LLM Knowledge Bases
摘要
Karpathy 分享他用 LLM 构建个人知识库的工作流:raw/ 目录存放原始文档,LLM 增量"编译"成 .md wiki(含摘要、反向链接、概念分类文章);用 Obsidian 作为 IDE 前端查看原始数据、编译产物和可视化;wiki 达到约 100 篇文章/40 万字后,可以直接向 LLM agent 提问复杂问题。关键发现:不需要 fancy RAG,LLM 自己会维护索引文件和文档摘要。输出形式包括 Markdown 文件、幻灯片(Marp 格式)、matplotlib 图像。还会用 LLM 做 wiki 健康检查(不一致数据、缺失数据、新文章候选)。
正文
English
twitter/thread ┌─────────────────────┬─────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬───────┬──────────┬──────────────────────────────────────────────────────────┐ │ Id │ Author │ Text │ Likes │ Retweets │ Url │ ├─────────────────────┼─────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼───────┼──────────┼──────────────────────────────────────────────────────────┤ │ 2039805659525644595 │ karpathy │ LLM Knowledge Bases │ 55213 │ 6550 │ https://x.com/karpathy/status/2039805659525644595 │ │ │ │ │ │ │ │ │ │ │ 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. │ │ │ │ │ │ │ ...
*(Content truncated to 15000 characters)*
中文
*(Content needs translation - placeholder for bilingual format)*