Skip to content
Part 14 34 min read

Visual Learning Resources

ten interactive guides that show how AI works

Ten visual and interactive resources that let you see inside a language model, such as Transformer Explainer, LLM Visualization, and 3Blue1Brown. Each section shows what a resource displays, how to use it in a few minutes, and what to check.

Go to quiz
On this page

Section 1 of 10

Transformer Explainer: watch a model predict the next token

A live GPT-2 in your browser. See tokens, embeddings, attention, and sampling in the order they happen.

Live view · 1 page

  • Transformer Explainerpoloclub.github.ioOpen in a new tab ↗

    Pick an example or type a prompt, press Generate, and click a token to follow it through the model. The page downloads GPT-2 into your browser, so the first load can take a while.

    The page loads from its own site when you click. Works best on a wide screen.

Transformer Explainer is a free web page from the Polo Club of Data Science at Georgia Tech. It runs a live GPT-2 (small) model inside your browser. You type a prompt, and the page shows every stage that turns your text into a prediction for the next token.[2][1]

Open it: poloclub.github.io/transformer-explainer. No install and no account. The model runs on your own machine, so your text does not leave the browser.[1]

What the page shows

GPT-2 (small) has 124 million parameters. That is tiny next to a modern chat model, but its design is the same: a stack of transformer blocks that predicts one token at a time.[2][3]

StageWhat happensGPT-2 (small) numbers
TokenizeText is cut into tokens. Each token gets an integer id.Vocabulary of 50,257 tokens
EmbedEach id becomes a vector. A position vector is added, so the model knows the order.768 numbers for each token
AttentionEach token looks at the earlier tokens and takes in the useful ones. Several heads do this in parallel.12 heads in each block
MLPA small network refines each token on its own.Expands 768 to 3,072, then back
RepeatThe attention and MLP pair repeats. Each repeat is one transformer block.12 blocks
OutputThe last vector becomes one score for every token in the vocabulary. Softmax turns the scores into probabilities.50,257 probabilities
SampleOne token is picked from the probabilities. Temperature, top-k and top-p control this pick.One new token
One generation step. The loop runs once for every new token.Promptplain textTokensidsEmbed768 numbersBlocks12 × attn+MLPLogits50,257 scoresSoftmaxprobabilitiesSampletop-k / top-pappend the new token to the prompt, then run the whole stack again
The text-generation loop that Transformer Explainer animates. The model never writes a whole answer at once. It picks one token, appends it, and repeats.
Transformer Explainer যে টেক্সট-জেনারেশন লুপ দেখায়। মডেল একবারে পুরো উত্তর লেখে না। সে একটি টোকেন বাছে, প্রম্পটে জুড়ে দেয়, তারপর আবার চালায়।

Temperature, top-k and top-p, with numbers

The page has sliders for the three sampling settings. Each setting changes the pick from the probability list, not the model itself.

  • Temperature T: divide every score by T before softmax. A small T makes the top token even more likely. A large T flattens the list.
  • Top-k: keep only the k most likely tokens, then pick among them.
  • Top-p: keep the smallest group of tokens whose probabilities add up to at least p, then pick among them.
Same five scores, three temperatures. Prompt: “The cat sat on the”T = 0.5 sharpmat76%floor15%couch7%roof1%moon0%T = 1.0 normalmat53%floor24%couch16%roof6%moon1%T = 2.0 flatmat37%floor25%couch20%roof13%moon6%
Illustrative scores for five candidate tokens, pushed through softmax at three temperatures. The bars are computed with softmax(score / T). Real models have 50,257 candidates, not five.
পাঁচটি ক্যান্ডিডেট টোকেনের (উদাহরণমূলক) স্কোর তিনটি টেম্পারেচারে সফটম্যাক্সের মধ্য দিয়ে। বারগুলো softmax(score / T) দিয়ে হিসাব করা। আসল মডেলে পাঁচটির জায়গায় ৫০,২৫৭টি ক্যান্ডিডেট থাকে।

At T = 0.5 the top token “mat” takes about 76% of the probability. At T = 2.0 it takes about 37%, and the unlikely word “moon” grows from under 0.1% to 6%. This is why a high temperature gives more creative text and also more mistakes.

A 10-minute path through the page

  1. Pick an example prompt, or type The cat sat on the. Press Generate.
  2. Click a token. Watch the page zoom from the embedding to the attention stage.
  3. Open the attention view. Hover over a token and see which earlier tokens it reads.
  4. Set temperature to 0.2, generate three times, then set it to 1.5 and generate three times. Compare the answers.
  5. Set top-k to 1. The output is now the same every time. This is greedy decoding.

Know the limit. GPT-2 (small) is from 2019. It shows the shape of a transformer, not the quality of a modern model. Newer models change parts of the design, such as how attention heads share keys and values (see section 6) and how the MLP is split into experts (see section 7).

Practice · 1 task

Open any free AI chat: ChatGPT · Claude · Gemini

How practice works
  • A new chat is a fresh conversation with no history. In ChatGPT, Claude, or Gemini, click New chat. It is usually at the top left.
  • Same chat means: keep typing in the chat that is already open. The AI remembers what you sent before.
  • To use a prompt: click Copy, click in the message box of the chat, paste it (Ctrl+V, or press and hold on a phone), and press Enter.
  • AI answers are a little different every time. Your answer does not need to match the example word for word. Look for the same idea.
  • Use made-up data only. Do not paste private information into a chat.

Task 1

Predict the next word, then check it in the explainer

Why this matters

A language model only ever answers one question: what token comes next? You will see the answer as a list of chances, not as one word.

  1. Step 1
    New chat

    Copy this prompt, paste it in an AI chat, and press Enter. It asks for a list of chances.

    Prompt
    Finish this sentence. Do not write the sentence again.
    
    The cat sat on the
    
    Give me the 5 most likely next words. For each word, give your best guess of its percentage chance. The five percentages must add up to about 100%. Show a small table only.

    You should see: A list of five words with percentages. The percentages add up to about 100%. One word is clearly the top choice.

    Example answer
    | Word | Chance |
    |---|---|
    | mat | 45% |
    | floor | 20% |
    | couch | 15% |
    | bed | 12% |
    | roof | 8% |

    Your answer will be worded differently.

  2. Step 2
    Same chat

    Open Transformer Explainer. Type The cat sat on the and press Generate. Look at the list of next-token probabilities.

    You should see: A list of candidate tokens with real probabilities from GPT-2. The top words are common places or objects, such as a floor, a bed, or a couch. They may differ from the chat answer. That is fine.

  3. Step 3
    Same chat

    In the explainer, move the temperature slider to 0.2, then to 2.0. Generate each time. In the chat, ask: Why does a high temperature give stranger words?

    You should see: At 0.2 the top word wins almost every time. At 2.0 rare words appear. The chat answer says that a high temperature flattens the probabilities.

What just happened

A model produces a list of chances for every token. A sampling setting then picks one. Temperature changes how flat the list is.

You are done when You saw the same idea in two places: an estimate from a chat model and the real numbers from GPT-2.

Check yourselfYou set top-k to 1. Will the output change if you generate twice?Show answer

No. With top-k = 1 the model always picks the single most likely token. This is greedy decoding, so the output is the same each time.

Try a harder version

Pick a prompt where you think two words are almost equally likely. Check the explainer to see if you were right.

Watch · 3 videos