Back to directory

How LLMs Work

How LLMs Work is an interactive local app that walks through the whole LLM pipeline hands-on, from a rule-based chatbot to training a small transformer from scratch, with runnable code for every stage.

How LLMs Work

How LLMs Work is a locally run interactive application covering five stages of how language models are built, each with its own working code. It starts with an ELIZA-style pattern-matching chatbot streamed word by word, then a small neural network trained live on the XOR problem to show why backpropagation was needed, then a byte-pair-encoding tokenizer trained from scratch on the user's own text with an animated view of its merge steps.

The next stage trains word embeddings from scratch with Word2Vec skip-gram and negative sampling, and the last trains a full decoder-only transformer from scratch with no machine-learning libraries: multi-head causal self-attention, layer normalization, feed-forward layers, backpropagation and Adam optimization are all implemented by hand, using multi-threaded data parallelism.

It is built with Hono for the server and JSX rendering and Vite for bundling, in TypeScript, and runs locally with pnpm and Node.js 20 or later.

More in Tutorials

See all 478
  • BootLife

    github.com

    Conway's Game of Life implemented to run directly from a 512-byte x86 boot sector in assembly, using VGA memory itself as the simulation grid.

  • A technical blog post deriving the Y combinator as a composition of combinator birds in an array language, and examining how eager evaluation changes fixed-point recursion compared with the usual lazy telling.

  • System Design Atlas

    atlas-sysdes.vercel.app

    A free reference of worked system design problems with interactive architecture diagrams, covering ranked designs such as a feed, a chat app, a URL shortener, and a rate limiter, plus pages on the technologies behind them.