Skip to main content

Crate semantic_memory

Crate semantic_memory 

Source
Expand description

§semantic-memory

Hybrid semantic search library backed by SQLite + HNSW. Combines BM25 (FTS5) with approximate nearest neighbor search via Reciprocal Rank Fusion.

§Quick Start

use semantic_memory::{MemoryConfig, MemoryStore};

let store = MemoryStore::open(MemoryConfig::default())?;

// Store a fact
store.add_fact("general", "Rust was first released in 2015", None, None).await?;

// Search
let results = store.search("when was Rust released", None, None, None).await?;

Re-exports§

pub use config::ChunkingConfig;
pub use config::EmbeddingConfig;
pub use config::MemoryConfig;
pub use config::SearchConfig;
pub use embedder::Embedder;
pub use embedder::MockEmbedder;
pub use embedder::OllamaEmbedder;
pub use error::MemoryError;
pub use hnsw::HnswConfig;
pub use hnsw::HnswHit;
pub use hnsw::HnswIndex;
pub use quantize::pack_quantized;
pub use quantize::unpack_quantized;
pub use quantize::QuantizedVector;
pub use quantize::Quantizer;
pub use storage::StoragePaths;
pub use tokenizer::EstimateTokenCounter;
pub use tokenizer::TokenCounter;
pub use types::Document;
pub use types::Fact;
pub use types::MemoryStats;
pub use types::Message;
pub use types::Role;
pub use types::SearchResult;
pub use types::SearchSource;
pub use types::SearchSourceType;
pub use types::Session;
pub use types::TextChunk;

Modules§

chunker
Text chunking via recursive splitting with overlap.
config
conversation
Session and message CRUD for conversation storage.
db
Database initialization, migrations, and connection management.
documents
Document ingestion pipeline: chunk, embed, store.
embedder
Embedding trait and implementations.
error
hnsw
HNSW approximate nearest neighbor index wrapper.
knowledge
Fact CRUD with FTS5 synchronization.
quantize
Scalar quantization (SQ8) for f32 → i8 vector compression.
search
Hybrid search engine: BM25 + vector similarity + Reciprocal Rank Fusion.
storage
Storage path management for the memory directory convention.
tokenizer
Pluggable token counting for context budget management.
types

Structs§

MemoryStore
Thread-safe handle to the memory database.