Series: RAG 系統架構 (1/5)

RAG's Five Stages: From Pipeline to Reasoning Retrieval, and the Naive RAG on My Own Site →
Key Points 7 min read
  • RAG retrieves chunks from scratch on every query and never accumulates knowledge; the LLM Wiki has the LLM actively weave information into a continuously updated markdown knowledge base that gets smarter the more you use it.
  • Three layers: Raw Sources (read-only original documents), The Wiki (LLM-maintained markdown pages), and Schema (the rules governing structure and workflow).
  • The key insight: the truly tedious part of maintaining a knowledge base isn't reading or thinking—it's the bookkeeping—and LLMs don't get tired, which is exactly the gap they fill.
Table of Contents

RAG (Retrieval-Augmented Generation) has been the industry’s default answer for years now: chunk your documents, vectorize them, and at query time find the relevant chunks and stuff them into the context. It solves the “the LLM doesn’t know your private data” problem—but it doesn’t solve another one: knowledge is static. Every query starts from scratch, there are no links between documents, and the system doesn’t get smarter the more you use it.

In April 2026, Andrej Karpathy proposed a different direction in a GitHub Gist: the LLM Wiki. The core claim is to have the LLM actively build and continuously maintain a structured knowledge base, rather than passively answering each individual query. This isn’t a minor improvement over RAG—it fundamentally replaces the assumption of “how a knowledge system should work.”

The Limits of Traditional RAG

The standard RAG pipeline looks like this:

flowchart LR
  A[Raw documents] --> B[Chunking]
  B --> C[Embedding]
  C --> D[("Vector database")]
  E[User query] --> F[Query embedding]
  F --> G[Similarity search]
  D --> G
  G --> H[Retrieve relevant chunks]
  H --> I[Stuff into LLM context]
  I --> J[Generate answer]

Every query is independent. The vector database only remembers “which pieces of text are similar to this query”—it doesn’t remember “what relationships exist between those pieces.”

This brings several concrete problems:

Weak cross-document reasoning: “How does this error relate to that incident three months ago?” RAG can find the individually relevant chunks, but it struggles to connect them and reason across them.

No compounding effect: You asked a great question today and the system produced a great answer, but that answer vanishes tomorrow—next time it has to be recomputed from scratch.

Semantic fragmentation from chunking: Slice a long document into 512-token chunks and a lot of context disappears at the boundaries. Vector similarity finds chunks that are “literally similar,” not necessarily the chunks that are “logically most relevant.”

Scale sensitivity: RAG performs fine when there aren’t many documents, but once you hit thousands, recall starts to drop and noise increases.

The Core Architecture of the LLM Wiki

Karpathy’s architecture has three layers:

graph TD
  A["📁 Raw Sources\n(original documents, immutable)\narticles, papers, notes, code"]
  B["📖 The Wiki\n(LLM-generated, continuously updated markdown pages)\nsummaries, cross-references, concept index"]
  C["⚙️ Schema\n(defines wiki structure and workflow)\noperating rules, page formats, update policy"]

  A -->|"Ingest"| B
  C -->|"governs"| B
  B -->|"Query"| D["👤 User"]
  B -->|"Lint"| B

Raw Sources is the immutable fact layer. Original articles, papers, conversation logs, and code all live here; the LLM only reads, never writes.

The Wiki is the knowledge layer. After reading in the Raw Sources, the LLM actively generates and maintains these markdown pages: creating entries for each important concept, writing cross-document summaries, and marking the relationships between concepts. These pages update as new data arrives—they aren’t generated once and then frozen.

Schema defines how the wiki grows: what page types exist, what format each page type uses, and under what circumstances which pages get updated. This is the skeleton of the system.

Three Core Operations

Ingest

When new data comes in, the LLM doesn’t just chunk it and store it in the vector database—it actively asks: “Which existing wiki pages does this data affect? Are there new concept entries that need to be created? Does anything contradict the older data?”


sequenceDiagram
  participant S as Raw Source (new document)
  participant L as LLM
  participant W as The Wiki

  S->>L: New document arrives
  L->>W: Read relevant existing pages
  W-->>L: Current knowledge state
  L->>L: Decide: add page / update page / flag conflict
  L->>W: Write or update markdown page

This process accumulates the relationships between pieces of knowledge, rather than just piling up data.

Query

At query time, the LLM reads wiki pages, not chunks of raw documents. Because wiki pages are already curated knowledge, the context quality is far higher than RAG’s fragmented chunks. For questions that require cross-concept reasoning, you can first look up the wiki index to find relevant pages, then read into them more deeply.

Lint

A health check run periodically or on demand. The LLM scans the wiki and finds: outdated content (a newer source has come in but the wiki wasn’t updated), orphaned pages (not referenced by any other page), and places where concept definitions are inconsistent. This lets the knowledge base self-heal.

LLM Wiki vs RAG: The Fundamental Differences

DimensionTraditional RAGLLM Wiki
Form of knowledgeChunks of raw documents + vectorsMarkdown pages curated by the LLM
Cross-document relationshipsIndirectly linked via vector similarityExplicit cross-references and concept index
Compounding effectNone (recomputed every query)Yes (the wiki grows over time)
Update methodRe-embed the entire documentOnly update the affected wiki pages
Query qualityHeavily affected by chunking strategyAffected by wiki quality
Build costLow (just embed)High (an LLM runs on every ingest)
Maintenance complexityLowMedium (you have to design a schema)
Suitable scaleTens to hundreds of documentsHundreds and up (where compounding really shows)

At a scale of around 100 articles and 400,000 words, Karpathy’s wiki noticeably beat an equivalent-scale RAG system on both Query accuracy and speed. The key reason: wiki pages are “digested knowledge,” not “fragments of raw data.”

When Should You Use an LLM Wiki?

Good fits:

  • Knowledge sources accumulate continuously (a blog, research notes, technical docs) and you want the system to get smarter the more you use it
  • You need cross-document reasoning: “What’s the relationship between concept A and concept B?”, “How has the perspective on this problem evolved across different periods?”
  • The knowledge base exceeds a few hundred documents and RAG’s recall has already started to disappoint you
  • You have the resources to design a schema and absorb the LLM cost of every ingest

Poor fits:

  • The documents are static and rarely updated (a one-shot RAG is enough)
  • You need to query the very latest data in real time (the LLM Wiki’s ingest has latency)
  • You’re resource-constrained and can’t afford to run an LLM every time new data arrives
  • The knowledge base is small (tens of documents)—RAG is already plenty

A practical rule of thumb: if you find yourself asking the knowledge system more and more of the same kind of question but having to re-explain the background each time, the LLM Wiki is a direction worth considering.

The State of Community Implementations

After the Gist was published, discussion took off quickly, and the community already has 50+ implementations:

  • OmegaWiki: a full three-operation pipeline implemented in Python + the Claude API
  • SwarmVault: a multi-agent collaborative wiki, with different agents responsible for different subject domains
  • WeKnora: integrates Obsidian as the wiki’s storage backend

The main challenge right now is schema design: there’s no standard for wiki page formats, different knowledge domains need different structures, and this part relies heavily on manual design. Karpathy’s own schema hasn’t been fully published yet.

Overall

The LLM Wiki solves a problem RAG never set out to solve: making machine-assisted knowledge management compound over time. RAG is “go look it up when you have a question”; the LLM Wiki is “keep the knowledge curated continuously, so when you ask a question you can find the answer fast.”

For personal knowledge bases, technical documentation systems, and long-term research notes, this direction has a lot of potential. For real-time querying and one-off Q&A, RAG remains the lighter-weight choice.

The two aren’t mutually exclusive—a more realistic direction may be to use the LLM Wiki as a preprocessing layer for RAG: first let the LLM curate the knowledge, then use vector search for precise pinpointing.

References

Ask this article

Answers come from this article only. Click any prompt below or open the chat at the bottom right.

🇺🇸 English

RAG has been the industry's go-to answer for years. You've probably heard the recipe a hundred times: take your documents, chop them into chunks, turn those chunks into vectors, and when a question comes in, find the chunks that look most similar and stuff them into the model's context. And honestly? It works. It solves the very real problem that a language model doesn't know anything about your private data.

But it leaves another problem completely untouched. With RAG, knowledge is static. Every single query starts from a blank slate. There are no links between your documents, and here's the kicker—the system never gets any smarter, no matter how much you use it. You could ask it the world's most brilliant question today, get a fantastic answer, and tomorrow that answer is just... gone. Vanished. Next time, it recomputes everything from scratch.

In April 2026, Andrej Karpathy published a GitHub Gist proposing a different direction entirely. He calls it the LLM Wiki. And the core idea is this: instead of having the model passively answer each question one at a time, you have it actively build and continuously maintain a structured knowledge base. This isn't a tweak to RAG. It's a different answer to the question of what a knowledge system should even be.

So let's talk about where traditional RAG hits its limits. Picture the standard pipeline: raw documents get chunked, embedded into vectors, dropped into a vector database. A user query comes in, it gets embedded too, you run a similarity search, pull back the relevant chunks, and feed them to the model. Clean. But notice—every query is an island. The vector database only remembers which pieces of text resemble your query. It has no memory of how those pieces relate to each other.

That creates a few concrete headaches. First, cross-document reasoning is weak. Ask something like, "How does this error connect to that incident three months ago?" RAG can dig up both relevant pieces individually, but stitching them together and reasoning across them? That's where it stumbles. Second, there's no compounding—that great answer from today doesn't stick around. Third, chunking itself fragments meaning. Slice a long document into little 512-token pieces and a lot of context just evaporates at the seams. Vector similarity finds text that's *literally* similar, which isn't always the text that's *logically* most relevant. And finally, it's sensitive to scale. RAG is perfectly happy with a few hundred documents. Push it into the thousands, and recall starts dropping while noise creeps up.

Now here's Karpathy's architecture, and it has three layers. Think of them as a stack.

At the bottom you've got Raw Sources—the immutable fact layer. Your original articles, papers, conversation logs, code. The model only ever reads from here. It never writes back. These are your ground truth.

In the middle sits The Wiki—the knowledge layer. This is where the magic happens. After reading the raw sources, the model actively generates and maintains a set of markdown pages. It creates an entry for each important concept, writes summaries that span across documents, and explicitly marks how concepts relate to one another. And crucially, these pages keep updating as new data flows in. They're alive, not frozen.

And on top, governing everything, is the Schema. The schema defines how the wiki grows: what types of pages exist, what format each one uses, and when a given page should get updated. It's the skeleton that holds the whole thing together.

Let's get into how it actually operates, because there are three core operations and they're each interesting.

The first is Ingest. When new data arrives, the model doesn't just chunk it and dump it into a database. It stops and asks real questions: Which existing wiki pages does this new information affect? Do I need to create new concept entries? Does any of this contradict what I already wrote down? So it reads the relevant existing pages, looks at the current state of knowledge, and then makes a decision—add a page, update a page, or flag a conflict—before writing back to the wiki. The point is, you're accumulating *relationships* between pieces of knowledge, not just piling up more data.

The second operation is Query. When you ask a question, the model reads wiki pages—not raw document chunks. And because those pages are already curated, distilled knowledge, the quality of the context is dramatically higher than RAG's scattered fragments. For a question that needs reasoning across concepts, you can first consult the wiki's index to find the right pages, then read deeper into them.

The third is Lint. And I love this one. It's basically a health check you run periodically. The model scans the whole wiki looking for problems: content that's gone stale because a newer source came in but the page never got updated, orphan pages that nothing else links to, and spots where a concept gets defined inconsistently in two different places. It lets the knowledge base heal itself. Your wiki does its own housekeeping.

So how does this really stack up against RAG, head to head? Let me walk through the differences. In RAG, knowledge takes the form of raw chunks plus vectors; in the LLM Wiki, it's curated markdown pages. Cross-document relationships in RAG are only implied through vector similarity; in the wiki they're explicit—actual cross-references and a concept index. Compounding effect? RAG has none, it recomputes every time; the wiki genuinely grows over time. Updating in RAG means re-embedding the whole document; in the wiki you only touch the pages that were actually affected.

Now, the wiki isn't free. Build cost in RAG is low—you just embed and you're done. The wiki is expensive, because an LLM has to run on every ingest. Maintenance is also heavier—you have to design that schema. And the sweet spots differ: RAG is great from tens to a few hundred documents, while the wiki really starts to shine at hundreds and up, where the compounding actually pays off.

And there's a real data point here. At around 100 articles, roughly 400,000 words, Karpathy's wiki clearly beat an equivalent RAG setup on both accuracy *and* speed. The reason comes down to one phrase: wiki pages are digested knowledge, not fragments of raw data.

So when should you actually reach for this? It's a strong fit when your knowledge keeps accumulating—a blog, research notes, evolving technical docs—and you genuinely want the system to get smarter the more you feed it. It's great when you need cross-document reasoning, like "how has the thinking on this problem shifted over time?" It makes sense once you've blown past a few hundred documents and RAG's recall has started letting you down. And it fits if you've got the resources to design a schema and eat the LLM cost on every ingest.

It's a poor fit in the opposite cases. If your documents are static and barely change, a one-shot RAG is plenty. If you need to query the very latest data in real time, remember the wiki's ingest has latency—it's not instant. If you're resource-constrained and can't afford an LLM run every time data lands, skip it. And if your knowledge base is small, just a few dozen documents, RAG already does the job fine.

Here's a practical rule of thumb I really like: if you keep asking your knowledge system the same kind of question but you find yourself re-explaining all the background every single time—that's your signal. That's when the LLM Wiki is worth a serious look.

The community jumped on this fast. Within a short time there were over fifty implementations. There's OmegaWiki, a full three-operation pipeline built in Python with the Claude API. There's SwarmVault, a multi-agent take where different agents own different subject domains. And there's WeKnora, which wires Obsidian in as the storage backend. The big open challenge right now is schema design—there's no standard for what a wiki page should look like, different domains need different structures, and a lot of it still comes down to hand-crafting. Karpathy hasn't even fully published his own schema yet.

So let me leave you with the core takeaways. First, the fundamental shift: RAG says "go look it up when you have a question," while the LLM Wiki says "keep the knowledge curated continuously, so when the question comes, the answer's already waiting." That's the whole philosophy in one line. Second, the wiki's real superpower is compounding—it's built for personal knowledge bases, technical docs, and long-term research notes that grow over time, whereas RAG stays the lighter, simpler choice for real-time lookups and one-off questions. And third—and this might be the most useful thing to walk away with—these two aren't enemies. The most realistic future might be using the LLM Wiki as a preprocessing layer that sits in front of RAG: let the model curate the knowledge first, then let vector search pinpoint the exact spot. Curate, then retrieve. You get the best of both.

🇹🇼 中文

RAG,也就是檢索增強生成,這幾年一直是業界的標準答案。做法很直觀:把文件切塊、轉成向量、查詢的時候找出相關的片段,塞進 context 給模型回答。它確實解決了「LLM 不知道你私有資料」這個問題。但它沒解決另一個問題——知識是靜態的。每一次查詢都從零開始,文件跟文件之間沒有連結,系統不會因為你用得越多就變得越聰明。

2026 年 4 月,Andrej Karpathy 在一份 GitHub Gist 裡丟出了一個不一樣的方向,叫做 LLM Wiki。核心主張是:讓 LLM 主動去建構、並且持續維護一個結構化的知識庫,而不是被動地回答每一次查詢。這不是對 RAG 的小修小補,而是從根本上換掉了「知識系統該怎麼運作」這個假設。

我們先看傳統 RAG 卡在哪。它的標準流程是把原始文件切塊、向量化、存進向量資料庫;查詢進來的時候也轉成向量,做相似度搜尋,找出最像的幾個片段,塞進 context 生成回答。問題在於,每一次查詢都是獨立的。向量資料庫只記得「哪些文字片段跟這個查詢相似」,它不記得「這些片段彼此之間有什麼關係」。

這會帶來幾個很具體的麻煩。

第一,跨文件推理很弱。比方你問「這個錯誤跟三個月前那個 incident 有什麼關係?」RAG 能找到個別相關的片段,但很難把它們串起來推理。

第二,沒有累積效應。你今天問了一個很好的問題,系統給了一個很好的答案,但這個答案明天就消失了,下次還得重新算一遍。

第三,切塊會把語意打碎。一份長文件切成 512 token 的小塊,很多上下文在邊界就不見了。向量相似度找到的是「字面上像」的塊,不見得是「邏輯上最相關」的塊。

第四,它對規模很敏感。文件少的時候還好,可是一旦量到幾千份,recall 開始下降,雜訊越來越多。

那 LLM Wiki 的架構長什麼樣?Karpathy 把它分成三層。

最底層是 Raw Sources,原始來源。文章、論文、對話紀錄、程式碼都放這裡,這是不可修改的事實層,LLM 只能讀、不能寫。

中間是 The Wiki,也就是知識層。LLM 讀進原始來源之後,會主動生成並維護一堆 markdown 頁面:為每個重要概念建立條目、寫跨文件的摘要、標記概念之間的關係。重點是,這些頁面會隨著新資料進來而更新,不是生成一次就凍結在那。

最上面是 Schema,它定義這個 wiki 該怎麼長:有哪些頁面類型、每種頁面的格式、什麼情況要更新哪些頁面。這是整個系統的骨架。

而讓 wiki 運轉起來,靠的是三個核心操作。

第一個是 Ingest,也就是吸收新資料。新東西進來的時候,LLM 不是單純把它切塊存起來,而是會主動問自己:這份資料影響到哪些現有的 wiki 頁面?有沒有需要新增的概念條目?有沒有跟舊資料矛盾的地方?它會先讀取相關的現有頁面,判斷該新增、該更新、還是該標記衝突,再把結果寫回去。這個過程累積的是知識之間的「關係」,而不只是把資料堆在一起。

第二個是 Query,查詢。查詢的時候,LLM 讀的是 wiki 頁面,不是原始文件的碎塊。因為 wiki 頁面已經是整理消化過的知識,所以 context 的品質比 RAG 那種碎片高很多。遇到需要跨概念推理的問題,可以先查 wiki 的索引找到相關頁面,再深入去讀。

第三個是 Lint,健康檢查。這個操作會定期或按需執行,讓 LLM 掃描整個 wiki,找出過時的內容——就是有新的 source 進來了但 wiki 還沒更新;找出孤立的頁面——沒被任何其他頁面引用到的;還有概念定義前後不一致的地方。這一步讓知識庫能夠自我修復。

那 LLM Wiki 跟 RAG 到底差在哪?我幫你把幾個關鍵維度講清楚。

知識的形式上,RAG 是原始文件的切塊加向量;LLM Wiki 是 LLM 整理過的 markdown 頁面。跨文件關係上,RAG 靠向量相似度間接連結;LLM Wiki 是明確的交叉引用跟概念索引。累積效應上,RAG 沒有,每次查詢都重算;LLM Wiki 有,wiki 會隨時間長大。更新方式上,RAG 要重新 embed 整份文件;LLM Wiki 只更新受影響的那幾頁。

當然 LLM Wiki 也有代價。建構成本比較高,因為每次 ingest 都要跑一輪 LLM;維護複雜度也比較高,你得花心思設計 schema。適合的規模也不一樣——RAG 在幾十到幾百份文件就夠用,LLM Wiki 要到幾百份以上,那個複利效應才會真的顯現出來。

Karpathy 自己的 wiki 大概在 100 篇文章、40 萬字的規模下,Query 的準確度跟速度都明顯贏過同等規模的 RAG。關鍵原因就一句話:wiki 頁面是「已經消化過的知識」,而不是「原始資料的碎片」。

那你該什麼時候用它?

適合的情況是:你的知識來源會持續累積,像部落格、研究筆記、技術文件,而且你希望系統越用越聰明;你常需要跨文件推理,比方「A 概念跟 B 概念的關係」、「同一個問題在不同時期觀點怎麼演變」;知識庫已經超過幾百份文件,RAG 的 recall 開始讓你不滿意;而且你有資源去設計 schema、也扛得起每次 ingest 的 LLM 成本。

不適合的情況也很清楚:文件是靜態的、不常更新,那一次性的 RAG 就夠了;你需要即時查最新資料,但 LLM Wiki 的 ingest 是有延遲的;你資源有限,沒辦法每來一筆新資料就跑一次 LLM;或者你的知識庫就幾十份文件,RAG 綽綽有餘。

有一個很實用的判斷標準:如果你發現自己對知識系統問的同類問題越來越多,但每次都得重新解釋一遍背景——那 LLM Wiki 就很值得考慮。

社群這邊反應也很快。Gist 一發出來就引爆討論,現在已經有 50 幾個實作。比方 OmegaWiki,用 Python 加 Claude API 把三個操作完整跑起來;SwarmVault 是多 agent 協作,不同 agent 負責不同主題領域;WeKnora 則是把 Obsidian 當成 wiki 的儲存後端。目前最大的挑戰是 schema 設計——wiki 頁面格式還沒有標準,不同知識領域需要不同結構,這塊高度依賴人工。連 Karpathy 本人的 schema 都還沒完整公開。

好,最後幫你收斂三個重點。

第一,LLM Wiki 解決的是一個 RAG 從來沒打算解決的問題:讓機器輔助的知識管理隨時間複利。RAG 是「有問題就去查」,LLM Wiki 是「平常就持續把知識整理好,問問題的時候才能快速找到答案」。

第二,它不是免費的。換來的累積效應,代價是每次 ingest 的 LLM 成本,加上你得自己設計 schema。所以它的甜蜜點在持續成長、規模偏大的個人知識庫跟長期研究筆記。

第三,這兩者其實不是二選一。更務實的做法,可能是把 LLM Wiki 當成 RAG 的前處理層——先讓 LLM 把知識整理乾淨,再用向量搜尋做精準定位。即時查詢、一次性問答這種輕量需求,RAG 還是更合適的選擇。

Tags

Related Articles

RAG's Five Stages: From Pipeline to Reasoning Retrieval, and the Naive RAG on My Own Site

Over the past two years RAG evolved from a 'linear pipeline' to 'loop-based reasoning'. It maps cleanly to five stages: Naive, Advanced, Modular, Graph, Agentic. The real inflection point is control moving from pipeline to agent — a System 1 → System 2 shift. Looking back at engineer-news's own RAG stack, it's stuck at the Naive edge — so this post also lays out what to fix next.

Building a Real RAG: 5 Infra Lessons from InfiniFlow's 2024 Year-in-Review

The previous post zoomed out for a five-stage panorama of RAG. This one zooms in on the five infra lessons any real RAG has to face: document ingestion, contextualized chunking, three-lane hybrid search, tensor reranker, and GraphRAG's semantic gap. Each lesson is checked against engineer-news's current stack, ending with a priority list for a personal site.