Skip to content

Instantly share code, notes, and snippets.

@karpathy
Created April 4, 2026 16:25
Show Gist options
  • Select an option

  • Save karpathy/442a6bf555914893e9891c11519de94f to your computer and use it in GitHub Desktop.

Select an option

Save karpathy/442a6bf555914893e9891c11519de94f to your computer and use it in GitHub Desktop.
llm-wiki

LLM Wiki

A pattern for building personal knowledge bases using LLMs.

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.

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.

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.

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.

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.

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.
  • 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.
  • 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.
  • 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.

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.

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.

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.

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.

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.

Indexing and logging

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

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.

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.

Optional: CLI tools

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.

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.
  • 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'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.
  • Marp is a markdown-based slide deck format. Obsidian has a plugin for it. Useful for generating presentations directly from wiki content.
  • 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.
  • The wiki is just a git repo of markdown files. You get version history, branching, and collaboration for free.

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.

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.

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.

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.

@sparkleMing
Copy link
Copy Markdown

sparkleMing commented Apr 5, 2026

Had a similar idea but for daily recording and turned it into a product — Memex, an open-source mobile app that brings "LLM Knowledge Base" to daily life. AI agents auto-organize your recordings into P.A.R.A. Markdown wiki, generate visual cards, and discover life patterns.

🐙 memex-lab/memex

image

@HawHello
Copy link
Copy Markdown

HawHello commented Apr 5, 2026

Love the framing. Been running the same pattern on the execution side of research — the wiki holds data paths, training configs, eval records; Agent enters from Overview.md, progressive-discloses down, writes records back. Knowledge-side compounds knowledge; this one compounds project memory. https://github.com/HawHello/AgenticResearchWiki

@hejiajiudeeyu
Copy link
Copy Markdown

hejiajiudeeyu commented Apr 5, 2026

We've been running this pattern in production for a few weeks across multiple related knowledge domains. A few things we learned that might help others:我们已经在生产环境中运行了几周,涵盖多个相关知识领域。我们学到的一些可能对其他人有帮助的事情:

  1. Classify before you extract. When ingesting sources, don't treat every document the same. Classify by type first (e.g., report vs. letter vs. transcript vs. declaration), then run type-specific extraction. A 50-page report needs different handling than a 2-page letter. This comes from Folio's sensemaking pipeline — classify → narrow → extract → deepen — and it saves significant tokens while producing better results. Without it, you get shallow, uniform summaries of everything.提取前先分类。在获取来源时,不要把每份文档都一视同仁。先按类型分类(例如,报告、信件、文字记录与声明),然后进行类型特定提取。一份 50 页的报告需要不同的处理方式,而不是一封两页的信件。这来自 Folio 的意义建设流程——分类→狭窄→提取→深度——它节省了大量代币,同时产生更好的结果。没有它,你会得到浅薄且统一的总结。
  2. Give the index a token budget. The progressive disclosure idea is right, but it helps to make it explicit. We use four levels with rough token targets: L0 (~200 tokens, project context, every session), L1 (~1-2K, the index, session start), L2 (~2-5K, search results), L3 (5-20K, full articles). The discipline of not reading full articles until you've checked the index first is what makes this scale. Without it, the agent either reads too little or burns context reading everything.给指数一个象征性的预算。渐进式披露的理念是对的,但明确表达会更有帮助。我们使用四个级别,设定粗略的代币目标:L0(~200 个代币,项目上下文,每次会话)、L1(~1-2K,索引,会话开始)、L2(~2-5K,搜索结果)、L3(5-20K,完整文章)。这种自律在于你不先查看索引就读完整文章。没有它,代理人要么读得太少,要么在阅读所有信息时烧掉上下文。
  3. One template per entity type, not one generic template. A person page needs different sections than an event page or a document summary. Define type-specific required sections in your schema. The LLM follows them consistently, and the wiki stays structurally coherent as it grows. Seven types has been our sweet spot — enough to be useful, not so many that the schema becomes overhead.每个实体类型都用一个模板,而不是一个通用模板。个人页面需要不同的部分,而不是事件页面或文档摘要。在你的模式中定义特定类型的必填部分。大型语言模型始终遵循这些内容,维基随着成长结构保持连贯。七种类型一直是我们的甜蜜点——足够实用,但又不会太多让模式变得负担过重。
  4. Every task produces two outputs. This is the rule that makes the wiki compound. Whatever the user asked for — an analysis, a comparison, a set of questions — that's output one. Output two is updates to the relevant wiki articles. If you don't make this explicit in your schema, the LLM will do the work and let the knowledge evaporate into chat history.每个任务产生两个输出。这就是使维基为基地的规则。无论用户提出什么——分析、比较、一组问题——这就是输出。输出二是对相关维基条目的更新。如果你在模式中没有明确说明这一点,LLM 会帮你完成工作,让这些知识在聊天历史中消失。
  5. Design for cross-domain from day one. If there's any chance your knowledge spans multiple projects, cases, clients, or research areas — add a domain tag to your frontmatter now. Shared entities (people, organizations, concepts that appear in multiple domains) become the most valuable nodes in your graph. Retrofitting this is painful.从第一天起就设计跨域。如果你的知识可能跨越多个项目、案例、客户或研究领域——现在就在前言中添加域名标签。共享实体(人、组织、出现在多个领域的概念)成为图中最有价值的节点。改装这些设备很痛苦。
  6. The human owns verification. The wiki pattern works. But "the LLM owns this layer entirely" needs a caveat for anyone using this in high-stakes contexts. The LLM can synthesize without citing, and you won't notice unless you look. Build source citation into your schema rules, and budget time to spot-check the wiki — not just the deliverables. The LLM is the writer. You're the editor-in-chief.验证权归人类所有。维基模式有效。但“LLM 完全拥有这一层”需要对任何在高风险场合使用这种方式的人有个警告。LLM 可以不用引用就综合分析,除非你自己看,否则你不会注意到。在你的模式规则中加入源代码引用,并预留时间抽查维基——而不仅仅是交付物。LLM 是作者。你是主编。

https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f?permalink_comment_id=6079549#gistcomment-6079549
Extremely useful, thank you for sharing!

@tashisleepy
Copy link
Copy Markdown

Hi,

Experimented with an open-source implementation of this pattern with a Memvid bridge for dual-layer retrieval.

Wiki layer: Obsidian-compatible markdown with frontmatter, wikilinks, confidence tags, source citations. Human reads here.

Memvid layer: .mv2 single-file memory with sub-5ms search. Machine queries here.

The bridge keeps both in sync atomically - content hashing, drift detection, lint checks for contradictions and orphan pages.

Honest note in the README: at under 50 docs, the wiki alone is enough. The Memvid layer earns its keep at 500+ docs when grep gets slow.

https://github.com/tashisleepy/knowledge-engine

@nutbox-io
Copy link
Copy Markdown

The LLM Wiki is just the beginning; we believe we will soon move from the LLM Wiki into 24/7 autonomous, self-evolving social and transactional Agents.

https://x.com/0xNought/status/2040824383300932003

@john-ver
Copy link
Copy Markdown

john-ver commented Apr 5, 2026

Turned this into an OpenClaw skill — now I can just talk to my agent and build the wiki through conversation. Install and go:

npx clawhub@latest install karpathy-llm-wiki
https://clawhub.ai/john-ver/karpathy-llm-wiki

Great idea, thanks for sharing.

@pithpusher
Copy link
Copy Markdown

Your idea file concept clicked immediately — we already have AGENTS.md, CLAUDE.md, GEMINI.md for agent behavior, but nothing standard for the idea itself.

So I standardized it. IDEA.md: a vendor-neutral file for portable idea intent. Five sections — thesis, problem, how it works, what it doesn't do, where to start. Intentionally abstract, works with any agent.

Your LLM Wiki as a worked example: https://github.com/pithpusher/IDEA.md

@Sandesh-seezo
Copy link
Copy Markdown

I like this. Wonder if we can recreate the company intranet with such an architecture. The source of truth comes from humans who run/lead the department. The wiki is a self-improving knowledge base for Agents.
Also need something that helps humans consume all of this information. Maybe each employee is able to build a personalized intranet that works for them. Could be helpful for learning about parts of the company that you don't interact with everyday, without adding a massive burden of communication on each department

@JaxVN
Copy link
Copy Markdown

JaxVN commented Apr 5, 2026

Just getting started with Obsidian and this gist has been genuinely inspiring! 🙏

I'm experimenting with using it as a second brain — both for my own notes and as shared memory for Claude Code and Gemini AI via Google Antigravity. Still learning a lot, but your approach gave me a solid mental model to work from. Thanks for sharing the idea openly!

image

@Paul-Kyle
Copy link
Copy Markdown

Paul-Kyle commented Apr 5, 2026

Palinode. git blame on every fact your agent knows. Been using markdown as agent artifacts since August, across multiple harnesses. This is where I've landed. Git-versioned markdown as source of truth, 17 MCP tools, hybrid search (BM25 + vector via SQLite-vec). Memory directory doubles as an Obsidian vault.

A deterministic executor sits between the LLM and your files. The LLM proposes operations (KEEP, UPDATE, MERGE, SUPERSEDE, ARCHIVE) as JSON, the executor validates and applies them, then git commit. Every fact gets provenance for free. When a newer source supersedes a stale claim, you can see exactly what changed and when.

The lint operation you describe maps directly. Orphan detection, stale file flagging, contradiction detection across active entities.

Running 227 files, 2,230 indexed chunks. The compounding effect is real. Agents that remember prior sessions make fewer mistakes and ask better questions.

Screenshot 2026-04-05 at 11 22 18 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment