rig-memvid
Memvid-backed persistent memory and vector store for Rig agents.
memvid-core is a crash-safe, deterministic, single-file (.mv2) AI memory
format. This crate exposes that format to Rig in two ways:
MemvidStore— aVectorStoreIndexyou can register with an agent for RAG.MemvidPersistHook— aPromptHookthat automatically appends every user prompt and assistant response into a memvid file as the agent runs.
The two compose: persist with the hook, recall with the store. They share an
Arc<Mutex<Memvid>> so writes are immediately searchable.
Features
| Feature | Default | Description |
|---|---|---|
lex |
yes | BM25 / Tantivy lexical search. |
vec |
no | HNSW vector search via memvid-core/vec (ONNX Runtime + bundled BGE-small / BGE-base / Nomic / GTE-large). |
api_embed |
no | Remote embedding providers (OpenAI etc.) via memvid-core/api_embed. |
temporal |
no | Temporal track / point-in-time queries. |
encryption |
no | At-rest encryption of the .mv2 file. |
Vector search (vec)
Enabling vec pulls in ort = =2.0.0-rc.10, which conflicts with
rig-fastembed's =2.0.0-rc.9. Workspaces that depend on rig-fastembed
must stay on the default lex-only configuration until those pins converge
upstream. Workspaces that don't can opt in:
[]
= { = "0.1", = ["lex", "vec"] }
Attach a local embedder on the builder; reads and writes through
[MemvidStore] are then routed through memvid's HNSW index instead of
BM25:
let store = builder
.path
.with_default_embedder? // BGE-small, 384-dim
.open_or_create?;
The ONNX model and tokenizer are loaded from
$XDG_CACHE_HOME/memvid/text-models/ (or the platform equivalent). They
must already be on disk; memvid does not auto-download. Fetch them with:
When an embedder is attached:
MemvidStore::put_textembeds the payload and stores it viaput_with_embedding_and_options.MemvidStore::top_n/top_n_idsembed the query and runvec_search_with_embedding.MemvidFilter::scopeis honoured;uri,as_of_frame, andas_of_tsreturnMemvidError::UnsupportedFilter(memvid's vector path doesn't support those). Drop down toMemvidStore::search(SearchRequest)for full filter control.
Compatibility
rig-memvid |
rig-core |
memvid-core |
|---|---|---|
0.1 |
0.36 |
2.0 |
This crate is community-maintained and not affiliated with the rig project.
WASM
memvid-core depends on tantivy, mmap, and (optionally) onnxruntime.
This crate is not WASM-compatible and will not build for wasm32-*
targets.
Quickstart
use openai;
use ;
# async
Filter
MemvidFilter implements SearchFilter and accepts these keys via eq(...):
uri(String) — restrict to frames whose URI matches the given prefixscope(String) — restrict to a logical scopeas_of_frame(u64) — point-in-time view by frame idas_of_ts(i64) — point-in-time view by unix-millis timestamp
gt/lt/or are not supported by memvid's query model and will produce a
MemvidError::UnsupportedFilter at query time.
License
MIT