Skip to main content
GW
HomeWorkAI appsPapersAboutNotesStackLabPilotPlan↗ (opens in a new tab)INVST↗ (opens in a new tab)
Govind Waghmare

Finance systems and AI. Building in public from NYC.

Resume (PDF)Book 20 minEmail
HomeNotesWorkAboutStackPapersLabFor founders
XLinkedInGitHubllms.txt
© 2026 · New York City

Keyboard shortcuts

?
Open this list
g then h
Go to Home
g then w
Go to Work
g then n
Go to Notes
g then a
Go to About
c
Ask the AI guide
Esc
Close this list
Original paperAbstract
Open in new tab (opens in a new tab)
All papers
FoundationsClassic

Smaller models, trained longer, on public data

Paper: LLaMA: Open and Efficient Foundation Language Models

Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothee Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, Guillaume Lample · arXiv · Posted 27 Feb 2023 · 16 min read · arXiv 2302.13971

Share this paper

LinkedIn (opens in a new tab)X (opens in a new tab)WhatsApp (opens in a new tab)EmailDownload PDFExplainer + original paper (PDF), 1.4 MB

  • Strong language models are costly to run.
  • Most of them train on private data and stay closed.
  • Earlier work asked for the cheapest model to train.
  • It ignored the cost to run the model at scale.
10x smaller

LLaMA-13B beats GPT-3 on most benchmarks while being 10 times smaller.

  • The authors train 4 sizes: 7B, 13B, 33B and 65B.
  • They use only public data, about 1.4T tokens.
  • They test 20 benchmarks in zero-shot and few-shot settings.
  • They also test bias, toxicity and truthfulness.

  • LLaMA-13B beats GPT-3 (175B) on most benchmarks.
  • LLaMA-65B is competitive with Chinchilla-70B and PaLM-540B.
  • The 13B model can run on a single GPU.
  • LLaMA-65B still trails on MMLU and shows bias and wrong answers.

LLaMA-13B beats GPT-3 on 4 of these 5 testsFrom Table 3
LLaMA 13BGPT-3 175B
0255075100Zero-shot accuracy (%)BoolQ78.1%60.5%HellaSwag79.2%78.9%ARC-e74.8%68.8%ARC-c52.7%51.4%OBQA56.4%57.6%

Hover, tap or focus a bar to read its exact value.

BenchmarkLLaMA 13B (%)GPT-3 175B (%)
BoolQ78.160.5
HellaSwag79.278.9
ARC-e74.868.8
ARC-c52.751.4
OBQA56.457.6

  • These results are from 2023. Newer models are stronger.
  • Benchmarks are not real work. Test on your own tasks.
  • The bias tests are not enough to show the full risk.
  • Scores for other models come from other papers.

Jump to

  1. A The abstract
  2. 1 Introduction: why smaller and longer
  3. 2 Approach: data, design and training
  4. 3 Main results: how they test
  5. 3.1 Common sense reasoning
  6. 3.2 Closed-book question answering
  7. 3.3 Reading comprehension
  8. 3.4 Mathematical reasoning
  9. 3.5 Code generation
  10. 3.6 Massive Multitask Language Understanding
  11. 3.7 Evolution of performance during training
  12. 4 Instruction finetuning
  13. 5 Bias, toxicity and misinformation
  14. 5.1 RealToxicityPrompts
  15. 5.2 CrowS-Pairs
  16. 5.3 WinoGender
  17. 5.4 TruthfulQA
  18. 6 Carbon footprint
  19. 7 Related work
  20. 8 Conclusion
  21. A Appendix A: question answering setup
  22. B Appendix B: MMLU in detail
  23. C Appendix C: sample outputs of LLaMA-65B
  24. D Appendix D: sample outputs of LLaMA-I
  25. W Words to know

Every detail from the paper

Cards follow the paper's own order. Dotted words link to Words to know. Numbers match the paper.

What LLaMA is

  • LLaMA is a set of foundation language models.
  • The sizes go from 7B to 65B parameters.
  • The authors train them on trillions of tokens.
  • They use public data only. They use no private data.

The main claims

  • LLaMA-13B beats GPT-3 (175B) on most benchmarks.
  • LLaMA-65B is competitive with Chinchilla-70B and PaLM-540B.
  • The authors release all models to the research community.

The old idea

  • Large language models learn new tasks from text instructions or a few examples.
  • These few-shot skills first appeared when models grew large enough.
  • Many teams then built bigger models.
  • They assumed that more parameters give better results.

The Chinchilla finding

  • Hoffmann et al. (2022) found something different.
  • For a fixed compute budget, the best results come from smaller models.
  • Those smaller models train on more data.
  • Their scaling laws show how to split a budget between model size and data size.

The authors' point

  • That goal ignores the cost to run the model.
  • This cost is the Inference budget. It matters when you serve a model at scale.
  • For a target quality, the best model is the fastest to run.
  • It is not the fastest to train.
  • A smaller model trained longer is cheaper to run.

A test of that point

  • Hoffmann et al. recommend a 10B model on 200B tokens.
  • The authors find a 7B model keeps improving after 1T tokens.

What this paper does

  • The goal is the best quality at each inference budget.
  • The method is to train on more tokens than is usual.
  • The models are called LLaMA. They range from 7B to 65B parameters.

The results in short

  • LLaMA-13B beats GPT-3 on most benchmarks. It is 10 times smaller.
  • The authors say it can run on a single GPU.
  • They believe this helps more people use and study LLMs.
  • LLaMA-65B is also competitive with Chinchilla and PaLM-540B.

Why public data matters

  • Chinchilla, PaLM and GPT-3 use data that is not public or not documented.
  • Two examples are "Books - 2TB" and "Social media conversations".
  • Some open models exist: OPT, GPT-NeoX, BLOOM and GLM.
  • None of them compete with PaLM-62B or Chinchilla.
  • LLaMA uses only publicly available data. So it is compatible with open-sourcing.

The plan of the paper

  • Next: the changes to the Transformer, and the training method.
  • Then: results on standard benchmarks against other LLMs.
  • Last: biases and toxicity in the models, using recent responsible AI benchmarks.

Overview

  • The method is similar to earlier work (Brown et al., 2020; Chowdhery et al., 2022).
  • It follows the Chinchilla scaling laws.
  • The authors train large transformers on a large amount of text.
  • They use a standard Optimizer.
2.1 Pre-training data
  • The training set mixes several sources that cover many domains.
  • Most sources were used by other LLMs before.
  • The rule: only data that is public and open-source compatible.
DatasetSampling shareEpochsDisk size
CommonCrawl67.0%1.103.3 TB
C415.0%1.06783 GB
Github4.5%0.64328 GB
Wikipedia4.5%2.4583 GB
Books4.5%2.2385 GB
ArXiv2.5%1.0692 GB
StackExchange2.0%1.0378 GB

Table 1: pre-training data

Epochs are for training on 1.4T tokens. Runs on 1T tokens use the same shares.

English CommonCrawl, 67%

  • The authors process five CommonCrawl dumps from 2017 to 2020.
  • They use the CCNet pipeline.
  • It removes repeated text at the line level.
  • It finds the language with a fastText linear classifier and drops non-English pages.
  • It filters low quality text with an n-gram language model.
  • They also trained a linear model to spot pages used as Wikipedia references.
  • They discarded pages that were not classified as references.

C4, 15%

  • Early tests showed that varied CommonCrawl data improves results.
  • So they added the public C4 dataset.
  • C4 also removes repeats and checks the language.
  • Its quality filter uses simple rules.
  • Examples are punctuation marks, or the number of words and sentences.

Github, 4.5%

  • They use the public GitHub dataset on Google BigQuery.
  • They keep only projects with Apache, BSD and MIT licenses.
  • They drop low quality files.
  • The rules use line length or the share of letters and digits.
  • They remove boilerplate, such as headers, with regular expressions.
  • They remove exact file-level repeats.

Wikipedia, 4.5%

  • They add Wikipedia dumps from June to August 2022.
  • They cover 20 languages that use Latin or Cyrillic scripts.
  • These are bg, ca, cs, da, de, en, es, fr, hr, hu, it, nl, pl,
  • pt, ro, ru, sl, sr, sv and uk.
  • They remove hyperlinks, comments and other formatting boilerplate.

Gutenberg and Books3, 4.5%

  • They use two book sets: the Gutenberg Project and Books3 from ThePile.
  • Gutenberg holds books in the public domain.
  • They remove repeats at the book level.
  • They drop books with more than 90% content overlap.

ArXiv, 2.5%

  • They process arXiv LaTeX files to add science text.
  • They remove everything before the first section, and the bibliography.
  • They remove comments from the .tex files.
  • They expand macros that users defined, to make papers more consistent.

Stack Exchange, 2%

  • They use a dump of Stack Exchange, a site of good questions and answers.
  • They keep the 28 largest websites.
  • They remove HTML tags.
  • They sort answers by score, from highest to lowest.

The tokenizer

  • They use the byte-pair encoding algorithm, from SentencePiece.
  • They split all numbers into single digits.
  • For unknown UTF-8 characters, they fall back to bytes.

Total size

  • The full training set holds about 1.4T tokens.
  • Most data is used once in training.
  • Wikipedia and Books are used for about two epochs.
2.2 Architecture
Three changes to the transformerFrom Section 2.2
  1. Start: original transformer
  2. RMSNormNormalize layer inputs
  3. SwiGLUSwap ReLU for SwiGLU
  4. RoPEAdd rotary position codes
  5. LLaMA block

Each change comes from a later model: GPT3, PaLM and GPTNeo.

Overview

  • The network is a Transformer.
  • The authors add changes that other models, such as PaLM, used later.
  • The brackets show where each idea came from.

Change 1

  • Pre-normalization [GPT3].
  • This makes training more stable.
  • They normalize the input of each sub-layer, not the output.
  • They use the RMSNorm function (Zhang and Sennrich, 2019).

Change 2

  • SwiGLU activation [PaLM].
  • It replaces the ReLU non-linearity, to improve performance (Shazeer, 2020).
  • They use a dimension of 2/3 of 4d instead of 4d as in PaLM.

Change 3

  • Rotary Embeddings [GPTNeo].
  • They remove the absolute positional embeddings.
  • They add rotary positional embeddings (RoPE) at each layer (Su et al., 2021).
2.3 Optimizer and model sizes
  • They train with the AdamW optimizer.
  • The settings are beta1 = 0.9 and beta2 = 0.95.
  • They use a cosine learning rate schedule.
  • The final learning rate is 10% of the maximum.
  • Weight decay is 0.1. Gradient clipping is 1.0.
  • They use 2,000 warmup steps.
  • Learning rate and batch size change with model size.
ParamsDimension, heads, layersLearning rate, batch sizeTokens
6.7B4096, 32 heads, 32 layers3.0e-4, 4M1.0T
13.0B5120, 40 heads, 40 layers3.0e-4, 4M1.0T
32.5B6656, 52 heads, 60 layers1.5e-4, 4M1.4T
65.2B8192, 64 heads, 80 layers1.5e-4, 4M1.4T

Table 2: model sizes and training settings

Figure 1: training loss

  • Figure 1 shows training loss against tokens for all four sizes.
  • LLaMA-33B and LLaMA-65B train on 1.4T tokens.
  • The smaller models train on 1.0T tokens.
  • All models use a batch size of 4M tokens.
2.4 Efficient implementation

Faster attention

  • They use an efficient form of causal multi-head attention.
  • It cuts memory and run time. It is in the xformers library.
  • It follows Rabe and Staats (2021). Its backward step uses Dao et al. (2022).
  • It does not store attention weights.
  • It does not compute key and query scores that the causal mask hides.

Less recomputing

  • They cut the work that is recomputed in the backward pass, with checkpointing.
  • They save the costly results, such as outputs of linear layers.
  • To do this, they write the backward function of the layers by hand.
  • They do not use PyTorch autograd for this.

Better use of GPUs

  • They use model and sequence parallelism to cut memory (Korthikanti et al., 2022).
  • They overlap the math with the network traffic between GPUs (all_reduce).

Speed

  • The 65B model processes about 380 tokens per second per GPU.
  • This runs on 2048 A100 GPUs with 80GB of RAM.
  • Training on 1.4T tokens takes about 21 days.

The plan

  • They follow Brown et al. (2020).
  • They test zero-shot and few-shot tasks.
  • They report results on 20 benchmarks.

The two settings

  • Zero-shot: a task text and one test example. The model answers or ranks options.
  • Few-shot: 1 to 64 examples of the task, plus a test example.

The models they compare with

  • Closed models: GPT-3, Gopher, Chinchilla and PaLM.
  • Open models: OPT, GPT-J and GPT-Neo.
  • Section 4 also compares briefly with OPT-IML and Flan-PaLM.

How multiple choice is scored

  • There are free-form generation tasks and multiple choice tasks.
  • For multiple choice, the model picks the option with the highest Likelihood.
  • Usually they follow Gao et al. (2021). They divide by the number of characters.
  • OpenBookQA and BoolQ follow Brown et al. (2020) instead.
  • There the score is P(completion|context) / P(completion|"Answer:").

The test

  • They use eight standard benchmarks.
  • These are BoolQ, PIQA, SIQA, HellaSwag, WinoGrande, ARC easy, ARC challenge and OpenBookQA.
  • They include Cloze and Winograd style tasks, and multiple choice questions.
  • They test in the zero-shot setting.
  • Numbers for other models come from their own papers.

The result

  • LLaMA-65B beats Chinchilla-70B on all reported benchmarks but BoolQ.
  • It beats PaLM-540B everywhere but BoolQ and WinoGrande.
  • LLaMA-13B beats GPT-3 on most benchmarks, though it is 10 times smaller.
LLaMA-13B beats GPT-3 on 4 of these 5 testsFrom Table 3
LLaMA 13BGPT-3 175B
0255075100Zero-shot accuracy (%)BoolQ78.1%60.5%HellaSwag79.2%78.9%ARC-e74.8%68.8%ARC-c52.7%51.4%OBQA56.4%57.6%

Hover, tap or focus a bar to read its exact value.

BenchmarkLLaMA 13B (%)GPT-3 175B (%)
BoolQ78.160.5
HellaSwag79.278.9
ARC-e74.868.8
ARC-c52.751.4
OBQA56.457.6
  • The chart shows 5 of the 8 benchmarks.
  • The tables below have all of them.
Table 3 in full: zero-shot common sense reasoning
ModelBoolQPIQASIQA
GPT-3 175B60.581.0-
Gopher 280B79.381.850.6
Chinchilla 70B83.781.851.3
PaLM 62B84.880.5-
PaLM-cont 62B83.981.4-
PaLM 540B88.082.3-
LLaMA 7B76.579.848.9
LLaMA 13B78.180.150.4
LLaMA 33B83.182.350.4
LLaMA 65B85.382.852.3

Table 3: zero-shot accuracy on common sense reasoning (part 1 of 3)

A dash means the paper has no number.

ModelHellaSwagWinoGrandeARC-e
GPT-3 175B78.970.268.8
Gopher 280B79.270.1-
Chinchilla 70B80.874.9-
PaLM 62B79.777.075.2
PaLM-cont 62B80.677.0-
PaLM 540B83.481.176.6
LLaMA 7B76.170.172.8
LLaMA 13B79.273.074.8
LLaMA 33B82.876.080.0
LLaMA 65B84.277.078.9

Table 3: zero-shot accuracy on common sense reasoning (part 2 of 3)

A dash means the paper has no number.

ModelARC-cOBQA
GPT-3 175B51.457.6
Gopher 280B--
Chinchilla 70B--
PaLM 62B52.550.4
PaLM-cont 62B--
PaLM 540B53.053.4
LLaMA 7B47.657.2
LLaMA 13B52.756.4
LLaMA 33B57.858.6
LLaMA 65B56.060.2

Table 3: zero-shot accuracy on common sense reasoning (part 3 of 3)

A dash means the paper has no number.

The test

  • They test on Natural Questions and TriviaQA.
  • They report exact match in a closed-book setting.
  • The models get no documents that hold the evidence.

The result

  • LLaMA-65B reaches state-of-the-art in zero-shot and few-shot settings.
  • LLaMA-13B is competitive with GPT-3 and Chinchilla, though 5 to 10 times smaller.
  • LLaMA-13B runs on a single V100 GPU for inference.
Table 4 and Table 5 in full
Model0-shot, 1-shot5-shot, 64-shot
GPT-3 175B14.6, 23.0-, 29.9
Gopher 280B10.1, -24.5, 28.2
Chinchilla 70B16.6, -31.5, 35.5
PaLM 8B8.4, 10.6-, 14.6
PaLM 62B18.1, 26.5-, 27.6
PaLM 540B21.2, 29.3-, 39.6
LLaMA 7B16.8, 18.722.0, 26.1
LLaMA 13B20.1, 23.428.1, 31.9
LLaMA 33B24.9, 28.332.9, 36.0
LLaMA 65B23.8, 31.035.0, 39.9

Table 4: NaturalQuestions exact match (0-shot and 1-shot, then 5-shot and 64-shot)

A dash means the paper has no number.

Model0-shot, 1-shot5-shot, 64-shot
Gopher 280B43.5, -57.0, 57.2
Chinchilla 70B55.4, -64.1, 64.6
LLaMA 7B50.0, 53.456.3, 57.6
LLaMA 13B56.6, 60.563.1, 64.0
LLaMA 33B65.1, 67.969.9, 70.4
LLaMA 65B68.2, 71.672.6, 73.0

Table 5: TriviaQA exact match on the filtered dev set (same column pairs)

A dash means the paper has no number.

  • They use the RACE reading comprehension set.
  • It comes from English exams for middle and high school students in China.
  • The setup follows Brown et al. (2020).
  • LLaMA-65B is competitive with PaLM-540B.
  • LLaMA-13B beats GPT-3 by a few percent.
ModelRACE-middleRACE-high
GPT-3 175B58.445.5
PaLM 8B57.942.3
PaLM 62B64.347.5
PaLM 540B68.149.1
LLaMA 7B61.146.9
LLaMA 13B61.647.2
LLaMA 33B64.148.3
LLaMA 65B67.951.6

Table 6: reading comprehension, zero-shot accuracy

The test

  • MATH has 12K middle and high school problems written in LaTeX.
  • GSM8k is a set of middle school math problems.
  • They compare with PaLM and Minerva.
  • Minerva is PaLM fine-tuned on 38.5B tokens from ArXiv and Math Web Pages.
  • Neither PaLM nor LLaMA is fine-tuned on math data.

How majority voting is set

  • Numbers for PaLM and Minerva come from Lewkowycz et al. (2022).
  • maj1@k means: make k samples per problem, then take a majority vote.
  • LLaMA and Minerva 62B use k = 256 for MATH.
  • They use k = 100 for GSM8k.
  • Minerva 540B uses k = 64 for MATH and k = 40 for GSM8k.

The result

  • On GSM8k, LLaMA-65B beats Minerva-62B.
  • It does so without any fine-tuning on math data.
Table 7 in full
ModelMATHMATH +maj1@k
PaLM 8B1.5-
PaLM 62B4.4-
PaLM 540B8.8-
Minerva 8B14.125.4
Minerva 62B27.643.4
Minerva 540B33.650.3
LLaMA 7B2.96.9
LLaMA 13B3.98.8
LLaMA 33B7.115.2
LLaMA 65B10.620.5

Table 7: quantitative reasoning (part 1 of 2)

A dash means the paper has no number.

ModelGSM8kGSM8k +maj1@k
PaLM 8B4.1-
PaLM 62B33.0-
PaLM 540B56.5-
Minerva 8B16.228.4
Minerva 62B52.468.5
Minerva 540B68.578.5
LLaMA 7B11.018.1
LLaMA 13B17.829.3
LLaMA 33B35.653.1
LLaMA 65B50.969.7

Table 7: quantitative reasoning (part 2 of 2)

A dash means the paper has no number.

The test

  • They test on HumanEval and MBPP.
  • The model gets a short description of a program and a few input-output examples.
  • In HumanEval it also gets a function signature.
  • The prompt looks like code, with the description and tests in a docstring.
  • The model must write a Python program that meets the description and passes the tests.

The result

  • They compare with models that are not fine-tuned on code: PaLM and LaMDA.
  • PaLM and LLaMA trained on a similar number of code tokens.
  • For similar size, LLaMA beats LaMDA and PaLM.
  • LLaMA-13B and larger beat LaMDA 137B on both tests.
  • LLaMA-65B beats PaLM 62B, even though PaLM trained longer.

How scores are made

  • pass@1 uses Temperature 0.1.
  • pass@100 and pass@80 use temperature 0.8.
  • They use the method of Chen et al. (2021) for unbiased pass@k estimates.
  • HumanEval runs zero-shot. MBPP uses 3-shot prompts like Austin et al. (2021).

Fine-tuning on code

  • Fine-tuning on code can raise scores.
  • PaLM-Coder raises PaLM pass@1 on HumanEval from 26.2% to 36%.
  • Other code-specific models also beat general models.
  • Fine-tuning on code is out of scope for this paper.
Table 8 in full
ModelHumanEval @1HumanEval @100
LaMDA 137B14.047.3
PaLM 8B3.6*18.7*
PaLM 62B15.946.3*
PaLM-cont 62B23.7-
PaLM 540B26.276.2
LLaMA 7B10.536.5
LLaMA 13B15.852.5
LLaMA 33B21.770.7
LLaMA 65B23.779.3

Table 8: code generation, pass@ score (part 1 of 2)

A star marks values read from figures in Chowdhery et al. (2022).

ModelMBPP @1MBPP @80
LaMDA 137B14.862.4
PaLM 8B5.0*35.7*
PaLM 62B21.463.2*
PaLM-cont 62B31.2-
PaLM 540B36.875.0
LLaMA 7B17.756.2
LLaMA 13B22.064.0
LLaMA 33B30.273.4
LLaMA 65B37.776.8

Table 8: code generation, pass@ score (part 2 of 2)

A star marks values read from figures in Chowdhery et al. (2022).

The test

  • MMLU (Hendrycks et al., 2020) has multiple choice questions.
  • They cover humanities, STEM and social sciences.
  • They test in the 5-shot setting, with the examples the benchmark gives.

The result

  • On average, LLaMA-65B is behind Chinchilla-70B and PaLM-540B by a few percent.
  • This holds across most domains.
LLaMA-65B trails the biggest models on MMLUFrom Table 9
020406080Average five-shot accuracy (%)GPT-3 175B43.9%Gopher 280B60.0%Chinchilla 70B67.5%PaLM 540B69.3%LLaMA 7B35.1%LLaMA 13B46.9%LLaMA 33B57.8%LLaMA 65B63.4%

Hover, tap or focus a bar to read its exact value.

ModelAverage (%)
GPT-3 175B43.9
Gopher 280B60.0
Chinchilla 70B67.5
PaLM 540B69.3
LLaMA 7B35.1
LLaMA 13B46.9
LLaMA 33B57.8
LLaMA 65B63.4

Why it may lag

  • A possible reason: LLaMA used few books and academic papers.
  • ArXiv, Gutenberg and Books3 add up to only 177GB.
  • Gopher, Chinchilla and PaLM trained on up to 2TB of books.
  • That large amount of books may also explain why Gopher beats GPT-3 here.
Table 9 in full
ModelHumanitiesSTEM
GPT-NeoX 20B29.834.9
GPT-3 175B40.836.7
Gopher 280B56.247.4
Chinchilla 70B63.654.9
PaLM 8B25.623.8
PaLM 62B59.541.9
PaLM 540B77.055.6
LLaMA 7B34.030.5
LLaMA 13B45.035.8
LLaMA 33B55.846.0
LLaMA 65B61.851.7

Table 9: MMLU five-shot accuracy (part 1 of 2)

ModelSocial SciencesOtherAverage
GPT-NeoX 20B33.737.733.6
GPT-3 175B50.448.843.9
Gopher 280B71.966.160.0
Chinchilla 70B79.373.967.5
PaLM 8B24.127.825.4
PaLM 62B62.755.853.7
PaLM 540B81.069.669.3
LLaMA 7B38.338.135.1
LLaMA 13B53.853.346.9
LLaMA 33B66.763.457.8
LLaMA 65B72.967.463.4

Table 9: MMLU five-shot accuracy (part 2 of 2)

What they saw

  • They tracked scores on a few question answering and common sense tests during training.
  • Figure 2 shows the results.
  • On most tests, scores improve steadily.
  • They track the training Perplexity (see Figure 1).
  • The exceptions are SIQA and WinoGrande.

The two exceptions

  • On SIQA, scores vary a lot.
  • The authors say this may show the benchmark is not reliable.
  • On WinoGrande, scores do not follow training perplexity well.
  • LLaMA-33B and LLaMA-65B score about the same during training.

What they did

  • A short instruction fine-tuning step quickly raises MMLU scores.
  • The plain LLaMA-65B can already follow basic instructions.
  • A very small amount of fine-tuning improves MMLU and instruction following.
  • This is not the focus of the paper.
  • They ran one experiment with the protocol of Chung et al. (2022).
  • The result is the instruct model LLaMA-I.

The result

  • LLaMA-I (65B) reaches 68.9% on MMLU.
  • It beats other instruction fine-tuned models of moderate size.
  • It is still far from the state of the art: 77.4 for GPT code-davinci-002.
  • Numbers for other models come from their papers (Iyer et al., 2022).
  • Scores for all 57 tasks are in Table 16 of the appendix.
ModelSizeMMLU
OPT30B26.1
GLM120B44.8
PaLM62B55.1
PaLM-cont62B62.8
Chinchilla70B67.5
LLaMA65B63.4
OPT-IML-Max30B43.2
Flan-T5-XXL11B55.1
Flan-PaLM62B59.6
Flan-PaLM-cont62B66.1
LLaMA-I65B68.9

Table 10: instruction finetuning, MMLU 5-shot

The first six rows have no instruction fine-tuning. The last five do.

Why they test

  • LLMs can repeat and increase the biases in their training data.
  • They can also write toxic or offensive text.
  • LLaMA trains on a large share of web data.
  • So the authors test how likely it is to write such content.
  • They test LLaMA-65B on benchmarks for toxic text and stereotype detection.

A limit

  • The authors say these tests are not enough to fully understand the risks.

The test

  • Models can write insults, hate speech or threats.
  • The range of toxic text is very wide, so a full test is hard.
  • RealToxicityPrompts has about 100k prompts that the model must complete.
  • PerspectiveAPI gives each text a toxicity score.
  • The authors do not control the third-party API pipeline.
  • This makes comparison with earlier models hard.

The method

  • They generate greedily for each of the 100k prompts.
  • The score per prompt goes from 0 (not toxic) to 1 (toxic).
  • "Respectful" prompts start with: "Complete the following sentence in a polite, respectful, and unbiased manner:".
  • "Basic" prompts do not have this start.
LLaMA sizeBasicRespectful
7B0.1060.081
13B0.1040.095
33B0.1070.087
65B0.1280.141

Table 11: RealToxicityPrompts, average toxicity score (higher is more toxic)

What they found

  • These scores are comparable with the literature, for example 0.087 for Chinchilla.
  • But the methods differ: sampling, number of prompts and time of the API.
  • Toxicity rises with model size, mostly for Respectful prompts.
  • OPT work saw the same (Zhang et al., 2022).
  • Hoffmann et al. (2022) saw no difference between Chinchilla and Gopher.
  • Gopher is larger but performs worse than Chinchilla.
  • So the link between toxicity and size may hold only within one model family.

The test

  • CrowS-Pairs (Nangia et al., 2020) measures bias in 9 categories.
  • The categories are gender, religion, race/color, sexual orientation, age,
  • nationality, disability, physical appearance and socioeconomic status.
  • Each example has a stereotype sentence and an anti-stereotype sentence.
  • They test zero-shot, using the Perplexity of both sentences.
  • A higher score means more bias.
  • They compare LLaMA-65B with GPT-3 and OPT-175B.
CategoryLLaMAGPT3OPT
Gender70.662.665.7
Religion79.073.368.6
Race/Color57.064.768.6
Sexual orientation81.076.278.6
Age70.164.467.8
Nationality64.261.662.9
Disability66.776.776.7
Physical appearance77.874.676.2
Socioeconomic status71.573.876.2
Average66.667.269.5

Table 12: CrowS-Pairs (higher means more bias)

What they found

  • LLaMA is slightly better than both models on average.
  • It is most biased in religion: +10% against OPT-175B.
  • Age and gender come next.
  • The authors expect the bias comes from CommonCrawl, despite many filters.

The test

  • WinoGender (Rudinger et al., 2018) is a co-reference task.
  • It checks if the pronoun's gender changes the model's co-reference accuracy.
  • Each sentence has three mentions: an occupation, a participant and a pronoun.
  • The pronoun refers to either the occupation or the participant.
  • The goal is to see if the model learned social biases about occupations.

How it works

  • Example: "The nurse notified the patient that his shift would be ending in an hour."
  • Then 'His' refers to. They compare the perplexity of "the nurse" and "the patient".
  • They test 3 pronoun sets: "her/her/she", "his/him/he" and "their/them/someone".

What they found

  • LLaMA-65B is much better with "their/them/someone".
  • It is weaker with "her/her/she" and "his/him/he".
  • Earlier work saw the same. It likely shows gender bias.
  • With gendered pronouns, the model probably uses the majority gender of the job.
  • It does not use the evidence in the sentence.

The gotcha test

  • "Gotcha" cases: the pronoun does not match the majority gender of the occupation.
  • In these cases the occupation is the correct answer.
  • LLaMA-65B makes more errors on gotcha cases.
  • This shows it captures social bias about gender and occupation.
  • The drop exists for both "her/her/she" and "his/him/he".
Table 13 in full
Pronouns7B13B
All66.064.7
her/her/she65.066.7
his/him/he60.862.5
their/them/someone72.165.0
her/her/she (gotcha)64.265.8
his/him/he (gotcha)55.055.8

Table 13: WinoGender co-reference accuracy (part 1 of 2)

Pronouns33B65B
All69.077.5
her/her/she66.778.8
his/him/he62.172.1
their/them/someone78.381.7
her/her/she (gotcha)61.775.0
his/him/he (gotcha)55.863.3

Table 13: WinoGender co-reference accuracy (part 2 of 2)

The test

  • TruthfulQA (Lin et al., 2021) measures truthfulness.
  • That means the ability to tell when a claim is true.
  • "True" means literal truth about the real world.
  • It does not mean claims that are true only inside a belief system.
  • It tests the risk of false claims and misinformation.
  • The questions use diverse styles, cover 38 categories and are adversarial.
ModelSizeTruthfulTruthful*Inf
GPT-31.3B0.310.19
GPT-36B0.220.19
GPT-3175B0.280.25
LLaMA7B0.330.29
LLaMA13B0.470.41
LLaMA33B0.520.48
LLaMA65B0.570.53

Table 14: TruthfulQA, fraction of answers

Specially trained models score the answers through the OpenAI API. The prompt style follows Ouyang et al. (2022). GPT-3 numbers come from the same paper.

What they found

  • LLaMA scores higher than GPT-3 in both columns.
  • But the rate of correct answers is still low.
  • So the model is likely to hallucinate wrong answers.

The method

  • Training used a huge amount of energy and emitted carbon dioxide.
  • They follow Wu et al. (2022) to estimate energy and carbon.
  • Energy in Wh = GPU hours x GPU power use x PUE.
  • They set PUE to 1.1.

A fair comparison

  • Carbon depends on where the data center is.
  • BLOOM uses a grid with 0.057 kg CO2 eq/KWh. That gives 27 tCO2 eq.
  • OPT uses a grid with 0.231 kg CO2 eq/KWh. That gives 82 tCO2 eq.
  • To compare fairly, they assume the same data center for all models.
  • They use the US national average of 0.385 kg CO2 eq/KWh.
  • So: tCO2 eq = MWh x 0.385.

The totals

  • They apply the same formula to OPT and BLOOM.
  • For OPT they assume 34 days on 992 A100-80B GPUs.
  • They used about 2048 A100-80GB GPUs for about 5 months to develop the models.
  • The total is around 2,638 MWh and 1,015 tCO2 eq.
  • They hope the release cuts future carbon, since training is done.
  • Some models are small and run on a single GPU.
The smaller LLaMA models emit far less carbon than OPT-175BFrom Table 15
050100150200Carbon emitted in training (tCO2 eq)OPT-175B137 tCO2 eqBLOOM-175B183 tCO2 eqLLaMA-7B14 tCO2 eqLLaMA-13B23 tCO2 eqLLaMA-33B90 tCO2 eqLLaMA-65B173 tCO2 eq

Hover, tap or focus a bar to read its exact value.

ModelCarbon (tCO2 eq)
OPT-175B137
BLOOM-175B183
LLaMA-7B14
LLaMA-13B23
LLaMA-33B90
LLaMA-65B173
ModelGPU hoursTotal powerCarbon (tCO2 eq)
OPT-175B809,472356 MWh137
BLOOM-175B1,082,880475 MWh183
LLaMA-7B82,43236 MWh14
LLaMA-13B135,16859 MWh23
LLaMA-33B530,432233 MWh90
LLaMA-65B1,022,362449 MWh173

Table 15: carbon footprint of training in the same data center

All use A100-80GB GPUs at 400W (thermal design power for NVLink systems), PUE 1.1 and 0.385 kg CO2 e per KWh.

The task

  • A language model is a probability distribution over text.
  • The task is often framed as next-token prediction.
  • It has long been a core problem in NLP.
  • Turing (1950) proposed the "imitation game" to measure machine intelligence by language.
  • Mahoney (1999) proposed language modeling as a benchmark for AI progress.

Architecture

  • Old models used n-gram counts (Bahl et al., 1983).
  • Smoothing methods helped with rare events (Katz, 1987; Kneser and Ney, 1995).
  • Neural networks then came in.
  • First feed forward ones (Bengio et al., 2000).
  • Then recurrent ones (Elman, 1990; Mikolov et al., 2010) and LSTMs.
  • Transformers improved long range dependencies.
  • See Vaswani et al. (2017), Radford et al. (2018) and Dai et al. (2019).

Scaling: n-gram days

  • Brants et al. (2007): models trained on 2 trillion tokens gave 300 billion n-grams.
  • That helped machine translation. It used a simple smoothing called Stupid Backoff.
  • Heafield et al. (2013) scaled Kneser-Ney smoothing to web-scale data.
  • This gave a 5-gram model on 975 billion tokens from CommonCrawl.
  • The model has 500 billion n-grams (Buck et al., 2014).
  • Chelba et al. (2013) made the One Billion Word benchmark.

Scaling: neural models

  • Jozefowicz et al. (2016) scaled LSTMs to 1 billion parameters.
  • They set a record on Billion Word.
  • Scaled transformers then improved many NLP tasks: BERT, GPT-2, Megatron-LM and T5.
  • GPT-3, with 175 billion parameters, was a major step.
  • It led to Jurassic-1, Megatron-Turing NLG, Gopher, Chinchilla, PaLM, OPT and GLM.

Scaling laws

  • Hestness et al. (2017) and Rosenfeld et al. (2019) found power laws.
  • The laws link model size, data size and performance.
  • Kaplan et al. (2020) derived power laws for transformer language models.
  • Hoffmann et al. (2022) refined them by adapting the learning rate schedule when data grows.
  • Wei et al. (2022) studied how scale changes the abilities of LLMs.

What they showed

  • The authors present a series of openly released language models.
  • They are competitive with state-of-the-art foundation models.
  • LLaMA-13B beats GPT-3 and is more than 10 times smaller.
  • LLaMA-65B is competitive with Chinchilla-70B and PaLM-540B.
  • Unlike earlier work, they reach this using public data only.

Hopes and plans

  • They hope the release speeds up LLM development.
  • They hope it helps efforts to improve robustness and cut toxicity and bias.
  • Like Chung et al. (2022), they saw that instruction fine-tuning gives promising results.
  • They plan to study this further.
  • They plan to release larger models trained on larger corpora.
  • They saw steady gains as they scaled.

The data

  • Natural Questions: they use the test split for open-domain QA. It has 3610 questions.
  • TriviaQA: they use the dev set of the filtered set.
  • GPT-3 and PaLM use the test set of the unfiltered set instead.
  • Its online evaluation server is not available any more.

Scoring and prompts

  • They answer with greedy decoding.
  • They stop at the first line break, final dot or comma to get the answer.
  • An answer is correct if it matches any listed answer after normalization.
  • Normalization lowercases the text and removes articles, punctuation and repeated spaces.
  • In every setting, they start the prompt with "Answer these questions:".
  • Figure 3 shows 1-shot examples for both datasets.

What the table holds

  • Table 16 lists 5-shot MMLU scores for each of the 57 tasks.
  • It covers GPT-3, Gopher, Chinchilla, LLaMA 7B to 65B and LLaMA-I.
  • This card shows the group totals. The task rows are in the original.
Table 16: group totals
GroupGPT-3 175BGopher 280BChinchilla 70B
Humanities40.656.263.6
STEM36.747.454.9
Social Science50.571.979.3
Others49.066.173.9
All43.960.067.6

Table 16: MMLU group totals (part 1 of 3)

GroupLLaMA 7BLLaMA 13BLLaMA 33B
Humanities34.045.055.8
STEM30.535.846.0
Social Science38.353.866.7
Others38.153.363.4
All35.146.957.8

Table 16: MMLU group totals (part 2 of 3)

GroupLLaMA 65BLLaMA-I 65B
Humanities61.867.4
STEM51.756.6
Social Science72.979.2
Others67.472.6
All63.468.9

Table 16: MMLU group totals (part 3 of 3)

  • This appendix shows text that plain LLaMA-65B wrote.
  • The model had no instruction fine-tuning. The prompts are in bold in the paper.
  • The samples include a note on the Fibonacci sequence and a funny recommendation letter.
  • They also include a short Python function and a made-up review of a rap album.
  • They are examples only. They are not scored.

  • This appendix shows text from LLaMA-I.
  • LLaMA-I is LLaMA-65B fine-tuned with the protocol and data of Chung et al. (2022).
  • The samples include a short chat between the sun and Pluto.
  • They also include code for an HTTP request in Javascript, and regular expressions in Python.
  • They are examples only. They are not scored.

Words to know

  • AdamW: A common optimizer for training large models.
  • Batch size: The amount of text used for each update.
  • Bias: Unfair patterns about people that a model learns from data.
  • Byte-pair encoding: A method that splits text into common pieces.
  • Causal attention: Each token looks only at earlier tokens.
  • Checkpointing: Save some results and recompute the rest, to save memory.
  • Closed-book: The model answers with no access to documents.
  • CommonCrawl: A public archive of web pages.
  • Cosine schedule: A learning rate that falls along a smooth curve.
  • Deduplication: Removing repeated copies of the same text.
  • Exact match: An answer counts only if it equals a right answer.
  • Few-shot: The prompt holds a few worked examples of the task.
  • Foundation model: A big model trained on broad text that people adapt to many tasks.
  • GPU: A chip that does the math for training and running models.
  • Gradient clipping: A cap on the size of each update.
  • Greedy decoding: Always pick the most likely next token.
  • Hallucination: A confident answer that is false.
  • Inference: Running a trained model to get answers.
  • Instruction fine-tuning: Extra training on instructions paired with good answers.
  • Large language model: A model trained on huge text that predicts the next token.
  • Learning rate: The size of each update step during training.
  • Likelihood: How probable the model finds a piece of text.
  • maj1@k: Make k answers, then pick the most common one.
  • MMLU: A multiple choice test that spans 57 subjects.
  • Model parallelism: Splitting one model across many GPUs.
  • MWh: Megawatt hour. A unit of energy.
  • Optimizer: The method that updates the model numbers during training.
  • Parameter: A number inside the model that training adjusts. 7B means 7 billion.
  • pass@k: The chance that at least one of k code samples passes the tests.
  • Perplexity: How surprised the model is by text. Lower is better.
  • PUE: Power usage effectiveness. It counts the extra power a data center uses.
  • RMSNorm: A way to rescale numbers in the network to keep training stable.
  • Rotary embeddings: A way to tell the model where each token sits in the text.
  • Scaling laws: Rules that predict model quality from model size and data size.
  • tCO2 eq: Tons of carbon dioxide equivalent. A unit of climate impact.
  • Temperature: A setting for randomness. Low values give safer text.
  • Token: A small piece of text, such as a word part or a digit.
  • Toxicity: Text that is rude, hateful or threatening.
  • Transformer: The standard network design for language models.
  • Warmup: Early steps where the learning rate rises slowly.
  • Weight decay: A penalty that keeps model numbers small.
  • Zero-shot: The prompt describes the task but gives no examples.

Share this paper

LinkedIn (opens in a new tab)X (opens in a new tab)WhatsApp (opens in a new tab)EmailDownload PDFExplainer + original paper (PDF), 1.4 MB

Ask AI about this paper

Stuck on a word or an idea? Ask in plain words. The answer comes from the write-up on this page.

Read the original paper on arXiv: LLaMA: Open and Efficient Foundation Language Models (opens in a new tab)

Jump to

One paper a week, in plain English

Every Monday: the new AI papers worth your time. Short lines, the key number, and what to do with it.

One email a week. Unsubscribe with one click. No spam.