Tokens & Attention

The input text is split into tokens. Click any token to see what it attends to.

Next-token prediction

After attention, the model scores every possible next token. The highest scores become the prediction.

What you are seeing

This is a simplified, local demonstration of the three core stages of a transformer language model. No data leaves your browser and no real neural network is running — the attention weights and predictions are computed from a small hand-built rule set so you can see the mechanics clearly.

1. Tokenization

The sentence is split into word-level tokens. Real models use subword tokenizers like BPE or WordPiece, which split rare words into pieces. Here we split on whitespace and punctuation for clarity.

2. Embeddings

Each token is mapped to a vector of numbers. In a real model these vectors are learned during training. Here we assign a small deterministic vector based on the token's characters so you can see that different tokens get different representations.

3. Self-attention

Attention lets each token look at every other token and decide how much to "pay attention" to it. The heatmap shows, for the selected token (row), how much weight it places on each token (column). Darker cells mean higher attention. Real transformers use multiple heads and many layers; this shows a single simplified head.

4. Next-token prediction

The final hidden state is projected onto the vocabulary to produce a score for every possible next token. A softmax turns those scores into probabilities. The bars show the top candidates. This demo uses a small hand-written scoring rule, not a trained model.

Privacy & limitations

Everything runs locally in your browser. Nothing is uploaded. The attention and prediction values are illustrative, not the output of a trained transformer. They are designed to make the mechanism visible, not to generate accurate text.

Enjoy this tool? Build your own with Super