LangChain VectorStore for mnestic — embedded graph + vector + full-text store with one-call hybrid retrieval.
Project description
langchain-mnestic
A LangChain VectorStore backed by
mnestic — an embedded graph + vector +
full-text database (a maintained fork of CozoDB). Retrieval is hybrid by
default: dense (HNSW) + keyword (full-text) fused with Reciprocal Rank Fusion, in
one call.
mnestic is a maintained fork of CozoDB; it is not the official CozoDB. Original design credit belongs to Ziyang Hu and the Cozo Project Authors.
pip install langchain-mnestic
from langchain_mnestic import MnesticVectorStore
from langchain_openai import OpenAIEmbeddings
store = MnesticVectorStore.from_texts(
["the cat sat on the mat", "a dog ran in the park"],
embedding=OpenAIEmbeddings(),
metadatas=[{"src": "a"}, {"src": "b"}],
engine="sqlite", path="mydocs.db", # or engine="mem" for ephemeral
)
docs = store.similarity_search("feline", k=2)
retriever = store.as_retriever(search_kwargs={"k": 4})
Scores returned by similarity_search_with_score are RRF fused scores — higher
is better (a relevance score, not a distance).
Engine pass-through: graph legs and more
Any extra keyword argument on the search methods goes straight to the engine's
hybrid query. That includes graph_legs — fuse graph proximity into the
ranking alongside the dense and keyword legs, in the same single call:
db = store._store.db # or pass your own CozoDbPy via MnesticVectorStore(db=...)
db.run_script(":create links {src: String, dst: String}", {}, False)
db.run_script("?[src, dst] <- [['doc-1', 'doc-9']] :put links {src, dst}", {}, False)
docs = store.similarity_search(
"feline", k=4,
graph_legs=[{
"edge_relation": "links", "from_col": "src", "to_col": "dst",
"seeds": ["doc-1"], "max_hops": 2, "label": "graph",
}],
)
extra_lists, vector_k, fts_k, rrf_k, and future engine keys pass through
the same way — no adapter release needed when the engine grows new knobs.
Mem0
The store works as a Mem0 vector-store backend
through Mem0's provider="langchain" (it implements the by-vector search, scored
search, get_by_ids, add_embeddings, and scalar metadata filter calls Mem0's
wrapper makes — exercised in tests/test_mem0.py):
config = {"vector_store": {"provider": "langchain",
"config": {"client": store, "collection_name": "mem0"}}}
License
Mozilla Public License 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_mnestic-0.2.0.tar.gz.
File metadata
- Download URL: langchain_mnestic-0.2.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a422eb7adc09db92f1e72ad0ea0e82bbcaec037185601c81180a0093652ba668
|
|
| MD5 |
94136a34ad9e611b0cbec7fe18c29a20
|
|
| BLAKE2b-256 |
9d7eb4605e0c48980a996cbe90fecf10eaafbd463f01d65c6dec11fa0af63d43
|
Provenance
The following attestation bundles were made for langchain_mnestic-0.2.0.tar.gz:
Publisher:
python-publish.yml on shuruheel/mnestic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_mnestic-0.2.0.tar.gz -
Subject digest:
a422eb7adc09db92f1e72ad0ea0e82bbcaec037185601c81180a0093652ba668 - Sigstore transparency entry: 2194910977
- Sigstore integration time:
-
Permalink:
shuruheel/mnestic@aecfd1fcf4aecf09675ebba5d78fc61f6c69da6d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/shuruheel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@aecfd1fcf4aecf09675ebba5d78fc61f6c69da6d -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file langchain_mnestic-0.2.0-py3-none-any.whl.
File metadata
- Download URL: langchain_mnestic-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65a0ce87c0f0b11da58ca8ed3daa3c8259d59a11f48ddae821a16cbad34585ca
|
|
| MD5 |
db9c6a864191e9c938dda0fdcf9a77e9
|
|
| BLAKE2b-256 |
8edf47496efc737c2d1b58bcaf6d47b562da39cd2f69af4292dc3a789686dff6
|
Provenance
The following attestation bundles were made for langchain_mnestic-0.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on shuruheel/mnestic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_mnestic-0.2.0-py3-none-any.whl -
Subject digest:
65a0ce87c0f0b11da58ca8ed3daa3c8259d59a11f48ddae821a16cbad34585ca - Sigstore transparency entry: 2194910981
- Sigstore integration time:
-
Permalink:
shuruheel/mnestic@aecfd1fcf4aecf09675ebba5d78fc61f6c69da6d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/shuruheel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@aecfd1fcf4aecf09675ebba5d78fc61f6c69da6d -
Trigger Event:
workflow_dispatch
-
Statement type: