quipu
GraphRAG and agent memory that live inside the Postgres you already run.
quipu turns documents into a knowledge graph and answers multi-hop questions with it, entirely inside Postgres:
- Any managed Postgres. Plain SQL + plpgsql + pgvector. No C extension, no superuser, no second database. Runs on RDS, Aurora, Cloud SQL, AlloyDB, Azure, Supabase, Neon, Crunchy.
- Multi-tenant by row level security. Postgres enforces isolation on every query. App mode sets the tenant per transaction; role mode pins a database role to a tenant so it can't switch, even with raw SQL.
- A graph schema per tenant. Entity and relation types, allowed endpoints and typed properties, per graph. Strict mode rejects off-schema writes; open mode grows the schema from your data.
- Multi-hop retrieval. Facts and passages found by BM25 + dense search seed personalized PageRank over the entity–passage graph (the HippoRAG 2 design), computed in SQL.
- Time-aware facts. Bi-temporal relations: new facts supersede old ones without deleting them; query the graph
as_ofany date. - Any language. One JSON ingest contract and one
retrieve()SQL function. Python and TypeScript SDKs, a CLI, and an MCP server.
Benchmarks against HippoRAG 2's published numbers: see bench/RESULTS.md.
Install
pip install quipugraph # add [local] for local embeddings, [mcp] for the MCP server
quipu install "$OWNER_DATABASE_URL" --app-role app
quipu install runs CREATE EXTENSION vector and creates the quipu schema. It's idempotent.
To use your own migration tool instead: quipu sql > migrations/0001_quipu.sql.
The application must connect as a non-superuser role (superusers and BYPASSRLS roles skip
row level security). --app-role grants that role what it needs.
Python
from quipu import Quipu, AnthropicLLM, OpenAIEmbedder
q = Quipu("postgresql://app@db/prod", tenant="acme",
embedder=OpenAIEmbedder("text-embedding-3-small"), llm=AnthropicLLM())
q.create_tenant()
kb = q.create_graph("support", mode="strict", ontology={
"entities": [{"name": "Product"}, {"name": "Plan"}, {"name": "Feature"},
{"name": "Customer", "properties": {"region": {"enum": ["EU", "US"]}}}],
"relations": [{"name": "includes", "source": ["Plan"], "target": ["Feature"]},
{"name": "subscribed_to", "source": ["Customer"], "target": ["Plan"]}],
})
kb.add_many([{"external_id": "pricing.md", "text": open("pricing.md").read()}])
for hit in kb.retrieve("Which plans include SSO?", k=5):
print(hit.rank, hit.external_id, hit.content[:80])
print(kb.ask("Does Globex get SSO on their current plan?").text)
kb.neighbors("Enterprise plan") # what the graph knows about an entity
kb.retrieve("Who was CEO?", as_of="2025-01-01") # the graph as known on a date
Embedders: SentenceTransformerEmbedder (local, CPU/CUDA/Apple), OpenAIEmbedder (OpenAI or any
OpenAI-compatible server: Ollama, vLLM, TEI, LiteLLM). LLMs: AnthropicLLM, OpenAILLM (also
OpenAI-compatible servers), ClaudeCodeLLM (a local claude CLI, for development).
TypeScript
npm install quipugraph
import { Quipu, AnthropicLLM, OpenAIEmbedder } from "quipugraph";
const q = new Quipu({ connectionString: process.env.DATABASE_URL, tenant: "acme",
embedder: new OpenAIEmbedder(), llm: new AnthropicLLM() });
const kb = await q.createGraph("support", { existOk: true });
await kb.add([{ externalId: "pricing.md", text }]);
const hits = await kb.retrieve("Which plans include SSO?", { k: 5 });
SQL (any language)
The SDKs are thin wrappers. Everything is a SQL function:
SELECT quipu.use_tenant('acme'); -- per transaction
SELECT quipu.create_graph('support', 1536, '{"entities": [...]}', 'strict');
SELECT quipu.ingest('support', '{"external_id": "doc-1", "chunks": [{"content": "...",
"embedding": [...], "entities": [...], "relations": [...]}]}');
SELECT * FROM quipu.retrieve('support', 'question', $1::vector, '{"k": 5}');
SELECT * FROM quipu.search_facts('support', 'question', $1::vector, 10);
SELECT * FROM quipu.neighbors('support', 'Acme Corp');
SELECT quipu.context('support', ARRAY[12, 40]); -- facts grounding passages
See docs/sql-api.md for every function and option.
Agent memory (MCP)
{"mcpServers": {"quipu": {"command": "quipu", "args": ["mcp"],
"env": {"QUIPU_DATABASE_URL": "postgresql://app@db/prod", "QUIPU_TENANT": "me",
"QUIPU_GRAPH": "memory", "QUIPU_LLM": "anthropic:claude-haiku-5-5",
"QUIPU_EMBEDDER": "openai:text-embedding-3-small"}}}}
Tools: remember(text, source), recall(question), about(entity), forget(source).
How retrieval works
- Facts: BM25 + dense search over extracted facts. Their endpoints become seed entities, weighted by fact score ÷ the entity's passage count (rare entities count more). Optionally an LLM filters the facts first.
- Passages: BM25 + dense scores of the closest passages are added as small seeds (weight 0.05).
- Walk: personalized PageRank (damping 0.5) over entities, facts, synonym links (embedding similarity ≥ 0.8) and passage mentions, within a bounded neighborhood.
- Rank: passages by PageRank mass, optionally fused with the hybrid ranking.
Modes: graph (default), hybrid, dense, lexical. Options: k, fact_k, link_k,
passage_weight, seed_pool, damping, hops, max_nodes, lexical, fuse, as_of,
entities (query NER), fact_ids (pre-filtered facts).
Architecture
Decisions and their reasons are in docs/adr/.
Development
docker run -d --name quipu-pg -e POSTGRES_PASSWORD=quipu -e POSTGRES_USER=quipu -p 5434:5432 pgvector/pgvector:pg17
uv venv && uv pip install -e ".[local,mcp,bench,dev]"
pytest # SQL + SDK tests, as a non-superuser role
cd sdk/typescript && npm install && npm run build && npm test
Reproduce the benchmark: bench/README.md.
License
Apache-2.0. The name comes from the khipu, the Andean knotted-cord records: cords and knots that stored facts.
Metadata
Release files for quipugraph 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| quipugraph-0.1.1.tar.gz | 44.4 kB | With provenance | Details for quipugraph-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quipugraph-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for quipugraph-0.1.1-py3-none-any.whl |
Total release size: 91.0 kB
Release files / quipugraph-0.1.1.tar.gz
| Download URL | quipugraph-0.1.1.tar.gz |
|---|---|
| Size | 44.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d611a2d67084bcf33f12ee66954493f18d2648ab2cb699514592ad535e8023f8
|
|
BLAKE2b-256 checksum How to use checksums |
ff0a772a637cec2c466d307968d2227410a20c765f22421a15928595609d4374
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Dec 6, 2026.
Transparency logRelease files / quipugraph-0.1.1-py3-none-any.whl
| Download URL | quipugraph-0.1.1-py3-none-any.whl |
|---|---|
| Size | 46.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
300dcf3d1e5f6b026498f808f5de3a7b2805a9bab22a25fa4956780ba7a24011
|
|
BLAKE2b-256 checksum How to use checksums |
2f82eecf182609a7aa671fcdb52f61c79d1a55370d54b24f265ed72b689caa2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Dec 6, 2026.
Transparency logSecurity for quipugraph 0.1.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
Both files in this release have been uploaded with provenance metadata.
Attestation for quipugraph-0.1.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 Dec 6, 2026.
Transparency logA 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.