Karpathy's LLM Wiki Pattern
SmartDocs is built on a key insight from Andrej Karpathy's LLM Wiki pattern (April 2026, 5,000+ stars).
The Core Idea
Most AI + documents experiences work like this:
Upload files → ask question → LLM retrieves chunks → generates answer
The problem: the LLM re-derives understanding from scratch on every query. There's no accumulation. Ask a subtle question requiring synthesis across five documents, and the LLM finds and pieces together fragments every single time.
Karpathy's alternative: build a persistent, interlinked wiki that compounds over time.
"The knowledge is compiled once and then kept current, not re-derived on every query. This is the key difference: the wiki is a persistent, compounding artifact."
How SmartDocs Applies This
Your documentation is already a compiled artifact — you wrote it. SmartDocs reads the connections between your pages and uses them to provide better AI answers.
The Three Layers
Karpathy's architecture defines three layers:
| Layer | In Karpathy's Wiki | In SmartDocs |
|---|---|---|
| Raw sources | Articles, papers, PDFs — immutable | Your content/*.md files — immutable |
| The wiki | LLM-generated markdown pages, interlinked | Already written by you. SmartDocs reads the links. |
| The schema | CLAUDE.md telling the LLM how to structure | build-graph.js + page-index.json |
The Key Difference
Karpathy's pattern uses an LLM agent to write the wiki. SmartDocs doesn't need to — you already wrote it. SmartDocs does what the LLM agent would do: read your cross-references and build the graph.
Operations: Ingest, Query, Lint
Karpathy describes three operations for maintaining a wiki:
- Ingest — Add a new source. The LLM reads it, extracts key info, updates entity pages, flags contradictions, updates the index. One source can touch 10-15 wiki pages.
- Query — Ask a question. The LLM finds relevant pages, reads them, synthesizes with citations. Good answers get filed back into the wiki.
- Lint — Health check. Look for contradictions, stale claims, orphan pages, missing cross-references.
SmartDocs automates the Query operation. When a reader asks a question, SmartDocs finds the right pages, follows their links, and feeds full context to the LLM. The answer comes back grounded in your documentation.
The Lint operation is something you can do manually — check that your pages link to each other where relevant. Every link becomes a graph edge that improves retrieval.
Comparison with Traditional RAG
| Traditional RAG | Karpathy LLM Wiki | SmartDocs | |
|---|---|---|---|
| Knowledge persists? | No — re-derived each query | Yes — compiled once | Yes — your docs |
| Cross-references? | No — disconnected chunks | Yes — interlinked pages | Yes — built from your links |
| Needs embedding API? | Yes | No (index file) | No (index file) |
| Needs vector DB? | Yes | No (markdown files) | No (JSON graph) |
| Hallucination risk | High (fragments lack context) | Low (full pages) | Low (full pages) |
Further Reading
- Karpathy's original gist — The 5,000+ star description of the pattern
- LLM Wiki Setup Guide — Practical walkthrough with Obsidian
- How the AI Works — SmartDocs' implementation in detail