w3cj GitHub avatar

how-llms-work

w3cj

An interactive, step-by-step web app that demonstrates the entire LLM pipeline from pattern matching to training a transformer from scratch using locally-run code.

Stars

393

7-day growth

No data

Forks

105

Open issues

0

License

No data

Last updated

2026-07-21

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It builds every component from scratch—BPE tokenizer, Word2Vec embeddings, and a full decoder-only transformer—without relying on ML libraries, making the inner workings of LLMs transparent and learnable.

Who it is for

  • Developers curious about how LLMs work under the hood
  • Machine learning students seeking hands-on, code-based learning
  • Educators looking for interactive demos to illustrate NLP concepts
  • Hobbyists who want to experiment with training small models locally

Use cases

  • Learning the full lifecycle of an LLM through interactive demos
  • Teaching backpropagation, tokenization, and transformer mechanics
  • Prototyping small-scale models and visualizing training progress
  • Comparing ELIZA-style patterns with learned neural approaches

Strengths

  • Covers the complete pipeline from simple pattern matching to a full transformer
  • All core implementations are written from scratch with no black-box ML libraries
  • Interactive SSE streaming provides real-time visualization of training and tokenization
  • References seminal papers for each section, grounding the code in research

Considerations

  • Requires local setup with Node 20+ and pnpm, limiting instant browser-only use
  • Training runs on CPU only and may be slow for larger datasets or experiments
  • No pre-trained weights or deployment guidance—strictly educational and demonstrative

README quick start

How LLMs Work

An interactive app that walks through every stage of the LLM pipeline — from pattern matching to training a transformer from scratch — with working code you can run locally.

Stack

  • Hono — server, JSX rendering, and client components
  • Vite — dev server + bundling

Setup

Requires pnpm and Node.js 20+.

pnpm install
pnpm dev

If pnpm reports ignored build scripts, run:

pnpm approve-builds

Select esbuild with Space, press Enter, then rerun pnpm install.

Sections

1. Simple Chat — Pattern Matching

The simplest possible "AI": an ELIZA-style chatbot that responds with if-statements, streamed word by word via SSE. Same plumbing as ChatGPT, zero intelligence.

2. XOR Neural Net — Backpropagation

Trains a neural network live. A single-layer perceptron fails on XOR (proving Minsky/Papert right). A multi-layer network succeeds via backpropagation — the same algorithm every neural network uses today.

3. Basic Tokenizer — BPE From Scratch

A from-scratch BPE implementation that trains on your input text. Watch merge steps animate as the algorithm builds a vocabulary from characters to words.

Description

An interactive app that walks through every stage of the LLM pipeline, from pattern matching to training a transformer from scratch, with working code you can run locally.

Related repositories

Similar projects matched by category, topics, and programming language.

TanStack
Featured
TanStack GitHub avatar

router

TanStack Router is a type-safe, data-driven React router with built-in caching, prefetching, and nested layouts, while TanStack Start extends it into a full-stack SSR framework.

Web DevelopmentFrontend Frameworks
14,861
vercel-labs
Featured
vercel-labs GitHub avatar

scriptc

scriptc compiles ordinary TypeScript into small, fast native executables without needing Node.js, V8, or any JavaScript runtime in the binary.

Developer ToolsCode Quality & Build
1,985
Jakubantalik
Featured
Jakubantalik GitHub avatar

thinking-orbs

A React component library that renders six hand-tuned animated thought orb loading indicators on a plain 2D canvas, with two purpose-tuned sizes and automatic theme detection for AI and agent UIs.

AI & Machine LearningAI Agents
1,191