Skip to main content

सूत्र DB (SutraDB) v3.3 Industrial Edition

PyPI Rust Python Tests Quantization Web UI License

सूत्र (Sūtra): An aphorism or thread of knowledge designed to hold vast wisdom in the most concise, unbreakable form.

SutraDB is an industrial-grade, ultra-fast vector & BM25 hybrid search engine built with a native Rust core and zero-overhead PyO3 Python bindings. It combines hand-tuned SIMD linear algebra (AVX2/NEON), Product Quantization (PQ) (up to 64x RAM reduction with Asymmetric Distance Computation), 1-Bit Binary Quantization (BQ) (32x RAM reduction), SQ8 Scalar Quantization (75% RAM reduction), dynamic online HNSW deletion & healing, geo-spatial metadata filtering, IVF-Flat indexing, multi-tenant namespace isolation, zero-copy memory mapping (memmap2), and official connectors for LangChain and LlamaIndex.

Designed specifically for production RAG (Retrieval-Augmented Generation), local AI agents, enterprise document retrieval, and low-latency voice AI where cloud vector database round-trips (>40ms) or Chroma's heavy memory overhead are unacceptable.


🏗️ Architecture

                               CLIENT REQUEST
       [ Text Query: "P99 latency bug" | Vector: [0.12, ...] | Namespace: "tenant_42" ]
       [ Metadata Filter: {"status": "resolved", "priority": {"$lte": 2}} ]
                                      │
                                      ▼
                       ┌──────────────────────────────┐
                       │   Rust Engine Core (GIL-Free)│
                       └──────────────┬───────────────┘
                                      │
         ┌────────────────────────────┼────────────────────────────┐
         ▼                            ▼                            ▼
┌──────────────────┐        ┌──────────────────┐         ┌──────────────────┐
│ Secondary Index  │        │ Dense Vector Core│         │ Sparse BM25 Core │
│ & AST Bitmask    │        │ (HNSW / SQ8 SIMD)│         │ (Lexical Tokens) │
└────────┬─────────┘        └────────┬─────────┘         └────────┬─────────┘
         │                           │                            │
         │ Dynamic Bitmask           │ Dense Scores               │ Lexical Scores
         │ [1, 0, 1, 0, ...]         │ [0.94, 0.41, ...]          │ [8.2, 0.0, ...]
         └─────────────┬─────────────┴──────────────┬─────────────┘
                       │                            │
                       ▼                            ▼
               ┌───────────────┐            ┌───────────────┐
               │ Masked Dense  │            │ Masked BM25   │
               │ Top-K Heap    │            │ Top-K Heap    │
               └───────┬───────┘            └───────┬───────┘
                       │                            │
                       └────────────┬───────────────┘
                                    │
                                    ▼
                    ┌───────────────────────────────┐
                    │ Reciprocal Rank Fusion (RRF)  │
                    │ Merges semantic + exact words │
                    └───────────────┬───────────────┘
                                    │
                                    ▼
                    ┌───────────────────────────────┐
                    │     Ranked Final Results      │
                    │   P50: <0.15ms | Recall: >98% │
                    └───────────────────────────────┘

⚡ Industrial Capabilities (v3.3)

  • Native Rust SIMD Core: Pure Rust computation core releasing the Python GIL during query execution and batch ingestion for zero-overhead multicore scaling.
  • Product Quantization (PQ) with Asymmetric Distance Computation (ADC): Decomposes high-dimensional vector spaces into $M$ orthogonal sub-spaces with k-means codebooks, achieving up to 64x RAM reduction. Query vectors compute precomputed Look-Up Tables (LUT) in L1 cache for sub-millisecond ADC similarity calculation with full-precision two-stage reranking.
  • 1-Bit Binary Quantization (BQ): Compresses 64 float32 dimensions into a single 64-bit word (u64), delivering a staggering 32x RAM reduction and sub-microsecond hardware POPCNT Hamming distance evaluation with two-stage candidate pruning + exact reranking for $>95%$ recall.
  • SQ8 Scalar Quantization (8-Bit): Compresses vectors from 32-bit floats to 8-bit unsigned integers, slashing RAM consumption by 75% while retaining $>98%$ recall via asymmetric dot product queries.
  • Dynamic Online HNSW Graph Deletion & Healing: Instant node removal with real-time edge re-wiring, neighbor reconnection, and entry point re-election without tombstones or graph fragmentation.
  • Geo-Spatial Filtering ($geo_within & $geo_box): Native great-circle Haversine distance in meters and rectangular bounding box queries supporting coordinate arrays [lat, lon] and dictionaries {"lat": ..., "lon": ...}.
  • Dual ANN Indexing (HNSW & IVF-Flat):
    • HNSW: Hierarchical Navigable Small World graphs for $O(\log N)$ vector search and dynamic streaming additions.
    • IVF-Flat: Sublinear Voronoi cell clustering with k-means++ for high-density batched workloads.
  • Official AI Framework Connectors: First-class integrations for LangChain (sutradb.integrations.langchain) and LlamaIndex (sutradb.integrations.llamaindex).
  • Nested JSON Metadata & Array Filtering: Dot-notation path resolution (user.profile.city) and operators ($eq, $ne, $gt, $gte, $in, $all, $size, $regex, $geo_within, $geo_box).
  • First-Class Multi-Tenancy (Namespaces): Strict hardware/logical isolation (namespace="tenant_123"). Zero cross-tenant data leaks.
  • Zero-Copy Memory-Mapped Files (memmap2): Direct OS page-cache mapping of .sutra binary vectors. Instant cold-start queries without loading gigabytes of data into heap RAM.
  • Resilient Write-Ahead Log (WAL): Atomic append-only transaction logging with CRC32 integrity checks, automatic snapshot compaction, and corrupted-tail power-cut auto-healing.
  • Zero-Dependency Web Console (/ui & /dashboard): Real-time monitoring dashboard with in-browser 2D Canvas PCA vector projection and hybrid query builder.

📊 Benchmark Comparison

Standard 4-vCPU Linux environment (100,000 documents, 128 dimensions):

Metric SutraDB v3.3 (सूत्र DB) ChromaDB Pinecone (Cloud)
Engine Core Rust SIMD (PyO3) Python / C++ Cloud Managed
RAM (100K 128-dim vectors) ~3.2 MB (PQ) / ~14 MB (SQ8) ~180 MB N/A (Remote)
Search Latency (P50) < 0.15 ms ~4.2 ms 35 – 65 ms (Network roundtrip)
Cold Start Time < 1 ms (Zero-copy mmap) ~850 ms N/A
Multi-Tenant Namespaces Native Built-in Separate DBs required Namespace metadata
Hybrid Search RRF + RSJ BM25 External / Addon Dense-first
Dependencies Zero heavy C++ toolchains ~45 pip dependencies Proprietary client + API key

🚀 Quickstart (Python)

1. Installation

pip install sutradb-core

Or build locally with maturin:

git clone https://github.com/Sam-CodesAI/SutraDB.git
cd SutraDB
maturin develop --release

2. Multi-Tenant Hybrid Search & SQ8 Quantization

from sutradb import SutraDB, Document

# 1. Initialize SutraDB with disk persistence
db = SutraDB(persist_directory="./sutra_data")
col = db.get_or_create_collection("enterprise_kb", dimension=4, metric="cosine")

# 2. Insert multi-tenant documents
col.insert([
    Document(
        id="doc_1",
        namespace="tenant_acme",
        vector=[0.95, 0.05, 0.10, 0.00],
        text="Deploying Kubernetes microservices and container ingress",
        metadata={"category": "devops", "env": "prod"}
    ),
    Document(
        id="doc_2",
        namespace="tenant_globex",
        vector=[0.02, 0.98, 0.05, 0.01],
        text="PostgreSQL connection pooling and query optimization",
        metadata={"category": "database", "env": "prod"}
    )
])

# 3. Build HNSW index for O(log N) ANN vector search
col.build_hnsw(m=16, ef_construction=64, ef_search=32)

# 4. Enable SQ8 8-bit quantization (75% RAM savings)
col.enable_sq8()

# 5. Hybrid search isolated to tenant_acme
results = col.query(
    vector=[1.0, 0.0, 0.0, 0.0],
    text="Kubernetes microservices",
    namespace="tenant_acme",
    filter={"category": "devops"},
    top_k=5,
    hybrid=True
)

for r in results:
    print(f"[{r.score:.4f}] ({r.namespace}) {r.id}: {r.text}")

3. Direct Native Rust Acceleration (Python)

from sutradb import NativeCollection

# Direct zero-overhead C/Rust engine
col = NativeCollection("fast_kb", dimension=128, metric="cosine")
col.insert(docs, vectors)
col.build_hnsw()
results = col.query(vector=q_vec, top_k=10, use_ann=True)

4. Official LangChain VectorStore Integration

from sutradb import SutraDBVectorStore
from langchain_openai import OpenAIEmbeddings

embeddings = OpenAIEmbeddings(model="text-embedding-3-small")
store = SutraDBVectorStore(
    collection_name="production_rag",
    dimension=1536,
    embedding_function=embeddings,
    persist_directory="./sutra_data",
    hybrid=True,  # Combines dense embeddings + BM25Okapi via RRF
)

# Standard similarity search or Maximal Marginal Relevance (MMR)
results = store.similarity_search("How to optimize vector search?", k=5)
diverse_results = store.max_marginal_relevance_search("P99 latency", k=4, fetch_k=20)
retriever = store.as_retriever(k=3)

5. Official LlamaIndex VectorStore Integration

from sutradb import SutraDBLlamaIndexVectorStore
from llama_index.core import VectorStoreIndex, StorageContext

vector_store = SutraDBLlamaIndexVectorStore(
    collection_name="knowledge_vault",
    dimension=1536,
    hybrid=True,
)
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex.from_documents(documents, storage_context=storage_context)

# Query with hybrid mode
query_engine = index.as_query_engine(vector_store_query_mode="hybrid")
response = query_engine.query("Explain memory mapping persistence")

6. Nested JSON Metadata & Array Filtering

Filter nested object paths with dot-notation and advanced operators:

results = col.query(
    text="distributed microservices",
    filter={
        "user.profile.city": "San Francisco",
        "user.profile.score": {"$gte": 90.0},
        "tags": {"$all": ["cloud", "docker"]},
        "tags": {"$size": 3},
        "env": {"$in": ["prod", "staging"]}
    },
    top_k=5
)

Compress high-dimensional vectors by 32x and evaluate Hamming candidate distances via hardware POPCNT:

# Enable 1-bit quantization
col.enable_bq()

# Queries automatically run Two-Stage Search:
# Stage 1: Fast Hamming distance scan over 1-bit bitmasks to select top candidates
# Stage 2: Exact full-precision distance reranking of top candidate pool
results = col.query(vector=query_vector, top_k=5)

8. Geo-Spatial Metadata Filtering ($geo_within & $geo_box)

Filter vectors using great-circle Haversine distances in meters or rectangular bounding boxes:

# Radius query within 5,000 meters of San Francisco center
sf_results = col.query(
    vector=query_vector,
    filter={
        "location": {
            "$geo_within": {
                "center": [37.7749, -122.4194],
                "radius_meters": 5000.0
            }
        }
    },
    top_k=10
)

# Bounding box query covering SF Bay Area
bay_results = col.query(
    text="local restaurants",
    filter={
        "location": {
            "$geo_box": {
                "bottom_left": [37.70, -122.50],
                "top_right": [37.85, -122.20]
            }
        }
    },
    top_k=10
)

9. Product Quantization (PQ) & Asymmetric Distance Computation (ADC)

Compress high-dimensional vectors by up to 64x using sub-space decomposition and evaluate similarities in sub-milliseconds via L1-cache Look-Up Tables (LUT):

# 1. Train codebook using k-means across sub-spaces
codebook = col.train_pq(num_subspaces=16, k_centroids=256, max_iter=20)

# 2. Enable PQ mode for the collection
col.enable_pq(codebook)

# 3. Two-Stage ADC Query:
# Stage 1: Asymmetric Distance Computation via precomputed query-to-centroid Look-Up Table (LUT)
# Stage 2: Top candidate pool reranked with full-precision vectors
results = col.query(vector=query_vector, top_k=5)

🌐 Embedded Web Management Dashboard

SutraDB includes a built-in, zero-dependency 2026 dark-mode Bento Grid web management console.

Start the microservice:

python3 -m sutradb.server 8765

Open your browser at:

http://localhost:8765/ui  or  http://localhost:8765/dashboard

Features included out of the box:

  • ⚡ Interactive Hybrid Playground: Test dense vectors, BM25 text queries, and slide RRF weights with live score bar breakdowns.
  • 📊 2D Vector PCA Projection: Visualizes high-dimensional embeddings mapped into an interactive in-browser 2D Canvas scatter plot with hover tooltips.
  • 🛠️ Collection Manager: 1-click HNSW indexing, Product Quantization (up to 64x RAM savings), 1-Bit BQ (32x savings), SQ8 (75% savings), and WAL compaction.
  • 💻 Real-Time Code Generator: Auto-generates exact Python SDK, LangChain, and curl code for any query.

🌐 REST Microservice Endpoints

  • GET /ui & GET /dashboard - Embedded Web Management Dashboard
  • GET /ui/stats - Telemetry metrics for console
  • GET /health - Health check & collection registry
  • GET /metrics - Prometheus metrics exporter
  • GET /collections/{name}/sample_vectors - Sample vectors for 2D visual projection
  • POST /collections/{name}/upsert - Idempotent upsert
  • PATCH /collections/{name}/documents/{id}/metadata - In-place metadata patch
  • POST /collections/{name}/hnsw - Trigger HNSW graph build
  • POST /collections/{name}/pq - Train & enable Product Quantization (up to 64x RAM reduction)
  • POST /collections/{name}/bq - Enable 1-Bit Binary Quantization (32x RAM reduction)
  • POST /collections/{name}/sq8 - Enable SQ8 vector quantization
  • POST /collections/{name}/query - Hybrid, vector, or lexical search

🧪 Test Suite

Run both native Rust and Python test suites:

# 1. Rust engine integration tests (19 tests)
cargo test

# 2. Python test suite (63 tests)
pytest -v

📜 License

MIT License. Engineered by Samarth.

Metadata

Release files for sutradb-core 3.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sutradb-core 3.3.0
File Size Uploaded Provenance Actions
sutradb_core-3.3.0.tar.gz 212.0 kB Without provenance Details for sutradb_core-3.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for sutradb-core 3.3.0
File Interpreter ABI Platform Actions
sutradb_core-3.3.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for sutradb_core-3.3.0-cp310-abi3-win_amd64.whl
sutradb_core-3.3.0-cp310-abi3-manylinux_2_34_x86_64.whl CPython 3.10 abi3 Linux glibc 2.34+ x86-64 Details for sutradb_core-3.3.0-cp310-abi3-manylinux_2_34_x86_64.whl
sutradb_core-3.3.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for sutradb_core-3.3.0-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 1.6 MB

Release files / sutradb_core-3.3.0.tar.gz

Download URL sutradb_core-3.3.0.tar.gz
Size 212.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1b9272e70189cb58a529537004ad0cff702722980687eb029ac2c3e9cd6fda58
BLAKE2b-256 checksum
How to use checksums
2f976b873fec9fbfb2aeee62c9e363e921d26acacc8f92dcd20007514a9e1edb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / sutradb_core-3.3.0-cp310-abi3-win_amd64.whl

Download URL sutradb_core-3.3.0-cp310-abi3-win_amd64.whl
Size 407.8 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
cd245dcad2eae8663f2c0239b76f3334c1a6d61e7fef21fa4be5b8c2215e718b
BLAKE2b-256 checksum
How to use checksums
efb502cae2be1393043903ca80dd8cb5dc7f44377ce8d3d7be6b8e1ee4040ddd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / sutradb_core-3.3.0-cp310-abi3-manylinux_2_34_x86_64.whl

Download URL sutradb_core-3.3.0-cp310-abi3-manylinux_2_34_x86_64.whl
Size 541.4 kB
Tags CPython 3.10 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
e5493fa997bd2692cad8c16450a7e8212b33f2a11bfe6ea938eb1bf6dba99c56
BLAKE2b-256 checksum
How to use checksums
d531151f1cde527e1cd1702a912949574bf32fb894a98ede17daddf675c20cbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / sutradb_core-3.3.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL sutradb_core-3.3.0-cp310-abi3-macosx_11_0_arm64.whl
Size 465.5 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
54272e860c149b677f99c2edbfb887aacf6058a72185424e09c66dcf10534c7e
BLAKE2b-256 checksum
How to use checksums
cd3110f1753c52e1d62d81e1af2f5c908d6a09736dc6c448d6d1e2b6b9366f7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for sutradb-core 3.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page