AI Lab
Transformers you can touch
Nine experiments, from token to agent. 1–5 run instantly on a mini transformer written in JavaScript. 6 and 7 load real models on click and compute entirely in your browser – your input never leaves your device. 8 and 9 show how agents work with sub-agents, skills, MCP and their context.
Mini model · instant
1 · Tokenizer
Language models don't read letters, they read tokens. Type something and watch the text being chopped up.
The simplified tokenizer splits words and detaches common endings. GPT-2's real byte-pair encoding tokenizer has learned 50,257 tokens – rare words fall apart into several pieces. The “Ġ” marks a space in front of the token.
Mini model · instant
2 · The space of meaning
Embeddings are coordinates for meaning. Here every word has 11 dimensions (royal, male, female, young, animal, food, tech, place, city, Germany, France) – projected to 2D with MDS.
Real models use anywhere from 384 to more than 4,000 dimensions that nobody named in advance – the model learns them itself. The principle stays the same: closeness in space = similarity in meaning.
Mini model · instant
3 · Self-attention
Hover over a word (or tap it). The arcs show how strongly it attends to the words before it.
Every token produces three vectors: a query (what am I looking for?), a key (what do I stand for?) and a value (what do I pass on?). The attention weights are softmax(Q·Kᵀ/√d) – exactly the formula from the Nerd Corner.
Mini model · instant
4 · Temperature & sampling
At the end the model has a score (logit) for every possible next token. Softmax turns those into probabilities – and the sampling dials decide what gets picked.
Temperature below 1 makes the distribution peakier (predictable), above 1 flatter (creative, but also more nonsensical). Top-k keeps only the k best candidates, top-p the smallest set whose probabilities add up to p.
Mini model · instant
5 · The whole transformer, step by step
A complete mini transformer: 8 dimensions, 3 attention heads, 1 block. Small enough to see every single number.
Real model · on click
6 · Real embeddings & semantic search
Now with a real sentence transformer: every sentence becomes a 384-dimensional vector. Similar meaning, similar direction – even without shared words.
This is how retrieval in RAG works: documents are embedded once, the question too – and the highest cosine similarity wins. The very same technique powers semantic search across handwritten notes.
Real model · on click
7 · Real GPT-2: next-token prediction
DistilGPT-2 (82 M parameters) runs in your browser. You see the real probabilities for the next token – and can pick one yourself or let it sample.
At every step the model computes 50,257 logits. Temperature, top-k and top-p are applied live to those real logits – without re-running the model.
Simulation · instant
8 · Agent run: sub-agents, skill, MCP & memory
One question, one orchestrator, two sub-agents, one skill and three MCP servers – including a knowledge graph as long-term memory. Play it or step through it.
Watch for two things: the sub-agents burn lots of tokens in their own context but return only a short distillate. And the skill only enters the context once it's needed. Both keep the orchestrator's context small.
Simulation · instant
9 · Building the context window
This is what a request to the model really looks like – block by block. Switch parts on and off, change the window size and see what happens when it no longer fits.
Order and sizes are typical example values. Real agent frameworks put the system prompt, agent configuration, skill index and tool definitions up front as a stable prefix – which can be reused via prompt caching. Everything dynamic follows behind it.