Skip to main content

langchain-sqlite-graph-memory

A LangChain retriever over your own markdown notes, with the links between them. It runs sqlite-graph-memory: vector search finds the entry points, the [[wikilinks]] you already wrote are the graph, and a cross-encoder reranks what the 1-hop expansion pulled in. Everything runs on your machine: no server, no graph database, no LLM call at retrieval time.

pip install "langchain-sqlite-graph-memory[lite]"   # ONNX models, starts in seconds
sgm-index /path/to/your/notes                      # builds ./index once
from langchain_sqlite_graph_memory import SQLiteGraphMemoryRetriever

retriever = SQLiteGraphMemoryRetriever(index_dir="./index", k=8)

for doc in retriever.invoke("why did we drop the graph database?"):
    print(doc.metadata["rank"], doc.metadata["title"], doc.metadata["via_graph"])

Each result is a Document. page_content holds the matched chunk of the note. metadata holds path, title, date, score (cross-encoder), rank, and via_graph. via_graph is True when the note came in only through a wikilink from a top vector hit, so you can tell associative recall from direct recall.

Options

Argument Default What it does
index_dir $BRAIN_INDEX_DIR, else ./index Folder with the sgm-index output
k 12 Documents returned. retriever.invoke(q, k=3) overrides it per call
graph "auto" True always follows wikilinks, False never does. "auto" follows them except for name or tool lookups, where the hop measured as noise
fetch_k 60 Unique notes taken from vector search before expansion and rerank
encoder, reranker SGM models Pass your own preloaded models, or fakes in tests

In an agent

from langchain_core.tools import create_retriever_tool

recall = create_retriever_tool(
    retriever, "recall_notes",
    "Search my notes and the notes they link to. Use for anything I wrote down before.",
)

Scope, stated plainly

  • This adapter calls the core library and adds nothing to retrieval. It calls the same functions sgm-ask calls (query_sims, retrieve_candidates, expand_1hop, rerank_candidates). A test pins this: the adapter's order must equal a direct call of those functions. On a real vault of 29,474 notes (105,383 chunks), the adapter returned the same 12 notes in the same order as sgm-ask --graph.
  • The index is two files on disk, an embedding matrix (.npy) and note metadata (.pkl), written by sgm-index. Wikilinks are read from the notes at query time. SQLite stores the core library's session memory and A/B logs. The retriever needs only the two index files.
  • Embeddings: intfloat/multilingual-e5-base. Reranker: cross-encoder/mmarco-mMiniLMv2-L12-H384-v1. Both work for many languages.
  • Not implemented yet: a VectorStore (adding documents through LangChain) and a LangGraph long-term memory store. Indexing goes through sgm-index.

Tests

pip install -e ".[test]"
pytest

The suite includes LangChain's standard retriever tests (langchain-tests). It runs with fake models on a four-note vault: no download, no GPU, a few seconds.

License

MIT

Metadata

Release files for langchain-sqlite-graph-memory 0.1.0

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-sqlite-graph-memory 0.1.0
File Size Uploaded Provenance Actions
langchain_sqlite_graph_memory-0.1.0.tar.gz 9.8 kB With provenance Details for langchain_sqlite_graph_memory-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-sqlite-graph-memory 0.1.0
File Interpreter ABI Platform Actions
langchain_sqlite_graph_memory-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_sqlite_graph_memory-0.1.0-py3-none-any.whl

Total release size: 17.3 kB

Release files / langchain_sqlite_graph_memory-0.1.0.tar.gz

Download URL langchain_sqlite_graph_memory-0.1.0.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
aafc844875351648ae7b376328cdd1f0aedae6da43b98f3df1053ba82a9d76a8
BLAKE2b-256 checksum
How to use checksums
ffa064cd00f75eeadf3756ddc025967dc2dee99c2915c399f058ea5ed989b236
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 Nov 10, 2026.

Transparency log

Release files / langchain_sqlite_graph_memory-0.1.0-py3-none-any.whl

Download URL langchain_sqlite_graph_memory-0.1.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6cc58253cced97c9c40e275f7e018e92501ad31ec5c5f3156f7cee34c28f143
BLAKE2b-256 checksum
How to use checksums
3a76f76e7c030a3e306b4b0c899b7ebd882e8d2fa33fe3e4cd3bc6be34c29ec4
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 Nov 10, 2026.

Transparency log

Security for langchain-sqlite-graph-memory 0.1.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_sqlite_graph_memory-0.1.0.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 Nov 10, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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