semantic-memory
Hybrid semantic search with SQLite — BM25 + vector + Reciprocal Rank Fusion. Built for AI agents, runs everywhere from ESP32 to servers.
Features
- Hybrid search: BM25 (FTS5) + dense vectors (HNSW or brute-force) + RRF fusion
- PerDim compressed scoring (default): 4× compression, 100% recall@10, 205ms artifact generation
- Multi-codec dispatch: Runtime-switchable backends — Disabled, PerDim, TurboQuant, FibQuant
- Digest-verified artifact pipeline: SQLite generations with blake3 integrity
- Feature-gated compile: Zero-cost when disabled —
per-dim-codec,fib-quant-codec,turbo-quant-codec - no_std compatible (via
compressed-scorer): Runs on ESP32-S3 microcontrollers
Quick start
[]
= { = "0.6", = ["per-dim-codec"] }
use ;
// Default: PerDim compressed with exact rerank (100% recall)
let config = default;
// Fast path: skip exact rerank (~1.2× faster, ~1% recall loss)
let mut config = default;
config.per_dim_require_exact_rerank = false;
// Fall back to brute force exact search
config.derived_vector_backend = Disabled;
Multi-codec dispatch
| Backend | Compression | Recall@10 | Build time | Use case |
|---|---|---|---|---|
| Disabled (brute force) | 1× | 1.000 | — | Exact search |
| PerDim (default) | 3.98× | 1.000 | 205ms | Production default |
| TurboQuant | ~5× | 0.95+ | seconds | Rotation-based |
| FibQuant | 5.9× | 0.08-0.14 | 78s | Max compression |
Performance
Benchmarked on AMD Ryzen 7 7730U, 1,865 vectors, 768-dim all-MiniLM-L6-v2 embeddings:
- Artifact generation: 205ms for full corpus
- PerDim exact rerank: 17.8 ms/query, 100% recall@10
- PerDim skip-rerank: 15.0 ms/query, 100% recall@10 (1.19× speedup)
- Space savings: 5.73MB → 1.44MB (3.98×)
Council Graph usage
semantic-memory is developed with Agent Graph council deliberation:
┌─ Coordinator ────────────────────────────────────┐
│ → Fanout → Analyst 0 (research) │
│ → Analyst 1 (implementation) │
│ → Analyst 2 (validation) │
│ → Join → Synthesize → Plan │
└───────────────────────────────────────────────────┘
Multi-perspective research, spec generation, and implementation planning use the council_deliberation template. See RecursiveIntell doctrine for the full workflow.
Feature flags
| Feature | Description | Dependencies |
|---|---|---|
hnsw (default) |
Approximate nearest neighbor via HNSW | hnsw_rs |
per-dim-codec |
Per-dimension uniform quantization (recommended) | compressed-scorer |
fib-quant-codec |
Fibonacci quantization with Gram-lookup | fib-quant, scr-runtime-compression |
turbo-quant-codec |
TurboQuant polar-coordinate encoding | turbo-quant, scr-runtime-compression |
poly-kv-codec |
Shared KV pool encoding | poly-kv |
License
Apache-2.0