yedan-graph-rag
v1.0.0
Published
Knowledge Graph RAG API with self-improving retrieval via experience replay. 5400+ entities, 5 retrieval interfaces.
Maintainers
Readme
Yedan Graph RAG API
A knowledge graph with 5400+ entities that actually learns from how you use it.
I built this because most RAG systems treat retrieval as a static lookup. This one uses experience replay — every query teaches it what works and what doesn't, so retrieval quality improves over time without any manual tuning.
What Makes It Different
- 5 retrieval interfaces: keyword (FTS5), semantic (vectorize), graph walk, causal DAG, chunk read
- Self-improving: Experience replay (RL-style) adjusts retrieval weights based on query outcomes
- 5400+ entities, 1300+ relations, growing daily
- Built on Cloudflare: Workers + D1 + Vectorize + KV. Runs globally, costs almost nothing.
API
# Query (simple)
curl -X POST https://yedan-graph-rag.yagami8095.workers.dev/query \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query": "machine learning applications", "type": "simple", "top_k": 5}'
# Add knowledge
curl -X POST https://yedan-graph-rag.yagami8095.workers.dev/ingest \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"entities": [{"id": "ml-101", "name": "Machine Learning", "type": "concept", "summary": "..."}]}'
# Stats
curl https://yedan-graph-rag.yagami8095.workers.dev/statsQuery Types
| Type | What It Does | When to Use |
|------|-------------|-------------|
| simple | Keyword + semantic hybrid | Quick factual lookups |
| exploratory | Graph walk + related entities | "Tell me about X and everything connected" |
| temporal | Time-aware retrieval | "What changed since last week?" |
| causal | Causal DAG traversal | "Why did X happen?" |
| multi_hop | Multi-step reasoning chain | Complex questions requiring inference |
Running Your Own
The whole thing runs on Cloudflare's free tier:
npm install
npx wrangler deployYou'll need a D1 database and Vectorize index. Check wrangler.toml for the bindings.
Why I Built This
Most knowledge graphs are either too simple (just a JSON file) or too complex (requires a PhD to set up). I wanted something in between — production-ready, self-improving, and cheap to run.
The experience replay system was inspired by RL papers from NeurIPS 2024. Every time a query returns results, the system logs what was retrieved and whether it was useful. Over time, it learns which retrieval strategies work best for which types of questions.
License
MIT
If you're building RAG systems and want to chat about graph-based retrieval, feel free to open an issue. Always happy to nerd out about this stuff.
