Karpathy-inspired · LLM Wiki Agent Workflow

Agent 負責寫。The Agent writes. Wiki 負責記住。The Wiki remembers.

這不是聊天機器人,也不只是 RAG。AI Agent 持續把原始資料編譯成一個可維護、可累積、會自己編織關聯的 Markdown 知識系統。 Not another chatbot, and not just RAG. AI agents continuously compile raw material into a persistent, maintainable, self-linking Markdown knowledge system.

0
層架構Layers
0
Agent 視角Agent Lenses
0
核心操作Operations
複利累積Compounding
核心概念The Core Idea

為什麼不是 RAG?Why not just RAG?

Andrej Karpathy 在他的 LLM Wiki gist 中指出:一般 RAG 每次提問都要「從零重新發現知識」,什麼都沒有累積。LLM Wiki 則讓知識被編譯一次、持續維護,愈用愈厚。 In his LLM Wiki gist, Andrej Karpathy points out that with plain RAG the LLM rediscovers knowledge from scratch on every question — nothing accumulates. An LLM Wiki compiles knowledge once and keeps it current, growing richer with use.

📄 raw docs 🔍 retrieve chunks 🤖 LLM 💬 answer 🗑 丟棄discarded 每次提問重來一遍repeats on every question

沒有累積。跨五份文件的綜合問題,每次都要重新拼湊;好答案消失在聊天紀錄裡。NotebookLM、檔案上傳、多數 RAG 系統都是這種模式。 No accumulation. A question spanning five documents gets re-assembled from fragments every single time; good answers vanish into chat history. NotebookLM, file uploads, and most RAG systems work this way.

📄 raw/ 🤖 Agent ingest 📚 wiki/ 知識頁pages 🔗 cross-links 持續複利累積compounds over time

知識編譯一次,持續保鮮。新資料進來時,Agent 讀取、萃取、整合進既有頁面——更新摘要、標記矛盾、補上交叉連結。好答案還能回寫成 synthesis 頁,探索成果也會複利。 Compiled once, kept current. When a new source arrives, the agent reads it, extracts key information, and integrates it — updating summaries, flagging contradictions, maintaining cross-references. Good answers get filed back as synthesis pages, so exploration compounds too.

"The wiki is a persistent, compounding artifact." 交叉連結已經在那裡,矛盾已經被標記,綜合已經反映你讀過的一切。 The cross-references are already there. The contradictions have already been flagged. The synthesis already reflects everything you've read. — Andrej Karpathy, LLM Wiki gist
系統設計System Design

三層架構The Three-Layer Architecture

依循 Karpathy 的原始設計:不可變的原始資料、LLM 全權維護的 wiki、以及定義 Agent 行為的 schema。 Following Karpathy's original design: immutable sources, an LLM-owned wiki, and a schema that turns the LLM into a disciplined maintainer.

raw/

原始資料層Raw Sources

你策展的來源文件——文章、論文、筆記。不可變的 source of truth,Agent 只讀不改。 Your curated source documents — articles, papers, notes. The immutable source of truth: the agent reads, never modifies.

llm-wiki.mdai-agent-workflow.mddeliberate-practice-notes.md+3
wiki/

知識頁層The Wiki

LLM 生成與維護的 Markdown 知識頁:摘要、概念頁、synthesis,加上自動維護的交叉連結。你讀,LLM 寫。整個資料夾可直接用 Obsidian 開啟。 LLM-generated and maintained Markdown pages: summaries, concept pages, syntheses, with auto-maintained cross-links. You read; the LLM writes. The folder opens directly as an Obsidian vault.

index.mdlog.mdprogramming/concepts/syntheses/
AGENTS.md

Schema 層The Schema

行為契約:定義 wiki 結構、慣例、以及 ingest / query / lint 的工作流程。這份檔案讓 LLM 從聊天機器人變成有紀律的 wiki 維護者。 The behavioral contract: wiki structure, conventions, and the ingest / query / lint workflows. This file is what makes the LLM a disciplined wiki maintainer instead of a generic chatbot.

4 agent roles3 operationstemplates/
index.md · 內容導向目錄content catalog + log.md · 時間軸操作紀錄append-only timeline = 不需向量資料庫也能導航整個知識庫navigation without any vector DB
互動示範Interactive Demo

Ingest 工作流模擬器Ingest Workflow Simulator

挑一份原始資料、選一個 Agent 視角,看知識如何被編譯進 wiki——五個步驟正是本機 Streamlit 版每次 ingest 真實執行的流程。 Pick a raw source and an agent lens, then watch knowledge get compiled into the wiki — the same five steps the local Streamlit app runs on every real ingest.

1讀取原始資料Read source
2以視角編譯Compile via lens
3寫入 wiki 頁Write wiki page
4更新交叉連結Update cross-links
5更新 index + logUpdate index + log
輸出會顯示在這裡……Output will appear here…

* 此為前端模擬。本機 Streamlit 版會由 Gemini 實際編譯內容並寫入真實的 Markdown 檔案。 * Front-end simulation. The local Streamlit app has Gemini actually compile the content and write real Markdown files.

多視角實驗The Multi-Perspective Twist

同一份資料,四種知識產出One source, four knowledge artifacts

在 Karpathy 原始概念之外,這個 demo 加上了「多視角 remix」:四個 Agent 角色把同一份來源編譯成各自用途的 wiki 頁,並互相交叉連結。點擊卡片可看實際生成的頁面。 On top of Karpathy's original idea, this demo adds a multi-perspective remix: four agent roles compile the same source into their own wiki page, all cross-linked. Click a card to read the actual generated page.

知識網絡The Knowledge Network

互動式知識圖譜Interactive Knowledge Map

重點不是產生單篇摘要,而是讓知識逐步形成網路。點擊任一節點,右側面板會顯示它的角色、連結數與鄰居;wiki 節點可以從面板直接開啟該頁。圖愈密,知識庫愈好走。 The point isn't producing one summary — it's letting knowledge grow into a network. Click any node to inspect its role, degree, and neighbors in the side panel; wiki nodes open right from there. The denser the graph, the more navigable the wiki.

KNOWLEDGE ATLAS
AN ATLAS OF THE WIKI
0節點nodes 0連結edges 最大樞紐top hub 拖曳節點 · 點擊查看詳情drag nodes · click for details

每次 ingest 後,系統會自動更新同一來源所有兄弟頁面的 Related Pages 區塊,讓交叉連結保持對稱。 After every ingest, the system refreshes the Related Pages block of every sibling page from the same source, keeping cross-references symmetric.

真實產出Real Output

瀏覽 Wiki 頁面Browse the Wiki

以下是 demo 實際生成的 Markdown 檔案——包含 YAML frontmatter、Related Pages 交叉連結,以及 index 與 log。這個資料夾同時也是一個 Obsidian vault。 These are the actual Markdown files the demo generated — YAML frontmatter, Related Pages cross-links, plus the index and log. The same folder doubles as an Obsidian vault.

Query

對整個 Wiki 提問Ask the Wiki

Query 流程:先讀 index 找到相關頁面,再讀頁面內容作答並附上引用。有價值的回答可以「回寫」成 synthesis 頁——讓探索也複利。 The query flow: read the index to find relevant pages, then answer from page content with citations. Valuable answers can be filed back as synthesis pages — so exploration compounds too.

* 線上展示版使用客戶端關鍵字檢索;本機 Streamlit 版由 Gemini 讀取相關頁面並生成完整回答。 * This online demo uses client-side keyword search; the local Streamlit app has Gemini read the relevant pages and synthesize a full answer.

Lint · Maintain

對 Wiki 執行健檢Health-check the Wiki

Karpathy 的第三個操作:定期讓 LLM 巡檢知識庫。這裡不是模擬——按下按鈕會即時掃描本站內嵌的所有 wiki 頁面,檢查空頁、index 缺漏、斷鏈與孤兒頁。 Karpathy's third operation: periodically have the LLM inspect the knowledge base. This is not a mock — the button scans every wiki page baked into this site, checking for empty pages, missing index entries, broken links, and orphans.

Starter Kit

把這套模式帶回家Take the pattern home

Karpathy 的 gist 本來就是設計來「複製貼上給你的 LLM Agent」的 idea file。三個步驟,今天就能開始自己的 LLM Wiki。 Karpathy's gist was designed to be copy-pasted to your own LLM agent. Three steps and you can start your own LLM Wiki today.

三步驟開始Three steps

  1. 建一個資料夾,裡面放 raw/wiki/ 兩個子資料夾和一份 AGENTS.md(或 CLAUDE.md)。 Create a folder with raw/, wiki/, and an AGENTS.md (or CLAUDE.md).
  2. 把右邊的模板貼進 AGENTS.md,交給 Claude Code / Codex,和它一起微調規則。 Paste the template into AGENTS.md, hand it to Claude Code / Codex, and tune the rules together.
  3. 丟入第一份來源到 raw/,說一聲「ingest」。從此 Agent 負責寫,Wiki 負責記住。 Drop your first source into raw/ and say "ingest". From then on the agent writes; the wiki remembers.

原始概念全文:The original idea file: Karpathy's LLM Wiki gist ↗

AGENTS.md 起步模板AGENTS.md starter template

# LLM Wiki Agent Rules (starter)

You maintain a personal knowledge wiki. Follow these
rules in every session.

## Layers
- raw/   Immutable sources. Read, never modify.
- wiki/  Compiled pages. You own this layer:
         create, update, cross-link.
- wiki/index.md  Catalog of every page with a
         one-line summary. Update on every ingest.
- wiki/log.md    Append-only history. Prefix:
         ## [YYYY-MM-DD] kind | message

## Operations
### Ingest
1. Read one source from raw/.
2. Extract key information into topic pages
   under wiki/.
3. Cross-link related pages, both directions.
4. Update index.md; append to log.md.
### Query
Read index.md first, then relevant pages.
Answer with citations. Offer to archive valuable
answers under wiki/syntheses/.
### Lint
Report contradictions, stale claims, orphan pages,
broken links, and missing index entries.

## Conventions
- Markdown with YAML frontmatter:
  title, updated, sources.
- Small focused pages beat long dumps.
- Link generously; the graph is the product.
完整版本The Full App

本機 Streamlit 完整版Run the full Streamlit app

這個網站是靜態展示;完整的 8 分頁工作流(Showcase → Inputs → Agents → Knowledge → Concepts → Map → Ask → Maintain)在本機執行,串接 Gemini API 寫入真實檔案。 This site is a static showcase; the full 8-tab workflow (Showcase → Inputs → Agents → Knowledge → Concepts → Map → Ask → Maintain) runs locally, wired to the Gemini API and writing real files.

三個指令啟動Three commands to launch

# 1. create env conda env create -f environment.yml conda activate llm-wiki-demo # 2. set your key $env:GEMINI_API_KEY="your-api-key" # 3. run streamlit run app.py

github.com/WayneChou-bot/LLM-Wiki-Agent-Workflow-Demo ↗

為什麼是 Markdown 而不是資料庫?Why Markdown instead of a database?

因為知識應該保持 portable、inspectable、human-readable。整個 wiki/ 是純 Markdown + git repo:版本歷史免費、Obsidian 直接開、不被任何平台綁死。 Because knowledge should stay portable, inspectable, and human-readable. The whole wiki/ is plain Markdown in a git repo: free version history, opens straight into Obsidian, zero vendor lock-in.

Lint 操作會定期健檢:空頁面、遺漏的 index 條目、失效連結、孤兒頁面。 The lint operation runs periodic health checks: empty pages, missing index entries, broken links, orphan pages.