Transformers Explained Visually
TL;DR Highlight
Run GPT-2 in your browser to see Transformer internals and temperature in action
Who Should Read
An LLM API developer who tunes temperature and top-p by gut feel and wants to see what they actually do
Core Mechanics
- Text generation is next-token prediction
- The model predicts the most probable next token, a word or part of a word.
- Its core idea is self-attention, which looks at the whole sequence and captures long-range links.
- Input goes through four embedding steps
- The steps are tokenization, token embedding, positional encoding, and summing them into the final embedding.
- GPT-2 has a 50,257-token vocabulary and 768-dimensional vectors per token.
- Attention works like a web search
- Query is the search text, Key is the page title, and Value is the page content.
- Query-Key dot products give scores, and a mask hides future tokens.
- Attention and MLP do different jobs
- Attention moves information between tokens.
- The MLP refines each token separately, expanding 768 to 3072 and back to 768.
- Temperature just divides the logits
Community Reactions
- Commenters flagged differences from modern models
- One commenter noted GPT-2's absolute positional encoding is no longer used.
- They argued such details shape what representations a model can learn, so it shouldn't stand in for modern models.
- Pushback on calling low temperature safe
- One commenter said safety is the wrong word in the temperature explanation.
- They said temperature 0 text lacks surprise and feels artificial.
- A view of attention as a dynamic layer
- One commenter said multiplying the attention matrix by Value acts like a Dense layer whose weights come from the attention matrix.
- So each head builds a small single-layer network at inference time from Key and Query.
- Reports of heavy performance cost
- One user said the page crashed their Chromebook.
- Another said the tab used 2.2 GB of RAM within 10 seconds and slowed their laptop.
How to Apply
- Compare temperatures on one prompt
- Today, enter a prompt in Transformer Explainer and set temperature to 0.2, 0.8, and 1.5 to watch the distribution change.
- Then vary top-k and top-p to see candidate tokens shrink.
- Pick sampling values per use case
- A/B test low temperature for extraction and classification calls and higher values for text generation.
- Don't assume low temperature is safe; check whether the output gets too flat.
- Add the visualization to onboarding
- Show the site to teammates new to LLMs to align on token, embedding, and attention terms.
- Tell them it is GPT-2 based and explain separately where modern models differ.
Try It
# Paste into Claude or ChatGPT (a simple experiment based on the article's concepts)
You are an LLM sampling explainer. Generate 3 answers to the same question under each setting below.
Question: {{question}}
Setting A: temperature 0.2 (sharp distribution, predictable output)
Setting B: temperature 0.8
Setting C: temperature 1.5 (flat distribution, more randomness)
Compare how similar the answers are within each setting. Then tell me which value suits my service ({{service description}}) and why.
Next step: repeat the comparison with top-p set to 0.5 and 0.95.Terminology
Related Papers
AI is a tool and using it well takes skill
A rebuttal to Hickey: LLMs are tools, and skill in directing and checking them decides the outcome
Reflective Prompt Optimization of a Deep-Research Agent: A Topic-Disjoint, Multi-Seed Protocol for Measuring Transferable Gains and Prompt-Level Overfitting
Reflective prompt optimization raised held-out citation reward from 0.702 to 0.781 on a deep-research agent.
GPT‑6 and Intelligent UI for everyone
GPT-6 reportedly adds generated UI to chat; with no article text, only comment reactions are available.
Base Models Can Reason By Taking a Cue From Training Data
Prefilling just two opening tokens lifted Olmo-3-7B's MATH-500 accuracy from 42% to 78%.
Labels Override Definitions in Jev-Style Typed Decision Models
Renaming options to A/B raised routing accuracy by +0.1511 over meaningful labels.
How Much Prompt Is Enough? A Blackbox Minimization of Few-Shots in LLMs
Delta debugging trimmed few-shot prompts by 65.3% on average with unchanged propositional output