The Karpathy LLM wiki foundation is a memory pattern in which sources are compiled once into a wiki and the wiki is then queried. A compiled wiki is what is queried,1 whereas RAG re-reads raw sources on every question.2

Overview

Sources stay immutable, and the model writes the wiki.2 A schema states how to ingest, query, and maintain it.2 Useful answers are filed back, so later questions start from the wiki.2

Mechanism

  1. Immutable sources are indexed, and wiki pages are compiled from them.2
  2. On a question, the index is read, then the pages, and the answer cites them.2
  3. Useful outputs are filed back into the wiki.2
  4. The wiki is linted for stale claims, orphans, and missing links.2

Applications

The pattern applies when memory should be a maintained wiki instead of a fresh read of the sources on every question.

Limitations

The pattern is not a product to clone, and fine-tuning weights is not a substitute for first making the wiki the thing that is queried. RAG is not the primary memory when a compiled wiki already holds the answer.2

See also

Further reading

References

Footnotes

  1. https://x.com/karpathy/status/2039805659525644595 ↩

  2. https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9