# 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.

- URL: https://www.deepblue-ai.cloud/en/ai-lab/
- Also available: [de](https://www.deepblue-ai.cloud/de/ki-labor/index.html.md)

## 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.

https://www.deepblue-ai.cloud/en/ai-lab/#lab-tokenizer

## 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.**

https://www.deepblue-ai.cloud/en/ai-lab/#lab-embedding-space

## 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.

https://www.deepblue-ai.cloud/en/ai-lab/#lab-attention

## 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.

https://www.deepblue-ai.cloud/en/ai-lab/#lab-softmax

## 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.

https://www.deepblue-ai.cloud/en/ai-lab/#lab-pipeline

## 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.

https://www.deepblue-ai.cloud/en/ai-lab/#lab-semantic-search

## 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.

https://www.deepblue-ai.cloud/en/ai-lab/#lab-next-token

## 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.

**Is Project Atlas still worth it? Compare my notes with the current market and give me a recommendation with numbers.**

Steps:

1. **Question** – You ask: “Is Project Atlas still worth it? Compare my notes with the current market and give me a recommendation with numbers.” The question is appended to the context.
2. **Plan** – The orchestrator reads its context – including a memory from earlier conversations (“Markus likes tables”) – and breaks the task down: ① internal knowledge, ② market data, ③ analysis.
3. **Delegate** – A job for the **researcher** sub-agent: “Find everything about Project Atlas.” It starts with its **own, fresh context** – just its prompt, the task and its tools.
4. **MCP · tools/call** – The researcher queries the knowledge graph through its MCP server: entities, relationships and notes around Project Atlas.
5. **Result** – Back come 14 entities and 6 notes – decisions, people, linked technologies. All of it lands in the **researcher's** context, not in the main context.
6. **MCP · tools/call** – A second MCP server connects an **existing system**: from the CRM the researcher fetches the customer requests about the project.
7. **Distillate** – The researcher summarises and returns only **~900 tokens** – instead of 19,000. Its working context is thrown away.
8. **Delegate** – The **web scout** gets the second job: “Current market figures for digital note-taking apps and pens, with sources.” (In practice often in parallel with the researcher.)
9. **Web search** – The web scout searches, opens pages, discards what's useless – in its own context.
10. **Distillate** – Back come five key figures with sources (~1,200 tokens).
11. **Load skill** – For the analysis the orchestrator loads the **data analysis** skill. Until now it only knew its name and description – now the full SKILL.md enters the context (*progressive disclosure*).
12. **Analyse** – The orchestrator follows the instructions: normalises the numbers, builds the comparison table, checks for contradictions between notes and market.
13. **Answer** – You get a table, three key figures and a clear recommendation – with sources.
14. **MCP · memory** – Finally the agent writes **lessons learned** into the knowledge graph: “Markus wants numbers as a table”, “market source X was current and reliable”. Next time they'll already be in the context.

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.

https://www.deepblue-ai.cloud/en/ai-lab/#lab-agent-flow

## 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.

Parts:

- **System prompt** (~1500 tokens): Ground rules from the operator: role, tone, safety rules, today's date. Always comes first.
- **Agent configuration & sub-agents** (~2200 tokens): How the agent should work – and which sub-agents exist. For each sub-agent only name, purpose and allowed tools appear here; its own prompt lives in its own context.
- **Skill index** (~400 tokens): For every installed skill only name + description (~50–100 tokens each). That way the agent knows what it could do – without loading everything.
- **Tool definitions (incl. MCP servers)** (~3000 tokens): JSON schemas of all tools. Every connected MCP server brings its tools along – many servers mean many tokens before any work is done.
- **Memories from the knowledge graph** (~600 tokens): Facts from long-term memory that match the request – for example lessons learned from earlier conversations.
- **Conversation history** (~700/turn tokens): Every previous message in this session – questions, answers, tool calls and their results. Grows with every turn.
- **Current question** (~80 tokens): The user's new message.
- **Loaded skill (SKILL.md)** (~2400 tokens): Only when the agent decides it needs the skill does it read the full instructions – typically as the result of a tool call. Further files of the skill (scripts, templates) follow only when needed.
- **Retrieval results (KG + web)** (~2100 tokens): What the researcher and the web scout found. With sub-agents only the distillate arrives; without them all raw data lands in the main context.
- **Reserved for the answer** (~2000 tokens): The answer has to fit into the window too: input + output must not exceed the context limit.

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.

https://www.deepblue-ai.cloud/en/ai-lab/#lab-context-window
