Evolution of LLM Architecture

A timeline after 2017

After the Transformer

ANN: Evolution ends in 2017, when attention became the foundation of the Transformer and the recurrent queue was dropped. This page is the second flagship: the architecture timeline that follows. How the typist’s plan changed, one wall at a time, from that paper to the models we run today.

Architecture, here, means the plan: how the model reads, how it remembers what it has read, and how it writes the next token. The numbers and the loss stay in the same family. The plan is what moved.

The closer teaching pages already on this wiki stay where they are. The mechanics of attention, the 2017 paper, a block you can compute by hand, the builder’s view of n-grams and linear attention, and how a model is trained and run, all have homes. When a step has a page, we walk over to it. This page is the story of the shapes.

Before 2017, in brief

A language model is a distribution over the next token. The early toolkit was n-grams: guess from a fixed window of previous words. The table is simple, and it hits a wall as soon as the phrase is a little new or a little longer. Neural language models (Bengio and colleagues, 2003) replaced the giant table with vectors and a network that could share parameters. Recurrent nets, and then LSTM, folded the past into a hidden state that was updated one token at a time. That story, including why a recurrent net forgets and why it is a queue, is in ANN: Evolution. A builder’s sketch of the same path is in Language model architecture. What is a language model? is the next-token idea itself.

For translation, a typical net read a source sentence and squeezed it into one vector, then tried to write the target from that single summary. Attention (Bahdanau, Cho and Bengio, 2014) opened the letter back up: the decoder could look at the source, a little at a time, instead of trusting the sticky note alone. That family tree — Bahdanau, Luong, the Transformer, linear attention, FlashAttention — is The evolution of attention. We do not retell it here.

The wall that was still standing, in 2017, was the queue. Attention helped a recurrent encoder–decoder. The recurrent net still had to read one token before the next.

The Transformer (2017)

Attention Is All You Need (Vaswani, Shazeer, Parmar, Uszkoreit, Jones, Gomez, Kaiser and Polosukhin, 2017) asked a bold question: if attention is doing the real work, why keep the recurrent net at all?

They dropped recurrence, and convolutions, and built a model from attention and a few feed-forward layers. That model is the Transformer. The 2017 paper is an encoder–decoder, built for translation: one stack reads the source, the other writes the target, and attention ties the two together.

Two facts matter for everything that follows. The model can read the whole input at once, which is a much better fit for a GPU than a queue. It still writes one token at a time: predict, append, predict again. Attention Is All You Need is the reader’s guide to the paper. Transformer by hand works through one block with small integers. The encoder–decoder versus decoder-only distinction is the draft The Transformer.

The Transformer fixed the slow queue. It left two new questions on the table. Which of the two stacks do you actually need, if the job is not translation? And how big should the model be?

Three families (2018–2020)

The years after the paper split that shape three ways.

Encoder-only. BERT (Devlin, Chang, Lee and Toutanova, 2018) keeps the encoder and reads a sentence from both directions. It is trained to fill in masked tokens, and it became the default for understanding tasks: classification, extraction, a score for a sentence. It is not, by itself, a model that writes a long answer.

Decoder-only. GPT (Radford, Narasimhan, Salimans and Sutskever, 2018) keeps the decoder: a single stack with a causal mask, trained to write the next token. Give it a prefix, and it continues. Almost every chat model you meet now lives on this line.

Encoder–decoder, as text-to-text. T5 (Raffel and colleagues, 2019) keeps both stacks, and casts many language tasks as “read some text, write some text.” The 2017 shape, reused as a general recipe, not only as a translator.

The decoder-only line won for generation because it is one stack, one objective, and it scales cleanly: more tokens in, more tokens out, the same plan. Encoder-only models remain useful for understanding. Encoder–decoder models remain a good fit when you really do have a source and a target. For a chatbot, the field settled on a single causal decoder.

Scaling (2020–2022)

Once training was parallel, the next wall was not a missing block. It was a question of size.

Language Models are Unsupervised Multitask Learners (Radford and colleagues, 2019) — GPT-2 — showed that a larger decoder, trained on more web text, could do many tasks from a prompt, without a task-specific head. Language Models are Few-Shot Learners (Brown and colleagues, 2020) — GPT-3, at 175 billion parameters — made that jump hard to ignore. The same next-token model, given a few examples in the prompt, could do work that people had been fine-tuning for. The architecture had not changed shape. The scale had.

Scaling Laws for Neural Language Models (Kaplan and colleagues, 2020) then gave the growth a curve: as you scale parameters, data and compute together, the loss falls in a smooth, predictable way, over a wide range. Bigger, used carefully, kept getting better. There was no sudden wall on that plot.

A correction arrived in 2022. Training Compute-Optimal Large Language Models (Hoffmann and colleagues) — the Chinchilla paper — argued that many of the largest models were undertrained. They had too many parameters for the amount of text they had seen. For a fixed compute budget, a smaller model trained on more tokens can beat a larger model trained on fewer. Their 70-billion-parameter Chinchilla, trained on 1.4 trillion tokens, beat DeepMind’s earlier 280-billion-parameter Gopher, trained on 300 billion. The lesson is not “never grow the model.” It is: grow the data along with the weights.

Everyday example

A bigger engine is wasted if you only put a cup of fuel in the tank. Kaplan told us that a bigger engine, with enough fuel, runs more smoothly than we had any right to expect. Chinchilla told us to check the tank.

Language model training is the map of how a typist is actually taught — pretraining, midtraining, post-training. This page only needs the architectural consequence. Scaling worked. It also made a new wall obvious: in a dense model, every parameter works on every token. Double the model, and you roughly double the cost of every answer.

The modern decoder block, and open models (2023)

While the models grew, the block inside the decoder quietly changed. The look-then-think shape stayed. The defaults around it did not.

The 2017 paper uses post-norm: a residual add, then LayerNorm. GPT-2 already moved the normalisation to the input of each sub-block (pre-norm), which is kinder to deep stacks. RMSNorm (Zhang and Sennrich, 2019) later simplified the norm itself. The original positional signal is a fixed pattern of sines and cosines, added at the input. RoFormer (Su and colleagues, 2021) introduced RoPE: a rotation applied to the queries and keys, so the attention itself knows the relative distance. The 2017 feed-forward net uses a ReLU. GLU Variants Improve Transformer (Shazeer, 2020) made SwiGLU a common replacement.

One more change matters at run time. The 2017 attention has one key–value head for every query head. Fast Transformer Decoding (Shazeer, 2019) proposed multi-query attention (MQA): many query heads, one shared set of keys and values. GQA (Ainslie and colleagues, 2023) sits in between: a few key–value groups, each shared by several query heads. Fewer key–value heads means a smaller KV cache, which is the memory the model must keep of every earlier token while it writes the next one. How that cache is built in prefill and extended in decode is Language model inference. Here we only need why the architecture changed: the cache was becoming the bill.

Those choices were pulled together, and released, in LLaMA (Touvron and colleagues, 2023): a family of dense decoder-only models, trained on a large public-friendly mix, with pre-norm, RMSNorm, RoPE and SwiGLU. LLaMA 2 later brought grouped-query attention to the larger members of the family. The weights were not a new kind of attention. They were a clean, open instance of the modern block, and they became a starting point for a great deal of later work. When people say “a LLaMA-style model,” they usually mean this recipe.

The cache formula below is only the memory of the keys and values. It is not the cost of loading the weights, and it is not the roofline. Those sit on Language model inference.

The cell below is live Python in the browser. It uses only arithmetic. The numbers are a classroom example, in the spirit of a 32-layer decoder with 128-dimensional heads, in 16-bit precision, for one sequence. Change a head count and watch the cache shrink. That is the point of GQA and MQA.

Long context is the same bill, seen from the other side. Ordinary self-attention is quadratic in the length, and the cache grows with every new token. FlashAttention (Dao and colleagues, 2022) keeps the original exact attention and runs it with fewer trips to GPU memory; that story is in The evolution of attention. Another practical move is a sliding window: each token looks only at a recent neighbourhood, as in Mistral 7B (Jiang and colleagues, 2023), which combined a window with grouped-query attention. Linear attention and the hybrids that mix a cheap state with a few full look-backs are in Language model architecture. This page does not repeat them.

A dense timeline chart titled How LLMs build on each other. U.S. organizations are on the left, Chinese organizations on the right, with a year axis from 2021 to 2026 in the middle. Coloured arrows show ideas crossing between labs, such as RoPE into LLaMA, grouped-query attention into DeepSeek models, and DeepSeek's multi-head latent attention into Kimi. Small architecture sketches of later models sit in the side columns. The footer reads Sebastian Raschka and llm-gallery.com.

Chart titled How LLMs build on each other: a 2021 to 2026 map of ideas crossing between U.S. and Chinese labs, including RoPE, GQA, and multi-head latent attention.

US and Chinese labs keep borrowing each other’s ideas (e.g. RoPE to LLaMA, GQA to DeepSeek, DeepSeek’s MLA to Kimi).

Chart: Sebastian Raschka, llm-gallery.com

Mixture of Experts (2023–2024)

Scaling made models smarter, and more expensive to run, because a dense feed-forward net does work for every token. Mixture of Experts (MoE) attacks that bill without throwing the knowledge away.

The idea is older than the current wave. Outrageously Large Neural Networks (Shazeer and colleagues, 2017) already put a sparsely gated mixture of experts in a language model. Switch Transformers (Fedus, Zoph and Shazeer, 2021) simplified the routing: send each token to one expert. The attention stays shared. What used to be a single feed-forward net becomes a panel of experts, and a small router that picks one or two of them for each token.

Mixtral of Experts (Jiang and colleagues, 2024) made the recipe famous in the open. Mixtral 8×7B has eight experts; the router picks two of them per token. The name does not mean \(8 \times 7 = 56\) billion parameters. The attention and the other shared pieces are not copied. The published figures are about 47 billion parameters in total, and about 13 billion active for each token. Later models pushed the same idea further. DeepSeek-V3 (DeepSeek-AI, 2024), for example, reports 671 billion parameters in total and about 37 billion active per token, with a finer expert design.

Everyday example

A dense model is a whole faculty walking into every tutorial. An MoE model is the reception desk sending you to two tutors. The university still employs everyone. You do not meet everyone in the same hour.

The cell below is a classroom calculator, not a copy of any one model’s ledger. You choose how many experts, and how many of them fire. The default split is in the spirit of Mixtral: a shared part, plus eight feed-forward experts, with two of them active. The published Mixtral figures are printed underneath, for a check.

Two cautions, which belong in an FAQ as well. MoE saves compute per token. It does not, by itself, save memory: the unused experts still have to sit on the device, because the next token may pick a different pair. And the router has to be trained honestly, so that a few experts do not end up doing all the work.

Other shapes: state-space models and hybrids

The Transformer is the default, not the only path. If the quadratic look-back is the tax, one answer is to change the look-back.

State-space models, of which Mamba (Gu and Dao, 2023) is the name most people now know, keep a running state that updates in linear time, and — unlike a plain RNN — select what to write into that state and what to ignore. Mamba is not “just an RNN with a new coat of paint.” It is a bet that a careful, selective state can carry long context without paying \(n^2\). Hybrids, which keep a few full attention layers and use a cheap state for the rest, are now common. The builder’s comparison of softmax attention, linear attention and mixed designs — including why a compressed state can lose a long-context needle — is in Language model architecture. The 2020 linear-attention paper and FlashAttention stay on The evolution of attention.

A short look at multimodal

A language-model architecture can also take more than text. The usual plan is not a brand-new backbone. It is a connector: a vision encoder (or an audio encoder) produces a sequence of vectors, and those vectors are projected into the same space the language model already uses, or they are read with a cross-attention. The typist then continues, as before, one token at a time. CLIP (Radford and colleagues, 2021) made a shared vision–language space widely usable; models such as Flamingo (Alayrac and colleagues, 2022) showed how to graft a frozen encoder onto a large language model. This page only needs the architectural point. The decoder is still the typist. What changed is what it is allowed to see.

Reasoning models: a hand-off

From late 2024, a new kind of system became hard to ignore: a reasoning model, which spends a variable amount of work — a written trace, several attempts, extra compute at test time — before it settles on an answer.

That jump is not, first of all, a new backbone. The typist is still, in most cases, a decoder-only Transformer, dense or MoE, with a modern block. What changed is how the model is trained to use a thinking budget, and how much compute you spend when it is already trained. Those stories have their own chapter. Start at What is a reasoning model? (draft). The recent history is Evolution of reasoning models (draft). Test-time compute is Inference-time scaling (draft), and the training recipes sit in Reinforcement learning for reasoning (draft). This flagship stops here, and hands over.

Where next

The story is not finished. The quadratic look-back, and the KV cache, are still a tax on long context. MoE made large models cheaper to run per token, and left a memory and routing problem on the table. Hybrids and state-space models are a live bet that a different look-back can join, or partly replace, full attention. Multimodal inputs are already ordinary. Reasoning models asked the typist to spend work on the hard problems, without inventing a new house plan.

If a later page has to be written, it will probably be about one of those walls: a cheaper long memory, a cleaner way to serve a sparse model, or a block we do not have a name for yet. For now, the closer pages already on this wiki are the right next step.

A short history in a table

Year Idea Wall it fixed What came next
2017 The Transformer, an encoder–decoder of attention The recurrent queue: slow to train, and a long path through a state Which stack do you need, and how big should it be?
2018–20 Three families: BERT, GPT, T5 One 2017 shape had been asked to do every job Decoder-only won for generation; scale was the next lever
2020 GPT-3, and scaling laws (Kaplan and colleagues) We did not know, in a useful way, how far “bigger” would go Dense models got expensive to run; some were also undertrained
2022 Chinchilla: grow the data with the weights Large models trained on too little text The running cost of a dense forward pass was still the bill
2023 A modern decoder block, and open LLaMA-style models Deep stacks, a bulky KV cache, a dated positional scheme Long context and serving cost were now in plain view
2023–24 Mixture of Experts (Switch, Mixtral, DeepSeek MoE) Every parameter working on every token Memory, routing, and whether a new look-back would join attention
2023– State-space models and hybrids (Mamba, mixed attention) Quadratic look-back, and a cache that grows with every token Still being tried; full attention has not gone away
2024– Reasoning models Not a new backbone: a typist that spends work on the hard problems That chapter continues next door

Every row keeps what worked and repairs the biggest thing that did not. The Transformer kept attention and dropped the queue. The decoder-only line kept the typist and dropped the extra stack. Scaling kept the typist and grew it. Chinchilla kept the growth and filled the tank. The modern block kept the look-then-think shape and made it cheaper to run. MoE kept the knowledge and stopped paying for every expert on every token. Then the typist was asked to think longer, and that is a different story.

FAQ

Is a decoder-only model just half a Transformer?

It is the decoder stack, used as a language model: one stream, a causal mask, next-token training. The 2017 paper had two stacks, because the job was translation. For a chat model, one causal stack was enough, and it became the default. The closer distinction is in The Transformer (draft).

Did GPT-3 invent in-context learning as an architecture?

No. GPT-3 is a larger decoder-only Transformer, trained as a language model. What changed is the scale, and what that scale made possible from a prompt: a few examples in the context, and no task-specific head. The architecture of the typist did not grow a new module for “few-shot.”

If Chinchilla says to train smaller models on more data, why are models still getting bigger?

Chinchilla is a statement about a compute budget: for a fixed training spend, many earlier models were too large for the amount of text they had seen. It is not a law that says “never grow the model.” If you also grow the data, and the budget, a larger model can still be the right choice. The later LLaMA-style models followed the spirit of the result: more tokens, not only more weights.

Does a Mixture-of-Experts model use less memory than a dense model of the same quality?

Not in the simple way people hope. MoE reduces the work per token, because only a few experts fire. The unused experts still have to sit in memory, because the next token may pick a different pair. You save compute. You do not automatically save the footprint of the weights.

Is Mixtral 8×7B a 56-billion-parameter model?

No. Eight copies of a 7-billion-parameter dense model would be 56 billion, but only the feed-forward experts are copied. The attention and the other shared pieces are not. The published figures are about 47 billion parameters in total, and about 13 billion active for each token.

Is Mamba just an RNN?

No. Mamba keeps a running state, and its cost can grow in a straight line with the length, like a recurrent net. Unlike the older RNN, it selects what to keep and what to ignore as each token arrives, and it is designed so that training can stay efficient. It is a different bet about memory, not a replay of 1997.

Is a reasoning model a new architecture?

Usually not. Most reasoning models sit on the same decoder-only line, dense or MoE, with a modern block. What is new is the training and the test-time budget: a written trace, several attempts, a variable amount of work before the answer. That is the Reasoning models chapter, not a new house plan on this page.

See also

References

  • [1] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser and Illia Polosukhin, Attention Is All You Need, 2017. https://arxiv.org/abs/1706.03762.
  • [2] Jacob Devlin, Ming-Wei Chang, Kenton Lee and Kristina Toutanova, BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding, 2018. https://arxiv.org/abs/1810.04805.
  • [3] Alec Radford, Karthik Narasimhan, Tim Salimans and Ilya Sutskever, Improving Language Understanding by Generative Pre-Training, 2018. PDF; Alec Radford and colleagues, Language Models are Unsupervised Multitask Learners, 2019. PDF; Tom B. Brown and colleagues, Language Models are Few-Shot Learners, 2020. https://arxiv.org/abs/2005.14165.
  • [4] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li and Peter J. Liu, Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer, 2019. https://arxiv.org/abs/1910.10683.
  • [5] Jared Kaplan and colleagues, Scaling Laws for Neural Language Models, 2020. https://arxiv.org/abs/2001.08361; Jordan Hoffmann and colleagues, Training Compute-Optimal Large Language Models, 2022. https://arxiv.org/abs/2203.15556.
  • [6] Biao Zhang and Rico Sennrich, Root Mean Square Layer Normalization, 2019. https://arxiv.org/abs/1910.07467; Jianlin Su and colleagues, RoFormer: Enhanced Transformer with Rotary Position Embedding, 2021. https://arxiv.org/abs/2104.09864; Noam Shazeer, GLU Variants Improve Transformer, 2020. https://arxiv.org/abs/2002.05202.
  • [7] Noam Shazeer, Fast Transformer Decoding: One Write-Head is All You Need, 2019. https://arxiv.org/abs/1911.02150; Joshua Ainslie, James Lee-Thorp, Michiel de Jong, Yury Zemlyanskiy, Federico Lebrón and Sumit Sanghai, GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints, 2023. https://arxiv.org/abs/2305.13245.
  • [8] Hugo Touvron and colleagues, LLaMA: Open and Efficient Foundation Language Models, 2023. https://arxiv.org/abs/2302.13971.
  • [9] Tri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra and Christopher Ré, FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness, 2022. https://arxiv.org/abs/2205.14135; Albert Q. Jiang and colleagues, Mistral 7B, 2023. https://arxiv.org/abs/2310.06825.
  • [10] Noam Shazeer and colleagues, Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layer, 2017. https://arxiv.org/abs/1701.06538; William Fedus, Barret Zoph and Noam Shazeer, Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity, 2021. https://arxiv.org/abs/2101.03961; Albert Q. Jiang and colleagues, Mixtral of Experts, 2024. https://arxiv.org/abs/2401.04088; DeepSeek-AI, DeepSeek-V3 Technical Report, 2024. https://arxiv.org/abs/2412.19437.
  • [11] Albert Gu and Tri Dao, Mamba: Linear-Time Sequence Modeling with Selective State Spaces, 2023. https://arxiv.org/abs/2312.00752.
  • [12] Alec Radford and colleagues, Learning Transferable Visual Models From Natural Language Supervision, 2021. https://arxiv.org/abs/2103.00020; Jean-Baptiste Alayrac and colleagues, Flamingo: a Visual Language Model for Few-Shot Learning, 2022. https://arxiv.org/abs/2204.14198.
  • [13] The “wall then fix” shape of this timeline follows the same teaching pattern as Amit Shekhar, Evolution of LLM Architecture, Outcome School (21 September 2026). The prose, the diagrams and the choice of beats are our own, and they sit next to the other pages of this wiki rather than retelling them.
  • [14] Sebastian Raschka, How LLMs build on each other, https://llm-gallery.com. The chart in the margin of the 2023–2026 section is from this gallery.
Back to top