Skip to main content

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

Use 0.2.1 or newer. It validates relation, column, index, distance, and dtype identifiers and coerces numeric HNSW settings before constructing CozoScript; earlier releases interpolated those configuration values directly.

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.

Metadata

Release files for langchain-mnestic 0.2.1

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

Source distribution (sdist)

Source distribution for langchain-mnestic 0.2.1
File Size Uploaded Provenance Actions
langchain_mnestic-0.2.1.tar.gz 9.4 kB With provenance Details for langchain_mnestic-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-mnestic 0.2.1
File Interpreter ABI Platform Actions
langchain_mnestic-0.2.1-py3-none-any.whl Python 3 none any Details for langchain_mnestic-0.2.1-py3-none-any.whl

Total release size: 17.0 kB

Release files / langchain_mnestic-0.2.1.tar.gz

Download URL langchain_mnestic-0.2.1.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1a9197f368c18aefb719971c4834b91ab00f51575ae8bd6342841ecf85de0386
BLAKE2b-256 checksum
How to use checksums
057b101ac322d80351b855081eacf4613b0c22beeb67524b354b1f40f147fcbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Release files / langchain_mnestic-0.2.1-py3-none-any.whl

Download URL langchain_mnestic-0.2.1-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9072caff4304995cdf3622bcca80eac5f1c1e540585d6c94bc96e52bb8b87886
BLAKE2b-256 checksum
How to use checksums
76c02ff43b2c85b1af1b3785f22a8f730e84fcd5ddf554cf3c362d5d5559e32c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

Security for langchain-mnestic 0.2.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_mnestic-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.

Transparency log

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