ELI Ladder

What is a transformer in AI?

A transformer is the neural network design behind modern chatbots. It lets every word look at every other word to work out what it means in context.

Self-attention: “bank” looks at every word I sat by the bank of the river × N attend feed- forward repeat Thicker line = more attention. Every word does this at once, in every layer. Weights are illustrative

Rung 1 Explain like I'm 6

Picture a class reading the sentence "I sat by the bank of the river." The word "bank" is confused: is it a money bank or the side of a river? So "bank" raises its hand and looks around the room at all the other words. It spots "river" waving back, and now it knows. In a transformer, every word does this at the same time, looking at all the others to decide what it means. Then they do it again and again, getting a little smarter each round.

Rung 2 High-school level

In AI, a transformer is a design for a neural network, introduced in the 2017 paper "Attention Is All You Need" [1]. (It has nothing to do with the electrical transformer from physics class, which changes voltage.) The "T" in ChatGPT stands for transformer.

Its key idea is self-attention. Text is first split into tokens, and each token becomes a list of numbers. In every layer, each token compares itself with every other token, decides which ones matter most, and mixes in information from them. That is how "bank" learns it is next to "river".

Older language networks, called recurrent networks, read one word at a time, which is slow to train. A transformer looks at all the tokens in a passage together, so the work can be spread across thousands of GPU cores at once. That speed is a big reason why models could grow so large. Transformers are now used for text, images, speech and protein structures.

Rung 3 Undergraduate level

A transformer is a stack of identical blocks. Each block has two parts:

  1. Multi-head self-attention: tokens exchange information.
  2. Feed-forward network: each token is processed on its own by a small neural network.

Each part adds its output back onto its input (a residual connection) and uses layer normalisation to keep numbers stable. Because attention ignores word order, position information is added, today usually by rotating vectors by an amount set by position (RoPE).

Attention itself: each token's vector is multiplied by three learned matrices to make a query (what am I looking for?), a key (what do I offer?) and a value (what do I pass on?).

Attention(Q, K, V) = softmax(Q Kᵀ / √d_k) V

Toy example: in "the bank of the river", the query for "bank" is compared with each key. If its dot product with "river" is the largest, softmax might give "river" a weight of 0.6, and "bank" receives mostly the value vector of "river". Several heads do this in parallel, each free to learn a different kind of relation.

The 2017 model was an encoder-decoder for translation [1]. BERT kept only the encoder, for understanding text. GPT-style LLMs keep only the decoder, with a mask so each token sees only earlier tokens, which is what lets them generate text one token at a time.

Check yourself: Why does a transformer need position information added?

Attention treats the tokens as a set, so without it "dog bites man" and "man bites dog" would look the same.

Rung 4 Graduate level

The 2017 transformer reached 28.4 BLEU on WMT 2014 English-to-German, over 2 points above the best earlier results, and trained its English-to-French model in about 3.5 days on eight GPUs [1]. The base model had 6 encoder and 6 decoder layers, 512-dimensional vectors and 8 attention heads [1].

The central trade-off is cost against context length. Attention compares every token with every other, so compute grows with the square of sequence length. During generation, models keep each past token's keys and values in a KV cache, whose memory grows in step with context and often limits how many users one GPU can serve. Design choices that address this include grouped-query attention (sharing keys and values across heads), memory-aware attention kernels such as FlashAttention (2022), and sparse or linear attention.

The second trade-off is total parameters against compute per token. Mixture of experts replaces each feed-forward block with many expert networks and a router that sends each token to a few. DeepSeek-V3 (December 2024) has 671B parameters but activates 37B per token, and was trained on 14.8T tokens using 2.788M H800 GPU hours [2]. The cost is more total memory and harder load balancing across experts.

Position encoding matters for long contexts. Llama 4 (2025) interleaves attention layers that have no positional embeddings with RoPE layers, and scales attention temperature at inference, to help it generalise to longer inputs [3].

Rung 5 PhD level

Theory has asked what a fixed-depth transformer can compute. With a bounded number of layers and no extra output steps, it cannot solve some problems that need many sequential steps. Letting it write intermediate tokens (chain of thought) provably adds power (Merrill and Sabharwal, 2024). This gives one formal reason why "thinking out loud" helps.

Mechanistic interpretability has found concrete circuits. Induction heads (Olsson et al., 2022) copy patterns from earlier in the context and appear tied to in-context learning. Whether such circuits explain larger behaviours, or only small pieces, is open.

Attention's quadratic cost drives the search for alternatives. State-space models such as Mamba (2023) and linear-attention variants run in time linear in length and keep a fixed-size memory. Their known weakness is exact recall: a fixed-size state cannot store every detail of a long input, while full attention can look back at any token. Most current designs therefore mix the two rather than replace attention.

Open problems:

  • Length generalisation: models often fail on inputs longer than those seen in training.
  • Using long context: a model may accept a long input yet ignore much of it.
  • Inductive bias: transformers need huge data partly because they assume so little about structure.
  • Efficiency vs recall: how much full attention a model needs, and where.

Rung 6 State of the art: what experts work on now

Last checked 18 November 2026.

The 2025 trend was hybrids: keep a little full attention and replace the rest with something cheaper.

Linear-attention hybrids. Qwen3-Next-80B-A3B (2025) has 48 layers in a 3:1 pattern of Gated DeltaNet (a linear-attention layer) to gated full attention, with mixture of experts in every layer: 80B parameters, 3B active, and 262,144 tokens of native context. Qwen reports that its base model beat Qwen3-32B-Base at 10% of the training cost, with about 10x throughput beyond 32K tokens. These are the vendor's own figures [4].

Sparse attention. DeepSeek-V3.2-Exp (2025) changed only one thing from its predecessor: DeepSeek Sparse Attention, a fine-grained scheme in which an indexer module selects which earlier tokens each token attends to. DeepSeek reports scores on par with V3.1-Terminus across public benchmarks, with large efficiency gains in long-context training and inference [5].

Mixture of experts everywhere. Llama 4 (April 2025) was the first Llama family to use MoE, with Maverick at 400B total and 17B active parameters [3], following designs like DeepSeek-V3 [2].

Nine years on, the 2017 block [1] is still recognisable inside every one of these models.

Sources

  1. Vaswani et al.: Attention Is All You Need (2017)
  2. DeepSeek-AI: DeepSeek-V3 Technical Report (2024)
  3. Meta AI: The Llama 4 herd (2025)
  4. Qwen: Qwen3-Next-80B-A3B-Instruct model card (2025)
  5. DeepSeek-AI: DeepSeek-V3.2-Exp model card (2025)