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.

🧪Interaktive Demo · Interactive demo: tokenizer

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.

🧪Interaktive Demo · Interactive demo: embedding-space

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.

🧪Interaktive Demo · Interactive demo: attention

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.

🧪Interaktive Demo · Interactive demo: softmax

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.

🧪Interaktive Demo · Interactive demo: pipeline

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.

🧪Interaktive Demo · Interactive demo: next-token

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.

🧪Interaktive Demo · Interactive demo: agent-flow

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.

🧪Interaktive Demo · Interactive demo: context-window

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.