A transformer model is a neural network design that reads a whole sequence at once and lets every piece of it look at every other piece, using a mechanism called self-attention. Google researchers introduced it in 2017 for translation, and the same design now sits underneath most large language models. This guide covers what a transformer does, how attention works, why it replaced earlier designs and where it is still being reworked.
The problem it solved
Before transformers, language models were mostly recurrent neural networks, or RNNs. An RNN reads text one word at a time and carries a running summary forward. Google’s 2017 announcement explains the catch with an example. To work out that “bank” in “I arrived at the bank after crossing the river” means a riverbank, an RNN has to step through every word between “bank” and “river.” The more steps a decision needs, the harder it is for the network to learn it.
Reading one word at a time also fits poorly with modern chips. Google notes that GPUs and TPUs are good at parallel work, and a recurrent network is sequential by design. The original paper, “Attention Is All You Need”, states the same limit: sequential computation prevents parallelizing within a training example, which gets worse as sequences grow longer.
How self-attention works
A transformer drops the step-by-step reading. For each word, it compares that word with every other word in the sentence and produces an attention score for each pair. Those scores set how much each other word contributes to the word’s next representation. In Google’s example, “river” can receive a high score when the network computes a new representation for “bank,” so the model settles the meaning in a single step.
The paper describes the mechanism with three kinds of vectors: queries, keys and values. A query is compared against the keys to get weights, and the output is a weighted sum of the values. The arithmetic is mostly matrix multiplication, which suits GPUs.
One round of attention is not enough, so the original model ran eight in parallel. The authors call this multi-head attention and say it lets the model look at information from different positions and representation subspaces at once, which a single head would average away.
What else is inside
Attention is one of two main parts of each layer. The other is a small feed-forward network applied to each position separately. The original model stacked six identical layers in its encoder and six in its decoder, with a residual connection and layer normalization around each part.
Because nothing in the design reads words in order, the model needs another way to know position. The paper adds positional encodings, values built from sine and cosine functions, to each word’s embedding. The original was a translation model with two halves: an encoder that reads the input sentence and a decoder that writes the output one token at a time. The decoder is masked so that a position can only look at earlier outputs, never later ones.
How it compared in 2017
The authors reported a score of 28.4 BLEU on the WMT 2014 English-to-German translation task, more than 2 points above the best earlier results, ensembles included. BLEU is a standard translation-quality score where higher is better. On English-to-French, the model reached 41.8 BLEU after 3.5 days of training on eight GPUs, which the paper calls a small fraction of the cost of the best earlier models. The smaller base model trained in about 12 hours on eight P100 GPUs.
Why long inputs cost more
Comparing every word with every other word is the strength of attention and also its price. The paper’s complexity table shows self-attention growing with the square of the sequence length, while a recurrent layer grows linearly. For typical sentences that was fine, and the authors noted that restricting attention to a neighborhood could help for very long sequences. Today’s long inputs make the cost a live issue, which is part of why a context window is limited by memory and compute, not only by training.
A design still being reworked
The transformer is a starting point, not a fixed recipe. Two model releases from December 4, 2026 show how far builders now depart from the original. MiniMax says all 68 attention layers of its new M4 model use a sparse attention mechanism that cuts per-token KV cache needs fourfold versus its previous version (MiniMax). Hugging Face describes Alibaba’s Qwen4-35B-A3B as repeating a four-layer pattern in which three layers use a fixed-size memory called Gated DeltaNet and only the fourth uses sparse attention (Hugging Face). On the same day, Fujitsu said it has a method for converting existing transformer-based open-weight models to a different architecture and measured about 10 times higher throughput on documents of roughly one million tokens, in its own tests (Fujitsu). These are company claims, but they point the same way: the core idea of attention stays, while how much of it a model uses keeps changing.
What it means for the AI you use
When a chatbot answers, it is running this kind of network over your text and its own reply so far. A large language model is a transformer-style network trained at far larger scale. A reasoning model spends extra steps before it answers. Neither is a different species of network; they are the same attention-based design used in different ways.





