LLM 知识库-Andrej Karpathy

Andrej Karpathy 2026年4月7日 09:37

大神Karpathy 讲他怎么用 LLM 构建和管理个人知识库,以下为原文:


LLM Knowledge Bases

Something I'm finding very useful recently: using LLMs to build personal knowledge bases for various topics of research interest. In this way, a large fraction of my recent token throughput is going less into manipulating code, and more into manipulating knowledge (stored as markdown and images). The latest LLMs are quite good at it. So:

Data ingest:

I index source documents (articles, papers, repos, datasets, images, etc.) into a raw/ directory, then I use an LLM to incrementally "compile" a wiki, which is just a collection of.md files in a directory structure. The wiki includes summaries of all the data in raw/, backlinks, and then it categorizes data into concepts, writes articles for them, and links them all. To convert web articles into.md files I like to use the Obsidian Web Clipper extension, and then I also use a hotkey to download all the related images to local so that my LLM can easily reference them.

IDE:

I use Obsidian as the IDE "frontend" where I can view the raw data, the the compiled wiki, and the derived visualizations. Important to note that the LLM writes and maintains all of the data of the wiki, I rarely touch it directly. I've played with a few Obsidian plugins to render and view data in other ways (e.g. Marp for slides).

Q&A:

Where things get interesting is that once your wiki is big enough (e.g. mine on some recent research is ~100 articles and ~400K words), you can ask your LLM agent all kinds of complex questions against the wiki, and it will go off, research the answers, etc. I thought I had to reach for fancy RAG, but the LLM has been pretty good about auto-maintaining index files and brief summaries of all the documents and it reads all the important related data fairly easily at this ~small scale.

Output:

Instead of getting answers in text/terminal, I like to have it render markdown files for me, or slide shows (Marp format), or matplotlib images, all of which I then view again in Obsidian. You can imagine many other visual output formats depending on the query. Often, I end up "filing" the outputs back into the wiki to enhance it for further queries. So my own explorations and queries always "add up" in the knowledge base.

Linting:

I've run some LLM "health checks" over the wiki to e.g. find inconsistent data, impute missing data (with web searchers), find interesting connections for new article candidates, etc., to incrementally clean up the wiki and enhance its overall data integrity. The LLMs are quite good at suggesting further questions to ask and look into.

Extra tools:

I find myself developing additional tools to process the data, e.g. I vibe coded a small and naive search engine over the wiki, which I both use directly (in a web ui), but more often I want to hand it off to an LLM via CLI as a tool for larger queries.

Further explorations:

As the repo grows, the natural desire is to also think about synthetic data generation + finetuning to have your LLM "know" the data in its weights instead of just context windows.

TLDR: raw data from a given number of sources is collected, then compiled by an LLM into a.md wiki, then operated on by various CLIs by the LLM to do Q&A and to incrementally enhance the wiki, and all of it viewable in Obsidian. You rarely ever write or edit the wiki manually, it's the domain of the LLM. I think there is room here for an incredible new product instead of a hacky collection of scripts.

LLM 知识库

我最近发现一件非常有用的事情:使用大语言模型(LLM)为不同的研究主题构建个人知识库。这样一来,我最近的大部分 token 消耗,不再主要用于处理代码,而是用于处理知识本身(以 markdown 和图片形式存储)。最新一代的 LLM 在这方面已经相当强大。具体来说:

数据摄取(Data ingest):
我会把来源文档(文章、论文、代码仓库、数据集、图片等)统一索引到一个 raw/ 目录中,然后使用 LLM 逐步“编译”出一个 wiki。本质上,这个 wiki 就是一个按目录结构组织的.md 文件集合。wiki 中包含对 raw/ 中所有数据的总结、反向链接,同时会将数据归类为不同概念,为这些概念撰写条目,并建立相互链接。将网页文章转成.md 文件时,我习惯使用 Obsidian Web Clipper 插件,同时通过快捷键把相关图片下载到本地,方便 LLM 引用。

IDE:
我使用 Obsidian 作为 IDE 的“前端”,在其中查看原始数据、编译后的 wiki,以及衍生的可视化内容。需要强调的是,wiki 的所有内容都是由 LLM 编写和维护的,我几乎不会手动修改。我也尝试过一些 Obsidian 插件,用于以不同方式展示数据,比如用 Marp 生成幻灯片。

问答(Q&A):
真正有意思的地方在于,当你的 wiki 足够大(例如我最近某个研究主题大约有 100 篇文章、约 40 万字),你可以针对这个 wiki 向 LLM agent 提出各种复杂问题,它会自行展开检索和分析来给出答案。我原本以为必须使用复杂的 RAG 方案,但在这个规模下,LLM 已经能够自动维护索引文件和文档摘要,并比较轻松地读取相关数据。

输出(Output):
相比直接在文本或终端中查看答案,我更喜欢让它生成 markdown 文件、幻灯片(Marp 格式)或 matplotlib 图像,然后再在 Obsidian 中查看。根据不同问题,还可以设计更多可视化输出格式。很多时候,我会把这些输出结果重新“归档”进 wiki,进一步增强知识库。因此,我的探索和提问本身也在不断积累知识。

校验(Linting):
我会运行一些 LLM 的“健康检查”,例如发现不一致的数据、补全缺失信息(结合网页搜索)、挖掘潜在关联以生成新的条目候选等,从而逐步清理和增强整个 wiki 的数据完整性。LLM 在提出后续值得研究的问题方面也表现很好。

扩展工具(Extra tools):
我也在开发一些额外工具来处理数据。例如,我随手写了一个简单的 wiki 搜索引擎,既可以直接通过 Web UI 使用,也可以通过 CLI 作为工具交给 LLM 处理更复杂的查询。

进一步探索(Further explorations):
随着仓库不断增长,自然会想到结合合成数据生成和微调,让 LLM 将这些知识“写入权重”,而不仅仅依赖上下文窗口。

总结:
从多个来源收集原始数据,由 LLM 编译成.md wiki,再通过各种 CLI 工具由 LLM 进行问答与持续优化,所有内容统一在 Obsidian 中查看。你几乎不需要手动编写或编辑 wiki,这完全是 LLM 的工作领域。我认为,这里完全有机会诞生一个真正优秀的新产品,而不是目前这种略显拼凑的脚本体系。

Powered by Forestry.md