graphwalk
Cheap, confidence-scored question answering over a knowledge graph you already have. Python library, CLI, and MCP server for agents.
graphwalk answers a question by walking the graph from the entities it names. Each hop
is a constrained classification decision: the current node's relations, plus
STOP, are the options, and a decider returns a probability for each. So every
answer comes with a path and a confidence, and you can escalate the unsure ones to
a stronger model.
Bring your own decider. graphwalk is the machinery (options, walks, confidence, escalation, the MCP tools); the decider plugs in:
- Jev (default), TypeSafe's classification model: the fastest we measured.
- Any model that returns token probabilities, at any OpenAI-compatible endpoint (OpenRouter, vLLM, llama.cpp, OpenAI). With Qwen3.8-27B (open weights) it matched Jev's accuracy and confidence quality, at about 10× the latency through OpenRouter; other models vary, so check yours.
- Your own: anything implementing
DecisionBackend(a fine-tuned classifier, a cross-encoder). See deciders.
pip install graphwalk
graphwalk import kg.nt --graph kg.db # triples: CSV, TSV, JSONL, N-Triples; no key needed
graphwalk query kg.db "Where was the director of Inception born?" --escalate-below 0.9
When to use it (measured)
Every number below comes from an experiment in docs/, on samples of 30–300
questions. Treat them as directions, not guarantees.
| Situation | What we found |
|---|---|
| An agent exploring a KG with graph tools (MCP) | Adding graphwalk's walk tool cut a strong agent's cost by 17% (95% CI 8–27%) at equal accuracy (0.76 vs 0.75 F1, n=100, WebQSP). Text search over the same facts was as accurate and a little cheaper, but slower; with entity names replaced by meaningless aliases (no help from the model's memory), graph tools beat it by 0.25 F1. |
| Existing KG, cost or latency first, or you need a per-answer confidence | walk is ~6× cheaper and ~4× faster than an LLM writing the query, and its confidence ranks answers well (AUROC 0.92 on WebQSP, up to 0.97 on MetaQA). |
| Existing KG, best accuracy | Have an LLM write the query instead: 0.66 vs 0.49 F1 on a 5,419-relation Freebase graph. |
| Questions with constraints or superlatives (CWQ) | Not graphwalk. Every system we tried scored about 0.3. |
| Questions over documents | Not graphwalk. Multi-step RAG wins by 10–19 F1. Text ingestion exists but is experimental. |
graphwalk does not claim to be more accurate than an LLM. What it offers is a cheap first answer that knows when it might be wrong.
Quickstart
The default decider is Jev, through OpenRouter
(OPENROUTER_API_KEY) or TypeSafe (TYPESAFE_API_KEY). GRAPHWALK_DECIDER=logprob
decides with an open-weights model's token probabilities instead (on OpenRouter by
default, or your own server via GRAPHWALK_DECIDER_BASE_URL).
import asyncio
from graphwalk import Index
async def main() -> None:
async with Index.open("kg.db", escalate_below=0.9) as index:
await index.import_triples("kg.nt") # idempotent
result = await index.walk("Where was the director of Inception born?")
print(result.best.names, result.confidence, result.escalated, result.cost_usd)
asyncio.run(main())
A runnable example over a 15-triple movie graph is in
examples/kg/.
For agents (MCP)
pip install 'graphwalk[mcp]'
claude mcp add --env OPENROUTER_API_KEY=sk-or-... graphwalk -- graphwalk mcp --db kg.db
Tools: walk (answers, paths, confidence), neighbors, get_node, status, plus
locate/read/ingest for text. The usual loop: call walk first; at confidence 0.9
or above, take the answer; below it, check it with neighbors or escalate. The server
also runs over HTTP with bearer or OAuth 2.1 auth, and ships as a container. See
MCP setup.
The package carries its own guide for coding agents: graphwalk guide (or
graphwalk guide --skill for a SKILL.md), and llms.txt.
Install options
| Extra | Enables |
|---|---|
| (none) | import, walk, query, the CLI |
mcp |
the MCP server (stdio and HTTP) |
llm |
LiteLLM: escalation, the LLM decider, text ingestion |
embeddings |
local fastembed embedder (prefilter, dense locate) |
eval |
dataset loaders for the benchmarks |
Documentation
- Docs site: quickstart, agents and MCP, configuration, text ingestion, evidence.
- Results: every experiment, with CIs, costs, and the runs behind it.
- Design record and roadmap.
Status
Alpha (v0.3). The public API is what graphwalk exports; submodules may change between
minor versions. Results are from small samples, mostly one seed. Jev is a hosted model
from TypeSafe; this project has no affiliation with TypeSafe, and does not depend on
it: any model with token probabilities can decide.
Development
See CONTRIBUTING.md.
License
Apache-2.0. See LICENSE.
Metadata
Release files for graphwalk 0.3.0
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 |
|---|---|---|---|---|
| graphwalk-0.3.0.tar.gz | 184.3 kB | With provenance | Details for graphwalk-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| graphwalk-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for graphwalk-0.3.0-py3-none-any.whl |
Total release size: 417.5 kB
Release files / graphwalk-0.3.0.tar.gz
| Download URL | graphwalk-0.3.0.tar.gz |
|---|---|
| Size | 184.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
89a23e7a0a0701166466f57450247b59892d7c56538ade8028842b0de592e76c
|
|
BLAKE2b-256 checksum How to use checksums |
22a0bd1a3f32b679549cac076831c3acc4e5126781c6ac1314dbbe3c05e4612f
|
| 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 Oct 28, 2026.
Transparency logRelease files / graphwalk-0.3.0-py3-none-any.whl
| Download URL | graphwalk-0.3.0-py3-none-any.whl |
|---|---|
| Size | 233.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fac991a30064a994fd130385418892ab48af117ac0bc581dd16a54387effa503
|
|
BLAKE2b-256 checksum How to use checksums |
1e3b78f5d0bd1a3665dc088febf0105d13f3abfdaf105e9ead243d51d3451c11
|
| 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 Oct 28, 2026.
Transparency logSecurity for graphwalk 0.3.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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for graphwalk-0.3.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 Oct 28, 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.