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.

@Lukaschub
Copy link
Copy Markdown

thank you for sharing your knowledge Andrej! Something I'm wrestling with: Instead of one massive, single index file for an entire workspace, I setup a federated organization to keep things organized by project. Each major track has its own index.md. Curious on folks thoughts?

@LeonardoDaviti
Copy link
Copy Markdown

Anyone tested with local models?

@emory
Copy link
Copy Markdown

emory commented Apr 6, 2026

any alternative to obsidian for the command line?

obsidian has a cli tool officially and various community approaches. but for a PKM in terminal setup i learned about ekphos via macOS Homebrew, I don't know how flexible or close to Obsidian it is capability-wise.

@emory
Copy link
Copy Markdown

emory commented Apr 6, 2026

Anyone tested with local models?

be more specific, many people use local inference with knowledge bases or Obsidian vaults, myself included. Which part of this are you curious about? Local or cloud frontiers, obviously a lot of variation in quality of model but I use sub-20b models locally and have been using Obsidian and Ollama/LMStudio for quite a while now! Whatever models you use for research purposes if suitable for synthesis in other use cases it could probably work, as to if you're going to get the same quality as opus-4-6? I don't have the hardware for anything like that.

@liamsysmind
Copy link
Copy Markdown

I built WALI after reading @karpathy's LLM Knowledge Base gist and realizing I wanted something like it actually running at home.

The problem it solves: I collect a lot β€” articles, voice memos, meeting notes, random files β€” but never go back to organize any of it. Most of it just disappears.

WALI sits on my Mac Mini M4 and accepts anything I throw at it from my phone or browser. Text, files, audio recordings. It transcribes voice memos locally, stores everything in a raw inbox, and uses Claude to compile it into structured, cross-linked wiki articles in the background.

I don't have to categorize, tag, or file anything. I just collect. The knowledge base builds itself over time.

Everything stays on the machine β€” local ASR, local storage, local search. Claude handles the reasoning, but the data doesn't go anywhere.

It's a proof of concept. But the question behind it feels worth exploring: what if AI handled the parts of knowledge work that people
consistently don't do?

Built with Claude Agent SDK + Open WebUI + WikiForge.

github.com/liamsysmind/wali

@joshua-mike
Copy link
Copy Markdown

THIS IS FUN.

@wumborti
Copy link
Copy Markdown

wumborti commented Apr 6, 2026

This resonates a lot β€” I've been living this problem.

I recently shipped a personal project called [IdeasLake](https://ideaslake.com) β€” a "data lake for ideas" where long-running idea threads (notes, emails, analysis outputs) are treated as living artifacts, not one-off chats. I have 315+ ideas accumulated from 13 years of self-sent emails (yes, that kind of person), and this pain point showed up immediately when I tried to run AI analysis on one of my bigger ideas β€” a ~190-message Gmail thread, mostly with myself.

The key framing I keep returning to: LLMs are stateless by default, but ideas are inherently stateful and cumulative. Every conversation with an LLM about an idea is a one-off β€” nothing compounds. The wiki pattern you describe (persistent, compounding artifact between user and raw corpus) is the missing primitive for anyone with years of accumulated thinking spread across email, notes, and docs.

What's been working better for me on the summarization side is an incremental pipeline:

  1. Keep raw source messages immutable
  2. Maintain a rolling conversation_digest for older history
  3. Keep a "recent verbatim window" of the latest messages untouched
  4. On each update, process only deltas and merge into the digest with explicit conflict/uncertainty notes
  5. Run downstream analysis against digest + recent verbatim + delta β€” not the full thread each time

This preserves continuity while staying within token budgets. I'm building toward a per-idea structured schema (I call it a CIIM layer β€” Canonical Idea decomposition + Incremental Meta-analysis) that also extracts hypotheses, open questions, and cross-idea links from this process β€” designed to be updated, not regenerated.

Still actively working through:

  • Anti-drift checks across incremental summaries
  • Citation/traceability back to exact source messages
  • Contradiction tracking as new evidence arrives

If anyone else is building in this direction β€” especially fellow "too many ideas, too little time" people trying to manage a years-long personal corpus β€” I'd love to compare notes.
1000272919
1000272909
1000272913
1000272915
1000272917
1000272918

@Ar9av
Copy link
Copy Markdown

Ar9av commented Apr 6, 2026

Anyone tested with local models?

be more specific, many people use local inference with knowledge bases or Obsidian vaults, myself included. Which part of this are you curious about? Local or cloud frontiers, obviously a lot of variation in quality of model but I use sub-20b models locally and have been using Obsidian and Ollama/LMStudio for quite a while now! Whatever models you use for research purposes if suitable for synthesis in other use cases it could probably work, as to if you're going to get the same quality as opus-4-6? I don't have the hardware for anything like that.

Thats what I tried to tackle with my repo . I actually do it only through Gemma 4 with local obsidian vaults

@mmoustafa8108
Copy link
Copy Markdown

haven't any one made an implementation for this?
like in python for example!

@thomastron
Copy link
Copy Markdown

@wumborti
Dude, easy on the images! This thread is unusable now because everyone has to scroll through your long sequence of images. Use links or create small thumbnails or something...

@jmcastagnetto
Copy link
Copy Markdown

Using an LLM as an assistant to organize one's digital mess is a good idea. Perhaps compounded with the ideas/framework from the Zettlekasten method (https://zettelkasten.de/introduction/) - I've tried to do this manually but never had the required time to organize all the digital minutiae that live in my computer.

@jurajskuska
Copy link
Copy Markdown

Hi Andrej, here are some points we reached a bit earlier using OBSIDIAN. Greetings from bratislava to you.

The Destination: Self-Improving Multi-Agent System

What the architecture becomes when the loop matures:

πŸ€– Specialised agents, not one generalist β€” small agents each own a narrow task: research, audit, context update, safety check. Scoped context means fewer mistakes, faster execution, no overload.

⚑ Parallel execution β€” agents run simultaneously. Research agent finds information while audit agent checks integrity while context agent updates gaps. Human is not the bottleneck.

πŸ” Self-improving context loop β€” agents report what was missing or wrong. Context is updated. Next run starts better than the last. The loop runs until context is sufficient β€” then agents operate with minimal human input.

πŸ›‘οΈ Human + safety agents as overseers β€” human is not doing the work, human is treating: reviewing flagged weaknesses, approving context updates, watching for injection or drift. Specialised safety agents run the 4-eyes check automatically.

🧠 Autoresearch as natural output β€” when context is rich enough and agents are specialised enough, research loops run autonomously. Human sets the question, agents find the answer, safety layer validates, context is updated with findings.

πŸ“ˆ Self-learning by design β€” every session adds to the indexed layer. Every gap found improves the next run. The system learns from its own history without anyone explicitly teaching it.

🎯 Human role shifts β€” from operator to architect. From doing to directing. From fixing gaps manually to reviewing what the system flagged and approving the fix.

🐜 Small models as executors, large models as architects β€” bigger models are not always desired. With proper context equipment, smaller models execute reliably and cheaply β€” like ants working the same target in parallel. Larger models are reserved for what they do best: creating new solutions, designing better approaches, solving novel problems. The division is natural: architect once, execute many times.

πŸ”¨ "You wouldn't nail pins with a big hammer." β€” Juraj, 2026-04-05

πŸ’‘ Human creativity is the multiplier β€” the system amplifies what humans bring, it doesn't replace it. When the human is properly involved β€” setting direction, spotting what agents miss, injecting creative leaps β€” the synergy produces results none of the parts could reach alone. Agents execute with precision. Humans provide the spark.

🌐 End state: a parallel, self-correcting, context-driven agent network β€” where MD files are the shared language, Obsidian is the human dashboard, SQLite is the speed layer, large models design, small models execute, human creativity drives the direction, and the loop never stops improving.

@Nimo1987
Copy link
Copy Markdown

Nimo1987 commented Apr 6, 2026

This note was a big inspiration. I ended up building an open-source implementation of the idea here:

https://github.com/Nimo1987/atomic-knowledge

I pushed it in the direction of a markdown-first work-memory protocol for existing agents: explicit ingest/query/writeback/maintenance flows, a provisional candidate buffer before durable pages, and a small example KB plus evals.

Thanks for the original framing.

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