An interactive, step-by-step dry run of a GPT-style transformer. Every number on screen is computed live in the browser from the weights of a real (tiny) GPT-2-architecture model, and hovering any cell shows the exact arithmetic that produced it.
It has three chapters, listed at the top of the sidebar:
The model has 2 blocks, width 8, 2 attention heads, a 32-unit MLP and an 18-word vocabulary. It was trained on a toy corpus ("the cat sat on the mat .") to the optimal loss.
Requires Node.js 20.19+ or 22.12+.
npm install
npm run dev
Then open the URL Vite prints (usually http://localhost:5173). Use the arrow keys or the buttons at the bottom to step through; at the end of a chapter they carry on into the next one.
| Command | What it does |
|---|---|
npm test | Checks the TypeScript forward and backward passes and the reward model against the NumPy reference, that in-browser training converges, and the PPO gradients (by finite differences) and convergence |
npm run build | Type-checks and builds a static site into dist/ (serve it with npm run preview) |
npm run train | Retrains the model and rewrites src/model/tiny-gpt-weights.json (needs Python 3 with NumPy) |
npm run train-rm | Regenerates the labeler's comparisons, retrains the reward model, and rewrites src/model/reward-model-weights.json |
The site is hosted on Vercel at https://llm.manogya.dev. Every push to main deploys it, and every other branch gets a preview URL. The build runs npm test first (see vercel.json), so a failing test stops the deploy. To deploy from your machine instead, run npx vercel deploy --prod.
training/train-tiny-gpt.py: NumPy training script with a hand-written, gradient-checked backward pass.training/train-reward-model.py: the simulated labeler, its comparisons, and the Bradley–Terry reward model (same NumPy backward pass, starting from the final hidden state).src/model/: the instrumented forward and backward passes, sampling, the reward model, and the trained weights.src/training/: the in-browser pretraining trainer (initialisation, minibatches, Adam).src/post-training/: PPO (rollouts, rewards, GAE, clipped losses and their gradients, PPO-ptx, exact evaluation by enumerating responses) and the live PPO trainer.src/steps/step-defs.ts: the chapters (buildChapters) and the steps in each. A new chapter is an entry there, plus a component per step in STEP_COMPONENTS and optional top-bar controls in chapterBar (both in src/app.tsx).src/steps/: one component per step of the inference walkthrough; src/steps/training/ and src/steps/post-training/ for the other two chapters.src/components/: matrix heatmaps, charts, the calculation panel and layout pieces.An interactive, step-by-step dry run of a GPT-style transformer. Every number on screen is computed live in the browser from the weights of a real (tiny) GPT-2-architecture model, and hovering any cell shows the exact arithmetic that produced it.
It has three chapters, listed at the top of the sidebar:
The model has 2 blocks, width 8, 2 attention heads, a 32-unit MLP and an 18-word vocabulary. It was trained on a toy corpus ("the cat sat on the mat .") to the optimal loss.
Requires Node.js 20.19+ or 22.12+.
npm install
npm run dev
Then open the URL Vite prints (usually http://localhost:5173). Use the arrow keys or the buttons at the bottom to step through; at the end of a chapter they carry on into the next one.
| Command | What it does |
|---|---|
npm test | Checks the TypeScript forward and backward passes and the reward model against the NumPy reference, that in-browser training converges, and the PPO gradients (by finite differences) and convergence |
npm run build | Type-checks and builds a static site into dist/ (serve it with npm run preview) |
npm run train | Retrains the model and rewrites src/model/tiny-gpt-weights.json (needs Python 3 with NumPy) |
npm run train-rm | Regenerates the labeler's comparisons, retrains the reward model, and rewrites src/model/reward-model-weights.json |
The site is hosted on Vercel at https://llm.manogya.dev. Every push to main deploys it, and every other branch gets a preview URL. The build runs npm test first (see vercel.json), so a failing test stops the deploy. To deploy from your machine instead, run npx vercel deploy --prod.
training/train-tiny-gpt.py: NumPy training script with a hand-written, gradient-checked backward pass.training/train-reward-model.py: the simulated labeler, its comparisons, and the Bradley–Terry reward model (same NumPy backward pass, starting from the final hidden state).src/model/: the instrumented forward and backward passes, sampling, the reward model, and the trained weights.src/training/: the in-browser pretraining trainer (initialisation, minibatches, Adam).src/post-training/: PPO (rollouts, rewards, GAE, clipped losses and their gradients, PPO-ptx, exact evaluation by enumerating responses) and the live PPO trainer.src/steps/step-defs.ts: the chapters (buildChapters) and the steps in each. A new chapter is an entry there, plus a component per step in STEP_COMPONENTS and optional top-bar controls in chapterBar (both in src/app.tsx).src/steps/: one component per step of the inference walkthrough; src/steps/training/ and src/steps/post-training/ for the other two chapters.src/components/: matrix heatmaps, charts, the calculation panel and layout pieces.