What Is a Transformer? The Architecture Behind Every Modern AI Model

Photo: Hippopx (public domain). Illustrative image.
What is a transformer?
A transformer is a type of neural network architecture, introduced in 2017, that sits underneath virtually every modern AI model: GPT, Claude, Gemini, and every large language model you have used are transformers. It is not a product and not a chatbot — it is the design that makes the chatbot possible. The paper that introduced it, “Attention Is All You Need” by Vaswani and colleagues at Google, has been cited more than 150,000 times, making it one of the most influential papers in the history of computing.
The idea that gives the transformer its name is attention — specifically self-attention. When a transformer reads a sentence, every word looks at every other word in the passage and assigns each one a weight: how much does this word matter for understanding that word? In “the animal didn’t cross the street because it was too tired”, attention is what lets the model work out that “it” refers to the animal, not the street. The model does this for every word, in every layer, dozens of times over — and the pattern of weights is what we mean, loosely, when we say the model “understands” the text.
Why did it replace what came before?
Before transformers, the standard design for language was the recurrent neural network — RNNs, and their longer-memory cousins, LSTMs. These read text one word at a time, in order, carrying a summary forward. That made them slow to train (you cannot parallelise a sequence) and forgetful over long passages (the summary gets diluted with every step). Transformers removed the sequence entirely: because every word attends to every other word at once, the whole passage can be processed in parallel, which is exactly what GPUs are good at. Training that once took months could be done in days, and models could scale from millions of parameters to hundreds of billions. The mixture-of-experts designs in today’s biggest models are still transformers underneath — the attention machinery is the same.
What does a transformer look like?
The original design has two halves. The encoder reads the input and builds a rich representation of it; the decoder generates the output one piece at a time, attending both to what it has already written and to the encoder’s representation. Modern language models mostly use the decoder half alone: they predict the next word, then feed it back in and predict the next, which is how a chatbot writes its reply. Around the attention layers sit feed-forward networks that process each position, and the whole stack repeats — 12 layers in the original paper, 96 or more in today’s frontier models. The cost of attention grows with the square of the passage length, which is one reason a context window has a limit at all: double the passage, quadruple the attention work.
Frequently asked questions
Is a transformer the same as an LLM? No. A transformer is an architecture; an LLM is a model built with that architecture and trained on vast amounts of text. Every LLM is a transformer, but not every transformer is an LLM — transformers also power image, audio and video models.
What is attention in simple terms? It is a weighting: for each word, the model decides how much attention to pay to every other word when working out what it means. “It” in the sentence above pays most attention to “animal”. Attention is learned from data, not programmed in.
Who invented the transformer? A team at Google led by Ashish Vaswani, in the 2017 paper “Attention Is All You Need”. The eight authors — Vaswani, Shazeer, Parmar, Uszkoreit, Jones, Gomez, Kaiser and Polosukhin — were all at Google Research or Google Brain at the time.
Why does the transformer matter for ChatGPT? Without it, there is no ChatGPT. The parallel training that transformers allow is what made it possible to train models on trillions of words, and scale is what turned a research curiosity into a useful assistant.
Sources
- Vaswani et al. — “Attention Is All You Need” (2017), arXiv:1706.03762: https://arxiv.org/abs/1706.03762
- FreshSynapse — “What Are Large Language Models?”: https://freshsynapse.com/articles/what-are-large-language-models/
- FreshSynapse — “What Is a Mixture of Experts?”: https://freshsynapse.com/articles/what-is-a-mixture-of-experts/
- FreshSynapse — “What Is a Context Window?”: https://freshsynapse.com/articles/what-is-a-context-window/