Transformer Explainer begins with a practical question: how can a text model generate one token while still taking earlier tokens into account? The answer is not that it squeezes an entire conversation into a single fixed summary. In the decoder-only GPT-style architecture shown on the page, each token maintains a representation, and layers repeatedly exchange and transform information across those representations before the model predicts the next token.

The first stage converts the prompt into numbers the network can process. A tokenizer splits text into words or subwords; each token receives an embedding vector, and a positional encoding adds information about its place in the sequence. For the GPT-2 small model used by the explainer, the page describes a vocabulary of 50,257 tokens, 768-dimensional token vectors, and 12 stacked Transformer blocks. Those are properties of this teaching model, not constants shared by all modern language models.

Diagram illustrating how text is converted into token embeddings
Embedding diagram from Transformer Explainer, the project's source page.poloclub.github.io

Placed after the explanation of tokenization, embedding vectors, positional encoding, and the GPT-2 model dimensions.

Within each block, multi-head self-attention lets a token’s representation incorporate information from other tokens. The model derives query, key, and value vectors using learned weights. Query-key comparisons produce attention scores; a causal mask prevents a decoder from using future tokens when predicting the current next token; softmax turns the scaled scores into weights; and a weighted combination of value vectors is passed onward. Multiple heads divide the vectors into subspaces that can learn different relationships, although the page’s web-search analogy should not be mistaken for a literal account of what any particular head represents.

Diagram illustrating multi-head self-attention within a Transformer
Attention diagram from Transformer Explainer, the project's source page.poloclub.github.io

Placed after the explanation of query, key, and value vectors, causal masking, attention weights, and multiple attention heads.

Attention is only half of the standard block described by the explainer. Its output passes through a multilayer perceptron, or MLP, which applies learned transformations to each token representation independently. The GPT-2 example expands each 768-dimensional representation to 3,072 dimensions, applies a GELU nonlinearity, and projects it back to 768 dimensions. Alternating attention and MLP operations matter: information gathered from other positions can be transformed locally, then made available to later attention layers. This repeated mixing is why a flat-looking vector at one point does not imply that the model permanently discarded the rest of the context.

After the final block, a linear layer produces one logit for every vocabulary token, and softmax converts those logits into a probability distribution. Sampling selects the next token, after which it is appended to the sequence and the process continues. Temperature changes the sharpness of that distribution, while top-k and top-p sampling restrict the candidate set. These controls affect predictability and diversity; they do not by themselves establish that an output is safe, truthful, or creative.

A useful boundary is architectural rather than cosmetic. Hugging Face’s technical documentation distinguishes the original encoder-decoder Transformer from encoder-only models such as BERT and decoder-only models such as GPT-2. It also explains that audio Transformers often add an input adapter: a convolutional feature encoder can turn a waveform or spectrogram into embedding sequences before the Transformer processes them. That supports the broader point that “Transformer” names a reusable architectural family whose inputs, masking, and output heads vary by task. It does not show that every audio or language system uses the exact GPT-2 pipeline visualized by the demo.

The interactive page’s repository identifies the software as a browser-based learning tool running a live GPT-2 model and links it to a 2026 CHI paper. The repository therefore corroborates the project’s implementation and authorship, but it is not independent evidence that the visualization is the clearest possible explanation or that its analogies are universally valid. Likewise, the explainer’s statements about what attention does are descriptions of the demonstrated architecture, not experimental proof about the internal concepts learned by every Transformer head.

For readers trying to understand a language model, the most productive mental model is a sequence of contextual transformations, not a search over a compressed paragraph. Attention determines how representations are combined at a given layer; the MLP transforms them; residual connections and normalization help the stacked computation train; and the output layer turns the final representations into next-token probabilities. The exact roles learned by individual weights or heads remain model- and task-dependent, so the visualization explains the computation without fully explaining why a particular model produces a particular answer.