Quick answer: A transformer is the neural network architecture behind almost every modern large language model. Its defining trick is attention, a mechanism that lets the model weigh how much every word in the input relates to every other word when it decides what to do next. Introduced in 2017, the transformer model replaced older sequence approaches and made today's LLMs possible by being both powerful and highly parallel to train.
You do not need the math to understand a transformer well enough to reason about it. The core ideas are intuitive once you strip away the equations. Let us walk through what actually happens when text goes into a transformer, one stage at a time.
Step One: Tokens
A transformer does not read words the way you do. First it breaks the text into tokens, which are chunks that are often whole words but sometimes pieces of words. "Unhappiness" might become "un," "happi," and "ness." Common words are usually one token; rare words get split.
Why chunks instead of letters or whole words? Chunks are a compromise. Whole words make the vocabulary enormous and cannot handle words the model has never seen. Individual letters make sequences painfully long. Tokens sit in the middle, giving a manageable vocabulary that can still spell out anything.
Every token maps to an ID, so your sentence becomes a list of numbers. That list is what the model actually processes.
Step Two: Embeddings
Those token IDs are then turned into embeddings, which are lists of numbers that represent meaning. Each token becomes a vector, and tokens with related meanings get similar vectors. This is the same idea we cover in depth in what vector embeddings are.
At this stage the model also adds position information, because a raw bag of token vectors has no sense of order, and "dog bites man" means something very different from "man bites dog." The transformer encodes each token's position so that order is preserved. Now every token is represented by a vector that captures both what it is and where it sits in the sequence.
Step Three: Attention, the Main Event
Here is the idea that makes transformers special. Attention lets every token look at every other token and decide how relevant each one is to it right now.
Take the sentence "The trophy did not fit in the suitcase because it was too big." What does "it" refer to? A human knows "it" is the trophy, because a suitcase being too big makes no sense in context. Attention is how the model figures out the same thing. When the model processes "it," attention lets that token look back across the sentence and put most of its weight on "trophy."
Do this for every token against every other token and the model builds a rich map of how the whole input relates to itself. A word's representation gets updated based on the words that matter to it, not just the words next to it. That ability to connect distant, related parts of the text is what earlier architectures struggled with and what attention does naturally.
Models run several attention operations in parallel, often called multiple heads, so different heads can focus on different kinds of relationships at once: one might track grammar, another might track which noun a pronoun refers to. You do not manage this; it emerges from training.
Step Four: Layers, Stacked
One round of attention is not enough for language. So transformers stack the process into many layers, each one taking the previous layer's output and refining it further. Between attention steps, each layer also runs the token representations through a small feed-forward network that does additional processing.
| Concept | Plain-English meaning |
|---|---|
| Token | A chunk of text the model treats as one unit |
| Embedding | A vector of numbers standing in for meaning |
| Attention | Weighing how much each token relates to every other |
| Head | One attention operation focused on one kind of relationship |
| Layer | One full round of attention plus processing, stacked many deep |
Early layers tend to capture surface patterns like grammar. Deeper layers capture more abstract meaning. By the time text has passed through every layer, the model has built up a deep, context-aware understanding of the input. The "large" in large language model refers largely to how many of these layers and parameters are stacked up.
How It Produces Text
After the final layer, a transformer used for language does one deceptively simple thing: it predicts the next token. It outputs a probability for every token in its vocabulary and picks one, usually with a bit of controlled randomness so the output is not robotic.
Then it does it again. The token it just produced is appended to the input, and the whole sequence runs through the model to predict the following token. Generating a paragraph is this loop repeated hundreds of times, one token at a time. That is the entire generation process, and understanding it demystifies a lot of model behavior. For the bigger picture of how this becomes a useful system, see our overview of what an LLM is.
Why the Transformer Won
Older approaches processed text strictly in order, one word after another, which made them slow to train and prone to forgetting things from earlier in a long passage. The transformer changed two things at once.
- It handles the whole sequence in parallel. Because attention compares all tokens together rather than marching through them one by one, transformers train far more efficiently on modern hardware. That efficiency is what made training on internet-scale data practical.
- It connects distant words directly. A token at the end of a paragraph can attend to a token at the start in a single step, so long-range relationships survive. Earlier models lost that signal over distance.
Those two properties, parallel training and direct long-range connections, are why nearly every serious language model since 2017 is a transformer. The architecture scaled better than anything before it, and scaling turned out to matter enormously.
Honest Scope
A plain-English tour leaves things out, and it is worth being clear about what.
- The math is real and it is skipped here. Attention involves specific matrix operations and learned weight matrices. You do not need them to reason about behavior, but they are doing the actual work.
- Attention has a cost. Comparing every token to every other token gets expensive as the input grows, which is one reason context windows have practical limits. A lot of research goes into making this cheaper.
- Architectures keep evolving. The 2017 design has been tweaked heavily since. The core ideas above still hold, but production models include many refinements this overview does not touch.
- Understanding the mechanism is not understanding the model. Knowing how attention works does not fully explain why a given model gives a given answer. These systems remain hard to interpret even to the people who build them.
The Short Version
A transformer turns text into tokens, tokens into meaning-rich vectors, and then uses attention to let every token weigh its relationship to every other before predicting the next token, one at a time. Stacking that process into many layers builds deep contextual understanding, and doing it in parallel is what let these models train on enormous data. Attention connecting distant words is the whole reason transformers replaced everything before them and now power modern LLMs.
Building on top of LLMs and need real web data to feed them? link.sc fetches and searches the web in one clean API. Start free.