How Transformers Actually Work: The Visual Explainer

Every AI model you have read about on this site, GPT-6, Claude, Gemini, Muse, is the same machine underneath. It is called the transformer, it was invented in 2017, and almost nobody outside the field can explain how it works. This is the plain-language guide: no math, no jargon, original diagrams. By the end, you will understand the most important invention of the AI age.

Original ByteHerald diagram showing the transformer pipeline in six plain-language steps: words in, words become numbers, position tags, attention, the repeated thinking block, and next-word prediction
Original diagram: the transformer in six plain-language steps. The jargon version of each step lives in the article. Diagram by ByteHerald.

Step 1, Words become numbers

The model cannot read. It can only do arithmetic. So the first thing that happens to your sentence is translation: every word becomes a long list of numbers, hundreds or thousands of them. That list is the word's address in meaning-space: "cat" gets numbers close to "dog" and far from "carburetor, " because the model learned which words show up in similar contexts. Words that mean similar things end up with similar numbers. The jargon for this is an embedding, but the idea is simple: meaning, encoded as arithmetic.

Step 2, Every word gets a position tag

Number-lists alone lose something critical: order. "Dog bites man" and "man bites dog" use identical words and mean opposite things. So each word also gets a small extra set of numbers recording where it sits in the sentence, first, second, third. The jargon is positional encoding. The plain version: the model never forgets the sequence, even though it looks at all the words at once.

Step 3, Attention: each word looks at the others

This is the core trick, the reason the 2017 paper was titled "Attention Is All You Need." When the model processes a word, it doesn't just look at that word. It looks at every other word and decides how much each one matters. Consider:

"The animal didn't cross the street because it was too tired."

What does "it" refer to, the animal or the street? You know instantly. The model figures it out the same way: by checking. When it processes "it, " it shines a spotlight across the sentence, and the spotlight lands hardest on "animal":

Illustrative attention heatmap showing that when the model processes the word 'it' in a sentence about an animal and a street, it attends most strongly to 'animal'
Illustrative attention pattern: resolving "it" means checking every word and weighting what matters. Real models do this with many attention "heads" at once, many spotlights, not one. Diagram by ByteHerald.

Now multiply that. A real model doesn't use one spotlight, it uses dozens or hundreds simultaneously, each checking a different kind of relationship: grammar, meaning, tone, reference. The jargon is attention heads (and the mechanism is self-attention). The plain version: every word interviews every other word, many times, in parallel, and the interviews are where understanding happens.

Step 4, The thinking block, repeated dozens of times

Attention is half of one "thinking block." The other half is a plain feed-forward network, a pattern-matcher that transforms what attention found into something richer. Stack that block 30, 60, 100 times, and each layer refines the last: early layers catch grammar, middle layers catch meaning, deep layers catch reasoning. Depth is where the smarts live. The jargon: transformer layers (or blocks). The plain version: the same two-step dance, repeated until the representation is deep enough to be smart.

Then it predicts, one word at a time

After all those layers, the model does exactly one thing: it outputs a probability for every word it knows, which word is most likely to come next. It picks one (usually the most likely, sometimes a surprise for variety), appends it to the sentence, and runs the whole machine again for the following word. That is all "generation" is: prediction, one word at a time, at superhuman speed.

This also explains the most misunderstood behavior in AI. The model is predicting what sounds plausible, not checking what is true. When it "hallucinates, " it isn't lying, it is doing exactly what it was built to do, fluently continuing a pattern. Truth was never the objective function; likelihood was.

Why scale changed everything

Here is the remarkable part: the shape above hasn't fundamentally changed since 2017. What changed is size. The original transformer had 65 million parameters (the adjustable numbers the model learns during training). Today's frontier models have hundreds of billions. Same machine, enormously more capacity, and somewhere along the way, quantity became quality: bigger models don't just know more, they reason better. Nobody fully understands why scale unlocks new abilities; it just does, reliably. That mystery is the entire AI industry. (We did the math on what 100 billion parameters actually costs in memory, the numbers are physical, not abstract. To see how far that scaling now reaches on ordinary hardware, see how a 284B model runs on 64GB of RAM at about 9 tokens a second.)

The five terms worth knowing

If you hear…It means…
EmbeddingA word translated into a list of numbers that captures its meaning.
Attention / attention headsEach word checking every other word to decide what matters, many spotlights at once.
ParametersThe adjustable numbers the model learns during training. More parameters, more capacity.
Training vs inferenceTraining is the expensive one-time learning phase; inference is the cheap everyday act of using the model.
Context windowHow much text the model can "look at" at once, its working memory.

ByteHerald's reading

The transformer is the most important invention of the AI age that almost nobody outside the field can explain, which is exactly why it belongs on a magazine trying to be the field's authority. Everything else is commentary: every frontier model on our 2024–2026 timeline, every benchmark, every price war is this shape, scaled up. Understand the six steps above and you understand, at the level that matters, how the entire industry works.

By ByteHerald Staff. The transformer architecture is from Vaswani et al., "Attention Is All You Need" (2017). Diagrams are original ByteHerald illustrations; the attention heatmap is an illustrative pattern, not measured model weights. This is a research explainer.

BH
Written by