NLP Lineage

18 July 2023 · Language modelling

Llama 2

Llama 2: Open Foundation and Fine-Tuned Chat Models

H. Touvron, L. Martin, K. Stone, et al.

Date
18 July 2023
What the date marks
Model release
Kind
Model
Organisation
Meta AI
Access
Llama 2 Community License
Threads
In the guided tour
Chapter 8. The weights get out
Learning phases
2. How LLMs are trained; 5. Fine-tuning; 8. Training from scratch

A turning point: 4 later milestones descend directly from it, and its descendants reach 9 of the 10 threads. How levels are decided

Drafted with Claude from the paper on 15 October 2026; reviewed by Zeeshan Arif. Read from arxiv.org (arXiv version 2 (July 2023)).

What it changed

Meta released Llama 2 base models and chat models, from 7 to 70 billion parameters, for both research and commercial use. With them it published a detailed account of the RLHF and safety training behind the chat models, a kind of training that the authors say had often not been transparent or reproducible. The largest chat model came close to ChatGPT in Meta’s human tests.

The problem before it

Open base models, such as LLaMA, BLOOM and Falcon, could match closed base models like GPT-3. But none could replace closed chat products such as ChatGPT, Bard and Claude. Those products were heavily fine-tuned with human feedback to make them helpful and safe.

That fine-tuning needs a lot of compute and human labelling, and the authors note it was “often not transparent or easily reproducible”. So outside researchers could not easily study or improve it.

The idea

The mechanism. Train better base models, then fine-tune chat models in several rounds.

The base models (Llama 2). The same design as LLaMA, with these changes:

The chat models (Llama 2-Chat):

  1. Supervised fine-tuning. About 27,500 high-quality examples written by hired annotators. The authors found that fewer, better examples beat millions of examples from public datasets.
  2. Human preference data. Annotators wrote a prompt, compared two model answers and said how much better one was. Meta collected over 1.4 million such comparisons, for helpfulness and for safety separately.
  3. Two reward models, one for helpfulness and one for safety, because the two goals can conflict. During reinforcement learning, the safety score is used for risky prompts or unsafe answers, and the helpfulness score for the rest.
  4. Iterative RLHF, in five rounds. Each round used new preference data on the latest model. Two methods were used:
    • Rejection sampling: generate several answers with the 70-billion-parameter model, keep the best by reward, and fine-tune on them. The smaller models learn from these answers too.
    • PPO, the reinforcement learning method of InstructGPT, applied on top in the last rounds.
  5. Ghost Attention (GAtt). A data trick that teaches the model to keep following an instruction given at the start of a chat, such as “act as Napoleon”, for many turns.

Safety training added adversarial prompts with safe answers, a safety reward model, and “context distillation”: the model learns the safer answers it gives when told “You are a safe and responsible assistant”, so that it gives them without the instruction. More than 350 people tested the models for risks (“red teaming”).

The notation. The reward model is trained with -log σ(r(x, y_c) - r(x, y_r) - m(r)), where y_c is the chosen answer, y_r the rejected one, and m(r) a margin that is larger when annotators said one answer was much better.

What it showed

Reported in the paper. We read version 2 of the arXiv paper. It is a preprint. Most chat results come from Meta’s own human raters and reward models, and from GPT-4 used as a judge.

Limits, and what came later

The limits come from the paper:

Llama 3 was its direct successor. Mistral 7B reported beating Llama 2 13B on all its benchmarks. OLMo aimed at the Llama 2 level as a fully open model, and Gemma benchmarked against it.

What to know first

How to read it

The paper is 77 pages, with 36 pages of main text.

  1. Read section 1 with Figures 1 to 4 for the overview.
  2. Skim section 2 on pretraining, with Tables 1 and 3.
  3. Read section 3 closely. Sections 3.1 and 3.2 are the most detailed public account of RLHF at this scale.
  4. Read section 4.2 on safety fine-tuning and 4.4 on safety results.
  5. Read sections 5.1 and 5.2 for the authors’ observations and limits.

Expect about 3 hours for the steps above (an estimate).

In brief, from the research data

Before it

The best open weights were research-only, so companies could not build on them.

The problem

Open models were a research curiosity rather than a commercial option.

What it introduced

Open weights with a commercial licence, a documented RLHF pipeline, and chat models tuned for safety.

Why it matters

It made open weights a viable business decision and set off serious enterprise adoption.

What modern models inherit

The community licence model, restrictions and all.

What came next

Code Llama, Llama 3 and 3.1, then the pivot away from open releases in 2026.

Before and after

The milestones it descends from, and the milestones that descend from it. Work developed alongside it is not counted. Weak links are left out unless you include them.

Before: where it came from

Llama 2 has 41 documented ancestors across 9 chapters, reaching back to Recurrent networks in 1990. Showing its direct parents and the 18 turning points among them.

Llama 2 has 41 documented ancestors across 9 chapters, reaching back to Recurrent networks in 1990. Showing all of them.

Llama 2 has 42 recorded ancestors, including indirect ones, across 9 chapters, reaching back to Recurrent networks in 1990. Showing its direct parents and the 18 turning points among them.

Llama 2 has 42 recorded ancestors, including indirect ones, across 9 chapters, reaching back to Recurrent networks in 1990. Showing all of them.

  1. 2023Llama 2This milestone.
  2. 2023Grouped-query attention Turning pointLlama 2 built directly on thisChapter 9. Making it run anywhere
  3. 2023LLaMA Turning pointLlama 2 built directly on thisChapter 8. The weights get out
  4. 2022Chinchilla Turning pointLLaMA built directly on thisChapter 5. Scale becomes a science
  5. 2022InstructGPT Turning pointLlama 2 was influenced by thisChapter 6. Teaching models what people want
  6. 2021GopherChinchilla built directly on thisChapter 5. Scale becomes a science
  7. 2021FLANInstructGPT was influenced by thisChapter 6. Teaching models what people want
  8. 2021RoPE Turning pointLLaMA built directly on thisChapter 10. Reading more than you remember
  9. 2020RLHF for summarisation Turning pointInstructGPT built directly on thisChapter 6. Teaching models what people want
  10. 2020GPT-3 Turning pointInstructGPT built directly on thisChapter 5. Scale becomes a science
  11. 2020Scaling laws Turning pointGPT-3 was influenced by this
    Chinchilla built directly on this
    Chapter 5. Scale becomes a science
  12. 2019Multi-query attentionGrouped-query attention built directly on thisChapter 9. Making it run anywhere
  13. 2019T5 Turning pointFLAN was influenced by thisChapter 4. Pretrain once, use everywhere
  14. 2019C4 Turning pointT5 was influenced by thisChapter 4. Pretrain once, use everywhere
  15. 2019RLHF for LMsRLHF for summarisation built directly on thisChapter 6. Teaching models what people want
  16. 2019Sparse Transformer Turning pointGPT-3 built directly on thisChapter 4. Pretrain once, use everywhere
  17. 2019GPT-2 Turning pointGPT-3 built directly on thisChapter 4. Pretrain once, use everywhere
  18. 2019WebTextGPT-2 was influenced by thisChapter 4. Pretrain once, use everywhere
  19. 2019Transformer-XLRoPE was influenced by thisChapter 4. Pretrain once, use everywhere
  20. 2018BERT Turning pointT5 was influenced by thisChapter 4. Pretrain once, use everywhere
  21. 2018SentencePieceT5 built directly on thisChapter 4. Pretrain once, use everywhere
  22. 2018GPT-1GPT-2 built directly on thisChapter 4. Pretrain once, use everywhere
  23. 2018ELMoBERT was influenced by thisChapter 4. Pretrain once, use everywhere
  24. 2018ULMFiTBERT was influenced by thisChapter 4. Pretrain once, use everywhere
  25. 2017CoVeELMo was influenced by thisChapter 3. Attention, then only attention
  26. 2017Transformer Turning pointRoPE built directly on this
    Multi-query attention built directly on this
    Chapter 3. Attention, then only attention
  27. 2017RLHF originRLHF for summarisation built directly on thisChapter 6. Teaching models what people want
  28. 2016Layer normTransformer built directly on this
    GPT-2 built directly on this
    Chapter 3. Attention, then only attention
  29. 2015Residual connectionsTransformer was influenced by thisChapter 3. Attention, then only attention
  30. 2015LM pretraining Turning pointBERT was influenced by this
    GPT-1 was influenced by this
    Chapter 2. Words become vectors
  31. 2015BPE tokenizationLLaMA built directly on thisChapter 2. Words become vectors
  32. 2015Luong attentionTransformer was influenced by thisChapter 3. Attention, then only attention
  33. 2014AdamTransformer was influenced by thisChapter 2. Words become vectors
  34. 2014GloVeELMo built directly on thisChapter 2. Words become vectors
  35. 2014Seq2seq Turning pointTransformer built directly on thisChapter 2. Words become vectors
  36. 2014Attention Turning pointTransformer built directly on thisChapter 3. Attention, then only attention
  37. 2014GRU / encoder-decoderAttention built directly on thisChapter 2. Words become vectors
  38. 2013word2vecELMo was influenced by thisChapter 2. Words become vectors
  39. 2011NLP from scratchELMo was influenced by thisChapter 1. Language as probability
  40. 2003Neural LMNLP from scratch was influenced by this
    word2vec was influenced by this
    Chapter 1. Language as probability
  41. 1997LSTM Turning pointSeq2seq built directly on thisChapter 1. Language as probability
  42. 1990Recurrent networksLSTM was influenced by thisChapter 1. Language as probability
  1. 2023Llama 2This milestone.
  2. 2023Grouped-query attention Turning pointLlama 2 built directly on thisChapter 9. Making it run anywhere
  3. 2023LLaMA Turning pointLlama 2 built directly on thisChapter 8. The weights get out
  4. 2022Chinchilla Turning pointLLaMA built directly on thisChapter 5. Scale becomes a science
  5. 2022InstructGPT Turning pointLlama 2 was influenced by thisChapter 6. Teaching models what people want
  6. 2021GopherChinchilla built directly on thisChapter 5. Scale becomes a science
  7. 2021FLANInstructGPT was influenced by thisChapter 6. Teaching models what people want
  8. 2021RoPE Turning pointLLaMA built directly on thisChapter 10. Reading more than you remember
  9. 2020RLHF for summarisation Turning pointInstructGPT built directly on thisChapter 6. Teaching models what people want
  10. 2020GPT-3 Turning pointInstructGPT built directly on thisChapter 5. Scale becomes a science
  11. 2020Scaling laws Turning pointGPT-3 was influenced by this
    Chinchilla built directly on this
    Chapter 5. Scale becomes a science
  12. 2019Multi-query attentionGrouped-query attention built directly on thisChapter 9. Making it run anywhere
  13. 2019T5 Turning pointFLAN was influenced by thisChapter 4. Pretrain once, use everywhere
  14. 2019C4 Turning pointT5 was influenced by thisChapter 4. Pretrain once, use everywhere
  15. 2019RLHF for LMsRLHF for summarisation built directly on thisChapter 6. Teaching models what people want
  16. 2019Sparse Transformer Turning pointGPT-3 built directly on thisChapter 4. Pretrain once, use everywhere
  17. 2019GPT-2 Turning pointGPT-3 built directly on thisChapter 4. Pretrain once, use everywhere
  18. 2019WebTextGPT-2 was influenced by thisChapter 4. Pretrain once, use everywhere
  19. 2019Transformer-XLRoPE was influenced by thisChapter 4. Pretrain once, use everywhere
  20. 2018BERT Turning pointT5 was influenced by thisChapter 4. Pretrain once, use everywhere
  21. 2018SentencePieceT5 built directly on thisChapter 4. Pretrain once, use everywhere
  22. 2018GPT-1GPT-2 built directly on thisChapter 4. Pretrain once, use everywhere
  23. 2018ELMoBERT was influenced by this
    GPT-1 was influenced by this (indirect influence)
    Chapter 4. Pretrain once, use everywhere
  24. 2018ULMFiTBERT was influenced by this
    GPT-1 was influenced by this (indirect influence)
    Chapter 4. Pretrain once, use everywhere
  25. 2017CoVeELMo was influenced by thisChapter 3. Attention, then only attention
  26. 2017Transformer Turning pointRoPE built directly on this
    Multi-query attention built directly on this
    Chapter 3. Attention, then only attention
  27. 2017RLHF originRLHF for summarisation built directly on thisChapter 6. Teaching models what people want
  28. 2017ConvS2STransformer was influenced by this (indirect influence)Chapter 3. Attention, then only attention
  29. 2016Layer normTransformer built directly on this
    GPT-2 built directly on this
    Chapter 3. Attention, then only attention
  30. 2015Residual connectionsTransformer was influenced by thisChapter 3. Attention, then only attention
  31. 2015LM pretraining Turning pointBERT was influenced by this
    GPT-1 was influenced by this
    Chapter 2. Words become vectors
  32. 2015BPE tokenizationLLaMA built directly on thisChapter 2. Words become vectors
  33. 2015Luong attentionTransformer was influenced by thisChapter 3. Attention, then only attention
  34. 2014AdamTransformer was influenced by thisChapter 2. Words become vectors
  35. 2014GloVeELMo built directly on thisChapter 2. Words become vectors
  36. 2014Seq2seq Turning pointTransformer built directly on thisChapter 2. Words become vectors
  37. 2014Attention Turning pointTransformer built directly on thisChapter 3. Attention, then only attention
  38. 2014GRU / encoder-decoderAttention built directly on thisChapter 2. Words become vectors
  39. 2013word2vecELMo was influenced by thisChapter 2. Words become vectors
  40. 2011NLP from scratchELMo was influenced by thisChapter 1. Language as probability
  41. 2003Neural LMNLP from scratch was influenced by this
    word2vec was influenced by this
    Chapter 1. Language as probability
  42. 1997LSTM Turning pointSeq2seq built directly on thisChapter 1. Language as probability
  43. 1990Recurrent networksLSTM was influenced by thisChapter 1. Language as probability

After: what it led to

Llama 2 has 17 documented descendants across 3 chapters, reaching forward to Qwen3.8 in 2026. Showing its direct descendants.

Llama 2 has 17 documented descendants across 3 chapters, reaching forward to Qwen3.8 in 2026. Showing all of them.

Llama 2 has 20 recorded descendants, including indirect ones, across 3 chapters, reaching forward to Qwen3.8 in 2026. Showing its direct descendants.

Llama 2 has 20 recorded descendants, including indirect ones, across 3 chapters, reaching forward to Qwen3.8 in 2026. Showing all of them.

  1. 2023Llama 2This milestone.
  2. 2024DeepSeek LLMwas influenced by Llama 2Chapter 8. The weights get out
  3. 2024OLMowas influenced by Llama 2Chapter 8. The weights get out
  4. 2024GRPObuilt directly on DeepSeek LLMChapter 12. Thinking longer
  5. 2024Gemmawas influenced by Llama 2Chapter 8. The weights get out
  6. 2024Llama 3built directly on Llama 2Chapter 8. The weights get out
  7. 2024Llama 3.1 405Bbuilt directly on Llama 3Chapter 8. The weights get out
  8. 2024DeepSeek-V3built directly on GRPO
    was influenced by Llama 3.1 405B
    Chapter 8. The weights get out
  9. 2025DeepSeek-R1built directly on GRPOChapter 12. Thinking longer
  10. 2025Llama 4succeeded Llama 3.1 405BChapter 8. The weights get out
  11. 2025Qwen3was influenced by DeepSeek-R1Chapter 8. The weights get out
  12. 2025Kimi K2was influenced by GRPOChapter 8. The weights get out
  13. 2025DeepSeek-V3.2built directly on DeepSeek-V3Chapter 10. Reading more than you remember
  14. 2026Qwen3.5built directly on Qwen3Chapter 8. The weights get out
  15. 2026Muse Sparksucceeded Llama 4Chapter 8. The weights get out
  16. 2026DeepSeek-V4was influenced by DeepSeek-V3Chapter 8. The weights get out
  17. 2026Kimi K3built directly on Kimi K2Chapter 8. The weights get out
  18. 2026Qwen3.8built directly on Qwen3.5Chapter 8. The weights get out
  1. 2023Llama 2This milestone.
  2. 2024DeepSeek LLMwas influenced by Llama 2Chapter 8. The weights get out
  3. 2024OLMowas influenced by Llama 2Chapter 8. The weights get out
  4. 2024GRPObuilt directly on DeepSeek LLMChapter 12. Thinking longer
  5. 2024Gemmawas influenced by Llama 2Chapter 8. The weights get out
  6. 2024Llama 3built directly on Llama 2Chapter 8. The weights get out
  7. 2024Llama 3.1 405Bbuilt directly on Llama 3Chapter 8. The weights get out
  8. 2024DeepSeek-V3built directly on GRPO
    was influenced by Llama 3.1 405B
    Chapter 8. The weights get out
  9. 2025DeepSeek-R1built directly on GRPOChapter 12. Thinking longer
  10. 2025Llama 4succeeded Llama 3.1 405BChapter 8. The weights get out
  11. 2025Qwen3was influenced by DeepSeek-R1Chapter 8. The weights get out
  12. 2025Kimi K2was influenced by GRPOChapter 8. The weights get out
  13. 2025gpt-osswas influenced by DeepSeek-R1 (indirect influence)Chapter 8. The weights get out
  14. 2025GLM-4.5was influenced by DeepSeek-R1 (indirect influence)Chapter 8. The weights get out
  15. 2025DeepSeek-V3.2built directly on DeepSeek-V3Chapter 10. Reading more than you remember
  16. 2026Qwen3.5built directly on Qwen3Chapter 8. The weights get out
  17. 2026Muse Sparksucceeded Llama 4Chapter 8. The weights get out
  18. 2026DeepSeek-V4was influenced by DeepSeek-V3Chapter 8. The weights get out
  19. 2026GLM-5.2built directly on GLM-4.5Chapter 8. The weights get out
  20. 2026Kimi K3built directly on Kimi K2Chapter 8. The weights get out
  21. 2026Qwen3.8built directly on Qwen3.5Chapter 8. The weights get out

Direct links and their sources

Where it came from

Built directly on

Influenced by

What it led to

Built on directly by

Influenced

Developed alongside

Terms