LLM Wiki - by karpathy

原文出处

LLM Wiki

A pattern for building personal knowledge bases using LLMs.

一种利用 LLM 构建个人知识库的模式

This is an idea file, it is designed to be copy pasted to your own LLM Agent (e.g. OpenAI Codex, Claude Code, OpenCode / Pi, or etc.). Its goal is to communicate the high level idea, but your agent will build out the specifics in collaboration with you.

这是一个概念性文件,设计用于复制并粘贴到你自己的 LLM Agent 中(例如 OpenAI Codex、Claude Code、OpenCode / Pi 等)。其目的是传达高层次的想法,而你的 Agent 将在与你协作的过程中构建出具体的实现。

The core idea

核心理念

Most people's experience with LLMs and documents looks like RAG: you upload a collection of files, the LLM retrieves relevant chunks at query time, and generates an answer. This works, but the LLM is rediscovering knowledge from scratch on every question. There's no accumulation. Ask a subtle question that requires synthesizing five documents, and the LLM has to find and piece together the relevant fragments every time. Nothing is built up. NotebookLM, ChatGPT file uploads, and most RAG systems work this way.

大多数人使用 LLM 处理文档的体验类似于 RAG:上传一批文件,LLM 在查询时检索相关片段,然后生成答案。这确实有效,但 LLM 在每个问题上都要从头开始重新发现知识。没有任何积累。当你提出一个需要综合五个文档的细微问题时,LLM 每次都必须重新寻找并拼凑相关片段。没有任何知识被建立起来。NotebookLM、ChatGPT 的文件上传以及大多数 RAG 系统都是这样工作的。

The idea here is different. Instead of just retrieving from raw documents at query time, the LLM incrementally builds and maintains a persistent wiki — a structured, interlinked collection of markdown files that sits between you and the raw sources. When you add a new source, the LLM doesn't just index it for later retrieval. It reads it, extracts the key information, and integrates it into the existing wiki — updating entity pages, revising topic summaries, noting where new data contradicts old claims, strengthening or challenging the evolving synthesis. The knowledge is compiled once and then kept current, not re-derived on every query.

这里的思路则不同。LLM 并不是在查询时仅仅从原始文档中检索,而是逐步构建并维护一个持久的 wiki——一个结构化的、相互链接的 markdown 文件集合,位于你与原始资料之间。当你添加一个新的资料来源时,LLM 不仅仅是为了后续检索而为其建立索引。它会阅读该资料,提取关键信息,并将其整合到现有的 wiki 中——更新实体页面、修订主题摘要、指出新数据与旧主张之间的矛盾之处,从而强化或挑战不断演变的综合认知。知识被一次性编译,然后保持最新状态,而不是在每个查询中重新推导。这就是关键区别:wiki 是一个持久的、不断累积的产物。交叉引用已经存在。矛盾之处已经被标记。综合认知已经反映了你所阅读过的所有内容。随着你添加的每一个资料来源和提出的每一个问题,wiki 都会变得越来越丰富。

This is the key difference: 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. The wiki keeps getting richer with every source you add and every question you ask.

这就是关键区别:wiki 是一个持久的、不断累积的产物。交叉引用已经存在。矛盾之处已经被标记。综合认知已经反映了你所阅读过的所有内容。随着你添加的每一个资料来源和提出的每一个问题,wiki 都会变得越来越丰富。

You never (or rarely) write the wiki yourself — the LLM writes and maintains all of it. You're in charge of sourcing, exploration, and asking the right questions. The LLM does all the grunt work — the summarizing, cross-referencing, filing, and bookkeeping that makes a knowledge base actually useful over time. In practice, I have the LLM agent open on one side and Obsidian open on the other. The LLM makes edits based on our conversation, and I browse the results in real time — following links, checking the graph view, reading the updated pages. Obsidian is the IDE; the LLM is the programmer; the wiki is the codebase.

你很少(甚至从不)自己编写 wiki——LLM 负责编写和维护 wiki 的所有内容。你负责筛选资料来源、进行探索性研究以及提出正确的问题。LLM 负责所有繁琐的工作——总结、交叉引用、归档和记账,正是这些工作让一个知识库在长期使用中变得真正有用。在实践中,我会在一边打开 LLM Agent,在另一边打开 Obsidian。LLM 根据我们的对话进行编辑,而我则实时浏览结果——点击链接、查看关系图谱、阅读更新后的页面。Obsidian 就是 IDE;LLM 就是程序员;wiki 就是代码库。

This can apply to a lot of different contexts. A few examples:

这可以应用于许多不同的场景。举几个例子:

  • Personal: tracking your own goals, health, psychology, self-improvement — filing journal entries, articles, podcast notes, and building up a structured picture of yourself over time.

  • 个人:追踪自己的目标、健康状况、心理学、自我提升——整理日记条目、文章、播客笔记,并随着时间的推移,逐步构建出一个关于自己的结构化图景。

  • Research: going deep on a topic over weeks or months — reading papers, articles, reports, and incrementally building a comprehensive wiki with an evolving thesis.

  • 研究:在数周或数月内深入探究某个主题——阅读论文、文章、报告,并逐步构建出一个包含不断演变的论点的综合性 wiki。

  • Reading a book: filing each chapter as you go, building out pages for characters, themes, plot threads, and how they connect. By the end you have a rich companion wiki. Think of fan wikis like Tolkien Gateway — thousands of interlinked pages covering characters, places, events, languages, built by a community of volunteers over years. You could build something like that personally as you read, with the LLM doing all the cross-referencing and maintenance.

  • 阅读一本书:在阅读过程中整理每一章,为人物、主题、情节线索及其相互关系建立页面。到最后,你会拥有一本丰富的伴读 wiki。想想像 Tolkien Gateway 这样的粉丝维基——成千上万相互链接的页面,涵盖了人物、地点、事件、语言,由一群志愿者多年构建而成。在阅读时,你也可以在 LLM 负责所有交叉引用和维护工作的情况下,个人构建出类似的东西。

  • Business/team: an internal wiki maintained by LLMs, fed by Slack threads, meeting transcripts, project documents, customer calls. Possibly with humans in the loop reviewing updates. The wiki stays current because the LLM does the maintenance that no one on the team wants to do.

  • 商业/团队:由 LLM 维护的内部 wiki,输入来自 Slack 聊天记录、会议转录文本、项目文档、客户通话记录。可能还需要人工介入来审阅更新内容。由于 LLM 会处理团队中没有人愿意做的维护工作,wiki 能够始终保持最新状态。

  • Competitive analysis, due diligence, trip planning, course notes, hobby deep-dives — anything where you're accumulating knowledge over time and want it organized rather than scattered.

  • 竞争分析、尽职调查、旅行规划、课程笔记、爱好深度挖掘——任何你需要随着时间的推移积累知识,并希望将其组织起来而非散落各处的场景。

Architecture

架构

There are three layers:

架构分为三个层次:

Raw sources — your curated collection of source documents. Articles, papers, images, data files. These are immutable — the LLM reads from them but never modifies them. This is your source of truth.

原始资料层 (Raw sources):由你精心挑选的源文档集合。文章、论文、图片、数据文件。这些是不可变的——LLM 会读取它们,但从不修改它们。这是你的事实来源。

The wiki — a directory of LLM-generated markdown files. Summaries, entity pages, concept pages, comparisons, an overview, a synthesis. The LLM owns this layer entirely. It creates pages, updates them when new sources arrive, maintains cross-references, and keeps everything consistent. You read it; the LLM writes it.

Wiki 层 (The wiki):一个包含 LLM 生成的 markdown 文件的目录。摘要、实体页面、概念页面、比较、概述、综合总结。LLM 完全拥有这一层。它创建页面,在新资料到达时更新它们,维护交叉引用,并保持一切内容的一致性。你阅读 Wiki;LLM 编写 Wiki。

The schema — a document (e.g. CLAUDE.md for Claude Code or AGENTS.md for Codex) that tells the LLM how the wiki is structured, what the conventions are, and what workflows to follow when ingesting sources, answering questions, or maintaining the wiki. This is the key configuration file — it's what makes the LLM a disciplined wiki maintainer rather than a generic chatbot. You and the LLM co-evolve this over time as you figure out what works for your domain.

模式层 (The schema):一个文档(例如,Claude Code 的 CLAUDE.md 或 Codex 的 AGENTS.md),它告诉 LLM wiki 的结构是什么、约定是什么,以及在摄取资料、回答问题或维护 wiki 时应遵循什么工作流程。这是关键的配置文件——它使 LLM 成为一个纪律严明的 wiki 维护者,而不是一个通用的聊天机器人。随着你逐步确定适合你所在领域的做法,你和 LLM 会随着时间的推移共同演进这个模式层。

Operations

操作

Ingest. You drop a new source into the raw collection and tell the LLM to process it. An example flow: the LLM reads the source, discusses key takeaways with you, writes a summary page in the wiki, updates the index, updates relevant entity and concept pages across the wiki, and appends an entry to the log. A single source might touch 10-15 wiki pages. Personally I prefer to ingest sources one at a time and stay involved — I read the summaries, check the updates, and guide the LLM on what to emphasize. But you could also batch-ingest many sources at once with less supervision. It's up to you to develop the workflow that fits your style and document it in the schema for future sessions.

摄取。你将一个新资料放入原始资料集,并告诉 LLM 处理它。一个示例流程如下:LLM 读取该资料,与你讨论关键要点,在 wiki 中编写一个摘要页面,更新索引,更新 wiki 中相关的实体和概念页面,并在日志中追加一条记录。单个资料可能会涉及 10-15 个 wiki 页面。我个人倾向于一次摄取一个资料,并保持参与——我会阅读摘要,检查更新,并指导 LLM 需要强调哪些重点。不过,你也可以在较少监督的情况下,一次性批量摄取多个资料。你可以根据自己的风格开发工作流程,并将其记录在模式层中,以供未来的会话使用。

Query. You ask questions against the wiki. The LLM searches for relevant pages, reads them, and synthesizes an answer with citations. Answers can take different forms depending on the question — a markdown page, a comparison table, a slide deck (Marp), a chart (matplotlib), a canvas. The important insight: good answers can be filed back into the wiki as new pages. A comparison you asked for, an analysis, a connection you discovered — these are valuable and shouldn't disappear into chat history. This way your explorations compound in the knowledge base just like ingested sources do.

查询。你向 wiki 提出问题。LLM 搜索相关页面,阅读它们,并综合出带有引用的答案。根据问题的不同,答案可以采取不同的形式——一个 markdown 页面、一个对比表格、一个幻灯片(使用 Marp)、一个图表(使用 matplotlib)、一个画布。一个重要的见解是:好的答案可以作为新页面归档回 wiki 中。你要求进行的比较、分析、发现的联系——这些都是有价值的,不应消失在聊天记录中。这样,你的探索性工作就能像摄入的资料一样,在知识库中得到累积。

Lint. Periodically, ask the LLM to health-check the wiki. Look for: contradictions between pages, stale claims that newer sources have superseded, orphan pages with no inbound links, important concepts mentioned but lacking their own page, missing cross-references, data gaps that could be filled with a web search. The LLM is good at suggesting new questions to investigate and new sources to look for. This keeps the wiki healthy as it grows.

检查。定期要求 LLM 对 wiki 进行健康检查。检查是否存在:页面之间的矛盾之处、已被新资料取代的过时主张、没有入站链接的孤立页面、被提及但缺乏独立页面的重要概念、缺失的交叉引用、以及可以通过网络搜索填补的数据空白。LLM 很擅长建议需要探究的新问题和需要查找的新资料。这能让 wiki 随着其增长而保持健康。

Indexing and logging

索引与日志

Two special files help the LLM (and you) navigate the wiki as it grows. They serve different purposes:

两个特殊文件可帮助 LLM(和你)在 wiki 不断增长时进行导航。它们服务于不同的目的:

index.md is content-oriented. It's a catalog of everything in the wiki — each page listed with a link, a one-line summary, and optionally metadata like date or source count. Organized by category (entities, concepts, sources, etc.). The LLM updates it on every ingest. When answering a query, the LLM reads the index first to find relevant pages, then drills into them. This works surprisingly well at moderate scale (~100 sources, ~hundreds of pages) and avoids the need for embedding-based RAG infrastructure.

index.md:面向内容。它是 wiki 中所有内容的目录——每个页面都列出一个链接、一行摘要,以及可选的元数据(如日期或来源计数)。按类别组织(实体、概念、资料等)。LLM 在每次摄取时都会更新它。在回答查询时,LLM 首先读取索引以找到相关页面,然后深入阅读它们。这在中等规模(约 100 个资料、数百个页面)下效果出奇地好,并且避免了需要基于嵌入的 RAG 基础设施。

log.md is chronological. It's an append-only record of what happened and when — ingests, queries, lint passes. A useful tip: if each entry starts with a consistent prefix (e.g. ## [2026-04-02] ingest | Article Title), the log becomes parseable with simple unix tools — grep "^## \[" log.md | tail -5 gives you the last 5 entries. The log gives you a timeline of the wiki's evolution and helps the LLM understand what's been done recently.

log.md:按时间顺序排列。它是一个只添加的记录,记录了发生的事情和时间——摄取、查询、检查。一个有用的技巧:如果每条记录都以一致的前缀开头(例如,## [2026-04-02] ingest | 文章标题),那么日志就可以用简单的 unix 工具进行解析——grep "^## [" log.md | tail -5 可以为你提供最后 5 条记录。日志提供了 wiki 演化的时间线,并帮助 LLM 了解最近完成了哪些工作。

Optional: CLI tools

可选:CLI 工具

At some point you may want to build small tools that help the LLM operate on the wiki more efficiently. A search engine over the wiki pages is the most obvious one — at small scale the index file is enough, but as the wiki grows you want proper search. qmd is a good option: it's a local search engine for markdown files with hybrid BM25/vector search and LLM re-ranking, all on-device. It has both a CLI (so the LLM can shell out to it) and an MCP server (so the LLM can use it as a native tool). You could also build something simpler yourself — the LLM can help you vibe-code a naive search script as the need arises.

在某些时候,你可能希望构建一些小工具,帮助 LLM 更高效地在 wiki 上操作。最明显的工具是 wiki 页面的搜索引擎——在规模较小时,索引文件就足够了,但随着 wiki 的增长,你会希望有一个合适的搜索引擎。qmd 是一个不错的选择:它是一个本地的 markdown 文件搜索引擎,具有混合 BM25/向量搜索和 LLM 重排序功能,全部在设备上运行。它既有 CLI(这样 LLM 可以调用它),也有 MCP 服务器(这样 LLM 可以将其作为原生工具使用)。你也可以自己构建一些更简单的工具——LLM 可以在需要时帮你快速编写一个简单的搜索脚本。

Tips and tricks

提示与技巧

  • Obsidian Web Clipper is a browser extension that converts web articles to markdown. Very useful for quickly getting sources into your raw collection.

  • Obsidian Web Clipper:这是一个浏览器扩展,可以将网页文章转换为 markdown 格式。对于快速将资料放入你的原始资料集非常有用。

  • Download images locally. In Obsidian Settings → Files and links, set "Attachment folder path" to a fixed directory (e.g. raw/assets/). Then in Settings → Hotkeys, search for "Download" to find "Download attachments for current file" and bind it to a hotkey (e.g. Ctrl+Shift+D). After clipping an article, hit the hotkey and all images get downloaded to local disk. This is optional but useful — it lets the LLM view and reference images directly instead of relying on URLs that may break. Note that LLMs can't natively read markdown with inline images in one pass — the workaround is to have the LLM read the text first, then view some or all of the referenced images separately to gain additional context. It's a bit clunky but works well enough.

  • 本地下载图片:在 Obsidian 的“设置 → 文件与链接”中,将“附件文件夹路径”设置为一个固定目录(例如 raw/assets/)。然后在“设置 → 快捷键”中,搜索“Download”找到“下载当前文件的附件”并将其绑定到快捷键(例如 Ctrl+Shift+D)。在剪裁文章后,按下快捷键,所有图片都会被下载到本地磁盘。这是可选的,但很有用——它可以让 LLM 直接查看和引用图片,而不是依赖可能失效的 URL。请注意,LLM 无法原生地通过一次传递来阅读带有内联图片的 markdown——解决方法是让 LLM 先阅读文本,然后单独查看部分或全部引用的图片以获取额外的上下文。这有点笨拙,但效果不错。

  • Obsidian's graph view is the best way to see the shape of your wiki — what's connected to what, which pages are hubs, which are orphans.

  • **Obsidian 的关系图谱视图 **:这是查看 wiki 结构的最佳方式——了解哪些页面相互关联,哪些页面是枢纽,哪些是孤立页面。

  • Marp is a markdown-based slide deck format. Obsidian has a plugin for it. Useful for generating presentations directly from wiki content.

  • Marp:一种基于 markdown 的幻灯片格式。Obsidian 有相应的插件。这对于直接从 wiki 内容生成演示文稿非常有用。

  • Dataview is an Obsidian plugin that runs queries over page frontmatter. If your LLM adds YAML frontmatter to wiki pages (tags, dates, source counts), Dataview can generate dynamic tables and lists.

  • Dataview:一个 Obsidian 插件,可以对页面 frontmatter 运行查询。如果你的 LLM 向 wiki 页面添加了 YAML frontmatter(如标签、日期、来源计数),Dataview 可以生成动态表格和列表。

  • The wiki is just a git repo of markdown files. You get version history, branching, and collaboration for free.

  • Wiki 本质上就是一个由 markdown 文件组成的 git 仓库。你可以免费获得版本历史、分支和协作功能。

Why this works

为什么这样做是有效的

The tedious part of maintaining a knowledge base is not the reading or the thinking — it's the bookkeeping. Updating cross-references, keeping summaries current, noting when new data contradicts old claims, maintaining consistency across dozens of pages. Humans abandon wikis because the maintenance burden grows faster than the value. LLMs don't get bored, don't forget to update a cross-reference, and can touch 15 files in one pass. The wiki stays maintained because the cost of maintenance is near zero.

维护知识库最繁琐的部分不是阅读或思考,而是记账 (bookkeeping)。更新交叉引用、保持摘要内容的最新状态、指出新数据与旧主张之间的矛盾之处、在几十个页面之间保持一致性。人们放弃 wiki,是因为维护的负担增长快于其价值的增长。LLM 不会感到无聊,不会忘记更新交叉引用,并且可以在一次传递中处理 15 个文件。Wiki 之所以能够保持维护状态,是因为维护成本几乎为零。

The human's job is to curate sources, direct the analysis, ask good questions, and think about what it all means. The LLM's job is everything else.

人的工作是对资料进行精选、指导分析方向、提出好的问题,并思考这一切意味着什么。LLM 的工作是其他所有事情。

The idea is related in spirit to Vannevar Bush's Memex (1945) — a personal, curated knowledge store with associative trails between documents. Bush's vision was closer to this than to what the web became: private, actively curated, with the connections between documents as valuable as the documents themselves. The part he couldn't solve was who does the maintenance. The LLM handles that.

这个想法在精神上与 Vannevar Bush 在 1945 年提出的 Memex 有关联——一个个人化的、精心挑选的知识存储,带有文档之间的联想路径。Bush 的愿景更接近于这个想法,而不是后来的万维网:私密的、主动精选的、文档之间的联系与文档本身同等重要。他无法解决的部分是:谁来负责维护?LLM 解决了这个问题。

Note

注意

This document is intentionally abstract. It describes the idea, not a specific implementation. The exact directory structure, the schema conventions, the page formats, the tooling — all of that will depend on your domain, your preferences, and your LLM of choice. Everything mentioned above is optional and modular — pick what's useful, ignore what isn't. For example: your sources might be text-only, so you don't need image handling at all. Your wiki might be small enough that the index file is all you need, no search engine required. You might not care about slide decks and just want markdown pages. You might want a completely different set of output formats. The right way to use this is to share it with your LLM agent and work together to instantiate a version that fits your needs. The document's only job is to communicate the pattern. Your LLM can figure out the rest.

本文档刻意保持抽象。它描述的是想法,而不是具体的实现。确切的目录结构、模式约定、页面格式、工具——所有这些都将取决于你的领域、你的偏好以及你选择的 LLM。上面提到的所有内容都是可选的、模块化的——选择对你有用的,忽略不需要的。例如,你的资料可能只是纯文本,因此你根本不需要图像处理功能。你的 wiki 可能规模很小,索引文件就足够了,不需要搜索引擎。你可能不关心幻灯片,只想要 markdown 页面。你可能想要一套完全不同的输出格式。使用本文档的正确方式是:与你的 LLM Agent 分享它,并一起努力实例化一个符合你需求的版本。本文档的唯一工作是传达这个模式。你的 LLM 可以完成剩下的工作。

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容