LLaMA: Train Smaller Models for Longer, on Public Data Only
LLaMA is a family of 7B to 65B foundation models from Meta (2023), trained on public data only. The paper reports LLaMA-13B beating GPT-3 175B on most benchmarks. This post covers the inference-budget argument, data, architecture, training cost and evidence, and which claims need a discount.
On this page
- Why this paper matters
- What the paper contributes
- Background: the training budget and the inference budget
- Data: seven public sources
- Method: three architecture changes and a training setup
- Architecture
- Model sizes and hyperparameters
- Training efficiency
- Checking the numbers yourself
- Experiments: numbers first, then the setup
- Common-sense reasoning
- Closed-book QA and reading comprehension
- Math and code
- MMLU and instruction tuning
- Performance during training
- Bias, toxicity and truthfulness
- Limitations and cautions
- What came after
- What to take away from this paper
- Further reading
- FAQ
Why this paper matters
LLaMA comes from Meta, and version 1 of the paper appeared on arXiv on 27 February 2023. It is a family of base language models with 6.7B, 13.0B, 32.5B and 65.2B parameters according to Table 2 (the text calls them 7B, 13B, 33B and 65B), trained on 1.0T to 1.4T tokens drawn entirely from public sources. Two results stand out: LLaMA-13B outperforms GPT-3 (175B) on most benchmarks with about 1/13 of its parameters, and LLaMA-65B is competitive with the best models of the time, Chinchilla-70B and PaLM-540B. The authors say the models are released to the research community, and that the 13B model can run inference on a single V100 GPU.
A word about what kind of paper this is: it proposes no new architecture and has no ablation study. Its weight comes from three things. First, it makes the difference between the training budget and the inference budget explicit, which gives a reason to train small models for longer. Second, it shows that public data alone is enough for a competitive base model, and it writes the recipe down in unusual detail: data mix, preprocessing, hyperparameters, throughput and energy use are all in the paper. Third, its models became the foundation for a great deal of later fine-tuning and quantization work. The way to read it is as a recipe plus an evaluation report: the recipe can be checked, while the reasons it works have to come from other papers and your own judgment.
What the paper contributes
- Models. Four sizes (6.7B, 13.0B, 32.5B, 65.2B): the 7B and 13B models are trained on 1.0T tokens, the 33B and 65B models on 1.4T tokens.
- Data. A mixture of seven public sources, deduplicated, language-filtered and quality-filtered, about 1.4T tokens.
- Architecture. Three changes to the decoder-only Transformer: Pre-Norm with RMSNorm, SwiGLU and RoPE.
- Training. AdamW, a cosine learning-rate schedule and 4M tokens per batch; a memory-efficient attention implementation and a hand-written backward pass to cut recomputation; about 380 tokens/s/GPU for the 65B model on 2048 A100-80GB GPUs, so 1.4T tokens take about 21 days.
- Evaluation. Zero-shot and few-shot common-sense reasoning, question answering, reading comprehension, math, code and MMLU; one instruction-tuning experiment (LLaMA-I); bias, toxicity, truthfulness and carbon footprint.
Background: the training budget and the inference budget
Kaplan et al. (2020) found that bigger models are better, and the work that followed (GPT-3, Gopher, PaLM and others) went a long way down the road of adding parameters; see the Scaling Laws paper breakdown for the details. Hoffmann et al. (2022, Chinchilla) corrected this: for a given training compute budget, the best choice is not the largest model but one where parameters and training tokens grow in proportion, empirically about 20 tokens per parameter (see scaling laws).
The LLaMA paper points out that this objective only cares about training and ignores the inference budget, which becomes critical once a model is served at scale. Its argument is that, for a target level of performance, the preferred model is not the fastest to train but the fastest at inference: training a large model to reach some performance may be cheaper, but a smaller model trained for longer ends up cheaper to serve. The paper’s example is that Hoffmann et al. recommend training a 10B model on 200B tokens, while the authors found that a 7B model keeps improving even after 1T tokens.
Dividing each model’s training tokens by its parameter count makes the difference plain:
- GPT-3, Gopher and Jurassic were each trained on only about 300B tokens, which is 1.1 to 1.7 tokens per parameter; MT-NLG is at 0.51. They represent the “add parameters” route.
- LLaMA-65B sits almost exactly where Chinchilla does (21 vs 20) and saw the same number of tokens (1.4T). The largest LLaMA is essentially trained at the Chinchilla ratio.
- The small sizes are what is special about LLaMA. LLaMA-7B saw 148 tokens per parameter, about 7 times the Chinchilla ratio. These models are deliberately overtrained, spending extra training compute to get cheaper inference.
In terms of compute, training costs about floating-point operations and each token served costs about , so when the number of tokens served, , is large, the second term of overtakes the first, and shrinking pays off more. The paper gives only the argument. It does not measure inference cost and does not plot quality against total cost, which is the missing step the reader has to supply.
Data: seven public sources
The paper describes each source and its processing in detail. “Tokens at 1.4T” in the table is the sampling share times 1.4T:
| Source | Sampling share | Epochs | Disk size | Tokens at 1.4T | Processing |
|---|---|---|---|---|---|
| English CommonCrawl | 67.0% | 1.10 | 3.3 TB | 938B | Five 2017 to 2020 dumps through the CCNet pipeline: line-level deduplication, fastText language identification to drop non-English pages, an n-gram language model to filter low-quality text; plus a linear classifier that discards pages that do not look like pages cited by Wikipedia |
| C4 | 15.0% | 1.06 | 783 GB | 210B | Also deduplicated and language-identified; quality filtering is heuristic (punctuation, word and sentence counts) |
| GitHub | 4.5% | 0.64 | 328 GB | 63B | Public dataset on Google BigQuery, only projects under Apache, BSD and MIT licenses; heuristic filters on line length and the share of alphanumeric characters, regular expressions to remove boilerplate such as file headers, exact file-level deduplication |
| Wikipedia | 4.5% | 2.45 | 83 GB | 63B | Dumps from June to August 2022 in 20 languages that use Latin or Cyrillic scripts; hyperlinks, comments and other formatting boilerplate removed |
| Books | 4.5% | 2.23 | 85 GB | 63B | Project Gutenberg and the Books3 section of The Pile; book-level deduplication, dropping books with more than 90% content overlap |
| ArXiv | 2.5% | 1.06 | 92 GB | 35B | LaTeX sources: everything before the first section and the bibliography removed, comments removed, user-defined macros expanded inline |
| Stack Exchange | 2.0% | 1.03 | 78 GB | 28B | The 28 largest sites, HTML tags removed, answers sorted by score from highest to lowest |
- Tokenization. BPE through SentencePiece, with numbers split into individual digits and unknown UTF-8 characters falling back to bytes; see tokenizers and embeddings. The paper does not state the vocabulary size in its text. The released implementation uses 32,000, which the check below relies on, and the parameter counts it produces match Table 2.
- Epochs. Most data is used once; Wikipedia and books are used for about two epochs (2.45 and 2.23).
- Mostly English. Only English pages are kept from CommonCrawl, and although Wikipedia covers 20 languages it is only 4.5% of the mix.
- Data choices show up in the scores. The paper’s own explanation is that books and papers (ArXiv, Gutenberg, Books3) add up to only 177 GB, while Gopher, Chinchilla and PaLM used up to 2 TB of books, which may be why LLaMA trails on MMLU. This is the authors’ conjecture; the paper runs no controlled experiment to test it.
Method: three architecture changes and a training setup
Architecture
LLaMA is a decoder-only Transformer, and the paper lists three changes, with the authors’ sources of inspiration in brackets:
| Change | What it does | Deeper coverage |
|---|---|---|
| Pre-Norm and RMSNorm (GPT-3) | Normalize the input of each sublayer instead of the output; the normalization function is RMSNorm | The Transformer block |
| SwiGLU (PaLM) | Replace ReLU with SwiGLU, with a hidden size of instead of PaLM’s | Modern LLM architecture |
| RoPE (GPTNeo) | Remove absolute position embeddings and add rotary position embeddings to the queries and keys in every layer | Positional encoding |
RMSNorm (Zhang and Sennrich, 2019) divides by the root mean square of the features and does not subtract the mean:
The SwiGLU feed-forward network (Shazeer, 2020) has three matrices, with and of shape and of shape :
The hidden size is chosen to keep the parameter count unchanged: three matrices hold parameters, the same as the two matrices of a plain FFN, . The official implementation also rounds up to a multiple of 256, so gives 11008 rather than 10922.
The paper runs no ablation, so it does not say what each of the three changes buys. It is more accurate to read them as “a sound configuration for the time” than as “these three things make the model stronger”.
Model sizes and hyperparameters
| Model | Parameters (Table 2) | Heads | Layers | FFN hidden size | Learning rate | Batch | Training tokens | |
|---|---|---|---|---|---|---|---|---|
| 7B | 6.7B | 4096 | 32 | 32 | 11008 | 3.0e-4 | 4M | 1.0T |
| 13B | 13.0B | 5120 | 40 | 40 | 13824 | 3.0e-4 | 4M | 1.0T |
| 33B | 32.5B | 6656 | 52 | 60 | 17920 | 1.5e-4 | 4M | 1.4T |
| 65B | 65.2B | 8192 | 64 | 80 | 22016 | 1.5e-4 | 4M | 1.4T |
Everything else is shared by all sizes: AdamW with and ; cosine learning-rate decay to 10% of the peak; weight decay 0.1; gradient clipping at 1.0; 2,000 warmup steps. The FFN hidden sizes in the table follow the rule above; the paper does not list them.
Training efficiency
The paper uses several engineering optimizations to reach about 380 tokens/s/GPU for the 65B model on 2048 A100-80GB GPUs:
- Memory-efficient causal attention. The implementation in xformers (inspired by Rabe and Staats, 2021, with a backward pass from FlashAttention) does not store the attention weights and does not compute the query-key scores that the causal mask would hide. See the FlashAttention paper breakdown for the idea.
- Less recomputation. Expensive activations, such as the outputs of linear layers, are saved, which required writing the backward pass of the Transformer layers by hand instead of relying on PyTorch autograd.
- Parallelism and overlap. Model and sequence parallelism as in Korthikanti et al. (2022), with the computation of activations overlapped with the all_reduce communication between GPUs as far as possible. For background see compute and memory and distributed training.
Checking the numbers yourself
Tables 2 and 15 give enough information to check the parameter counts, the training compute and the energy use, and to estimate model FLOPs utilization (MFU) with fewer than 40 lines of code. It runs on a CPU with Python 3.14 and has no randomness.
# Table 2 configs (hidden size d, layers, training tokens), Table 15 GPU hours
CONFIG = {
"7B": (4096, 32, 1.0e12, 82_432),
"13B": (5120, 40, 1.0e12, 135_168),
"33B": (6656, 60, 1.4e12, 530_432),
"65B": (8192, 80, 1.4e12, 1_022_362),
}
V = 32_000 # SentencePiece vocabulary size
A100_PEAK = 312e12 # A100 dense BF16 peak, FLOP/s
def ffn_dim(d):
"""SwiGLU hidden size: 2/3 of 4d, rounded up to a multiple of 256."""
return 256 * -(-(8 * d // 3) // 256)
def n_params(d, layers):
attn = 4 * d * d # Wq, Wk, Wv, Wo, no biases
ffn = 3 * d * ffn_dim(d) # SwiGLU has three matrices
per_layer = attn + ffn + 2 * d # plus two RMSNorm scale vectors
return layers * per_layer + 2 * V * d + d # input and output embeddings
print("size params tok/param 6ND MFU MWh tCO2")
total_mwh = 0
for name, (d, layers, tokens, gpu_h) in CONFIG.items():
n = n_params(d, layers)
flops = 6 * n * tokens
mfu = flops / (gpu_h * 3600 * A100_PEAK)
mwh = gpu_h * 400 * 1.1 / 1e6 # 400 W per GPU, PUE 1.1
total_mwh += mwh
print(f"{name:>4} {n / 1e9:6.2f}B {tokens / n:9.0f} {flops:9.2e} "
f"{mfu:5.0%} {mwh:5.0f} {mwh * 0.385:5.0f}")
days = 1.4e12 / (380 * 2048) / 86400 # 380 tokens/s/GPU on 2048 GPUs
print(f"65B needs about {days:.1f} days for 1.4T tokens")
print(f"Four final runs: {total_mwh:.0f} MWh, "
f"{total_mwh / 2638:.0%} of the paper's 2,638 MWh")
Output:
size params tok/param 6ND MFU MWh tCO2
7B 6.74B 148 4.04e+22 44% 36 14
13B 13.02B 77 7.81e+22 51% 59 23
33B 32.53B 43 2.73e+23 46% 233 90
65B 65.29B 21 5.48e+23 48% 450 173
65B needs about 20.8 days for 1.4T tokens
Four final runs: 779 MWh, 30% of the paper's 2,638 MWh
Compared with the paper, line by line:
- The parameter counts match Table 2. 6.74B, 13.02B, 32.53B and 65.29B against 6.7B, 13.0B, 32.5B and 65.2B (65.29B is written as 65.2B in the table). It also confirms that a 32,000-token vocabulary with separate input and output embeddings is the right assumption.
- Tokens per parameter. 148, 77, 43 and 21, as in the figure above.
- MFU lands between 44% and 51%. Compute is estimated as , the denominator is the A100’s dense BF16 peak (312 TFLOP/s), and the GPU hours come from Table 15. leaves out the attention-score computation, so the true utilization is a little higher. The range is in the same ballpark as the 46.2% reported for PaLM 540B. The paper does not say whether the GPU hours include restarts after failures.
- Training time. At 380 tokens/s/GPU on 2048 GPUs, 1.4T tokens take 20.8 days, matching the paper’s “approximately 21 days”.
- Energy and emissions. With the paper’s assumptions (400 W per GPU, a PUE of 1.1, 0.385 kg CO2e per kWh), the computed 36, 59, 233 and 450 MWh agree with Table 15 (for 65B the table says 449; the exact value, 449.8, rounds to 450), which is 14, 23, 90 and 173 tonnes of CO2 equivalent. For comparison, Table 15 lists OPT-175B at 356 MWh and 137 tonnes and BLOOM-175B at 475 MWh and 183 tonnes.
- The final runs are only about 30% of the project’s electricity. The four final runs total 779 MWh, while the paper says developing the models took about 2048 A100-80GB GPUs for about 5 months, around 2,638 MWh and 1,015 tonnes of CO2 equivalent. The rest went to experiments, failed attempts and evaluation. Reporting only the final run understates the cost of a model.
Experiments: numbers first, then the setup
The paper evaluates on 20 benchmarks in the zero-shot and few-shot settings. Multiple-choice questions are answered by picking the option with the highest likelihood given the context, normalized by the number of characters in the option (OpenBookQA and BoolQ are the exceptions, normalized by the option’s likelihood after “Answer:”). The numbers for the other models (GPT-3, Gopher, Chinchilla, PaLM) are copied from their own papers and were not re-run under one prompt.
Common-sense reasoning
Table 3 is zero-shot, and each cell is accuracy in percent:
| Model | BoolQ | PIQA | SIQA | HellaSwag | WinoGrande | ARC-e | ARC-c | OBQA |
|---|---|---|---|---|---|---|---|---|
| GPT-3 175B | 60.5 | 81.0 | – | 78.9 | 70.2 | 68.8 | 51.4 | 57.6 |
| Chinchilla 70B | 83.7 | 81.8 | 51.3 | 80.8 | 74.9 | – | – | – |
| PaLM 540B | 88.0 | 82.3 | – | 83.4 | 81.1 | 76.6 | 53.0 | 53.4 |
| LLaMA 7B | 76.5 | 79.8 | 48.9 | 76.1 | 70.1 | 72.8 | 47.6 | 57.2 |
| LLaMA 13B | 78.1 | 80.1 | 50.4 | 79.2 | 73.0 | 74.8 | 52.7 | 56.4 |
| LLaMA 33B | 83.1 | 82.3 | 50.4 | 82.8 | 76.0 | 80.0 | 57.8 | 58.6 |
| LLaMA 65B | 85.3 | 82.8 | 52.3 | 84.2 | 77.0 | 78.9 | 56.0 | 60.2 |
The paper’s text has three sentences summarizing this table, and the math section has one more about GSM8k. Here they are checked by typing the numbers into code:
# Table 3: zero-shot common-sense reasoning (None: not reported in the paper)
TASKS = ["BoolQ", "PIQA", "SIQA", "HellaSwag", "WinoGrande",
"ARC-e", "ARC-c", "OBQA"]
T3 = {
"GPT-3 175B": [60.5, 81.0, None, 78.9, 70.2, 68.8, 51.4, 57.6],
"Chinchilla 70B": [83.7, 81.8, 51.3, 80.8, 74.9, None, None, None],
"PaLM 540B": [88.0, 82.3, None, 83.4, 81.1, 76.6, 53.0, 53.4],
"LLaMA 13B": [78.1, 80.1, 50.4, 79.2, 73.0, 74.8, 52.7, 56.4],
"LLaMA 65B": [85.3, 82.8, 52.3, 84.2, 77.0, 78.9, 56.0, 60.2],
}
def compare(a, b):
pairs = [(t, x, y) for t, x, y in zip(TASKS, T3[a], T3[b])
if x is not None and y is not None]
lost = [t for t, x, y in pairs if x <= y]
print(f"{a} vs {b}: {len(pairs)} comparable, "
f"wins {len(pairs) - len(lost)}, no win: {lost or 'none'}")
compare("LLaMA 13B", "GPT-3 175B")
compare("LLaMA 65B", "Chinchilla 70B")
compare("LLaMA 65B", "PaLM 540B")
# Table 7: GSM8k accuracy (single decode, majority vote)
GSM8K = {"LLaMA 65B": (50.9, 69.7), "Minerva 62B": (52.4, 68.5)}
for i, mode in enumerate(["single decode", "majority vote"]):
a, b = GSM8K["LLaMA 65B"][i], GSM8K["Minerva 62B"][i]
print(f"GSM8k, {mode}: LLaMA 65B {a}, Minerva 62B {b}, "
f"{'ahead' if a > b else 'behind'}")
Output:
LLaMA 13B vs GPT-3 175B: 7 comparable, wins 5, no win: ['PIQA', 'OBQA']
LLaMA 65B vs Chinchilla 70B: 5 comparable, wins 5, no win: none
LLaMA 65B vs PaLM 540B: 7 comparable, wins 5, no win: ['BoolQ', 'WinoGrande']
GSM8k, single decode: LLaMA 65B 50.9, Minerva 62B 52.4, behind
GSM8k, majority vote: LLaMA 65B 69.7, Minerva 62B 68.5, ahead
- “LLaMA-13B outperforms GPT-3 on most benchmarks” holds, but not on all. It wins 5 of the 7 comparable tasks and is slightly behind on PIQA and OpenBookQA.
- “LLaMA-65B outperforms Chinchilla-70B on all reported benchmarks but BoolQ” does not match the table. That is what the text says, but the 85.3 for BoolQ in Table 3 is also higher than Chinchilla’s 83.7, so LLaMA-65B is ahead on all 5 comparable tasks. The table is what counts, and the exception in the text looks like a slip.
- “LLaMA-65B surpasses PaLM-540B everywhere except BoolQ and WinoGrande” holds. It wins 5 of 7.
- “Outperforms Minerva-62B on GSM8k” holds only with majority voting. With a single decode it is 50.9 against 52.4, behind; with majority voting it is 69.7 against 68.5, ahead. Minerva is PaLM further trained on 38.5B tokens of math and ArXiv web pages, while LLaMA was not trained specially on math data, so this comparison is not unfair to LLaMA, but check which column a claim refers to.
Closed-book QA and reading comprehension
NaturalQuestions and TriviaQA are closed-book question answering (the model gets no documents), scored by exact match in percent. Tables 4 and 5 have 0-, 1-, 5- and 64-shot columns; only the 0-shot and 64-shot columns are shown here:
| Model | NaturalQuestions 0-shot | NaturalQuestions 64-shot | TriviaQA 0-shot | TriviaQA 64-shot |
|---|---|---|---|---|
| GPT-3 175B | 14.6 | 29.9 | – | – |
| Gopher 280B | 10.1 | 28.2 | 43.5 | 57.2 |
| Chinchilla 70B | 16.6 | 35.5 | 55.4 | 64.6 |
| PaLM 540B | 21.2 | 39.6 | – | – |
| LLaMA 7B | 16.8 | 26.1 | 50.0 | 57.6 |
| LLaMA 13B | 20.1 | 31.9 | 56.6 | 64.0 |
| LLaMA 33B | 24.9 | 36.0 | 65.1 | 70.4 |
| LLaMA 65B | 23.8 | 39.9 | 68.2 | 73.0 |
- LLaMA-65B is the highest in the table on both TriviaQA columns and on NaturalQuestions 64-shot. Its 39.9 on NaturalQuestions 64-shot is only 0.3 above PaLM-540B’s 39.6, and at zero-shot LLaMA-33B (24.9) beats the 65B model (23.8), so do not treat a single-cell gap as a stable pattern.
- On TriviaQA, LLaMA-13B is already close to Chinchilla. 56.6 against 55.4 at zero-shot and 64.0 against 64.6 at 64-shot. The authors say it runs on a single V100: at 2 bytes per parameter in fp16, 13.02B parameters take 26.0 GB, which fits a 32 GB V100 but not a 16 GB one.
- Reading comprehension (RACE, zero-shot). In Table 6 LLaMA-65B scores 67.9 on the middle-school questions and 51.6 on the high-school ones, against 68.1 and 49.1 for PaLM-540B and 58.4 and 45.5 for GPT-3. The paper says 65B is competitive with PaLM-540B, and LLaMA-13B is 3.2 and 1.7 points above GPT-3.
Math and code
Math uses MATH and GSM8k, and code uses HumanEval and MBPP (pass@1, sampling temperature 0.1). Tables 7 and 8 are excerpted below, in percent:
| Model | MATH | MATH, majority vote | GSM8k | GSM8k, majority vote | HumanEval pass@1 | MBPP pass@1 |
|---|---|---|---|---|---|---|
| PaLM 62B | 4.4 | – | 33.0 | – | 15.9 | 21.4 |
| PaLM 540B | 8.8 | – | 56.5 | – | 26.2 | 36.8 |
| Minerva 62B | 27.6 | 43.4 | 52.4 | 68.5 | – | – |
| LaMDA 137B | – | – | – | – | 14.0 | 14.8 |
| LLaMA 7B | 2.9 | 6.9 | 11.0 | 18.1 | 10.5 | 17.7 |
| LLaMA 13B | 3.9 | 8.8 | 17.8 | 29.3 | 15.8 | 22.0 |
| LLaMA 33B | 7.1 | 15.2 | 35.6 | 53.1 | 21.7 | 30.2 |
| LLaMA 65B | 10.6 | 20.5 | 50.9 | 69.7 | 23.7 | 37.7 |
- On math, a model trained specifically for it is far ahead. On MATH, Minerva 62B scores 27.6 and LLaMA-65B only 10.6; majority voting samples times on MATH and times on GSM8k.
- On code, LLaMA is near the top among general-purpose models of similar size. LLaMA-13B gets 15.8 on HumanEval and 22.0 on MBPP, both above the 137B LaMDA (14.0 and 14.8); LLaMA-65B is above PaLM-62B (HumanEval 23.7 vs 15.9, MBPP 37.7 vs 21.4) and close to PaLM-540B (HumanEval 23.7 vs 26.2, MBPP 37.7 vs 36.8). The paper notes that fine-tuning on code helps further (PaLM-Coder raises PaLM’s HumanEval pass@1 from 26.2% to 36%), which is out of scope here.
MMLU and instruction tuning
MMLU is a multiple-choice benchmark covering the humanities, STEM, social sciences and other fields, evaluated five-shot (Table 9, percent):
| Model | Humanities | STEM | Social sciences | Other | Average |
|---|---|---|---|---|---|
| GPT-3 175B | 40.8 | 36.7 | 50.4 | 48.8 | 43.9 |
| Chinchilla 70B | 63.6 | 54.9 | 79.3 | 73.9 | 67.5 |
| PaLM 540B | 77.0 | 55.6 | 81.0 | 69.6 | 69.3 |
| LLaMA 7B | 34.0 | 30.5 | 38.3 | 38.1 | 35.1 |
| LLaMA 13B | 45.0 | 35.8 | 53.8 | 53.3 | 46.9 |
| LLaMA 33B | 55.8 | 46.0 | 66.7 | 63.4 | 57.8 |
| LLaMA 65B | 61.8 | 51.7 | 72.9 | 67.4 | 63.4 |
This is where LLaMA does not lead: 65B averages 63.4, about 4 points behind Chinchilla-70B and about 6 behind PaLM-540B. The paper attributes this to the small amount of book and paper data (see above), and suggests that the large amount of books may also explain why Gopher is so much stronger than GPT-3 on this benchmark.
Section 4 of the paper runs one instruction-tuning experiment (a single experiment, following the Flan protocol of Chung et al., 2022) and calls the result LLaMA-I. In Table 10, LLaMA-65B’s MMLU rises from 63.4 to 68.9 for LLaMA-I, above Flan-PaLM-cont 62B at 66.1 and OPT-IML-Max 30B at 43.2, but still well below GPT code-davinci-002 at 77.4 (a number taken from the OPT-IML paper). So a small amount of instruction data clearly helps on MMLU, which the LLaMA paper treats only as a preview of future work.
Performance during training
Figure 2 of the paper tracks question-answering and common-sense benchmarks during training: on most benchmarks the scores rise steadily and correlate with training perplexity, with SIQA and WinoGrande as the exceptions. SIQA shows large variance, which the authors take as a sign that the benchmark may be unreliable, and on WinoGrande the 33B and 65B models perform similarly and do not track training perplexity. Using a single small benchmark as the only evidence of capability is risky.
Bias, toxicity and truthfulness
The paper checks LLaMA-65B (and some smaller sizes) on four benchmarks. The authors stress that these evaluations are not enough to fully understand the risks.
| Benchmark | Result | How to read it |
|---|---|---|
| RealToxicityPrompts (higher is more toxic) | “Basic” prompts: 7B 0.106, 13B 0.104, 33B 0.107, 65B 0.128; “respectful” prompts: 0.081, 0.095, 0.087, 0.141 | Toxicity rises with size, and the respectful prompt does not help at 65B (0.141 is higher than the basic prompt’s 0.128); scores come from a third-party API, so they are not strictly comparable with other papers |
| CrowS-Pairs (higher is more biased) | Average 66.6, against 67.2 for GPT-3 and 69.5 for OPT-175B; religion 79.0, about 10 points above OPT-175B’s 68.6 | Slightly better overall, but bias is clear for religion, age and gender; the authors expect it to come from CommonCrawl |
| WinoGender (coreference accuracy, 65B) | All 77.5; their/them/someone 81.7, her/her/she 78.8, his/him/he 72.1; on “gotcha” cases her 75.0 and his 63.3 | More accurate with the neutral pronoun, and more errors where the pronoun does not match the majority gender of the occupation, which suggests the model uses occupational stereotypes |
| TruthfulQA (truthful / truthful and informative) | 65B 0.57 / 0.53, GPT-3 175B 0.28 / 0.25 | Higher than GPT-3, but the rate of correct answers is still low, so the model is likely to make up wrong answers |
Limitations and cautions
- No ablation studies. The paper does not test the individual contributions of RMSNorm, SwiGLU, RoPE or the data mix, so “LLaMA is strong because of these changes” is not a conclusion of the paper.
- Comparison numbers are copied from other papers. The results for GPT-3, Gopher, Chinchilla and PaLM come from their own papers, with different prompts, shot counts and evaluation details, so gaps within a point or two should not be read as wins. The text also contains a statement that disagrees with the table (the BoolQ item above).
- Inference cost is not measured. “A smaller model trained for longer is cheaper to serve” is an argument, not a measured result; the paper gives no speed or cost comparison.
- Limited reproducibility. The paper lists the data sources and processing steps but does not release the processed dataset. The models were released to the research community, and the terms of use are those of the license at release, which is not the same as an open license that allows commercial use.
- The MMLU explanation is a conjecture. The idea that too little book data is the reason was not tested by a controlled experiment.
- One instruction-tuning experiment. The LLaMA-I result is only a directional signal.
- Limited safety evaluation. The bias and toxicity checks cover a handful of benchmarks, and the authors admit they are not sufficient to fully understand the risks.
What came after
- The fine-tuning and quantization ecosystem. Many projects built directly on LLaMA: Alpaca fine-tuned LLaMA 7B on 52K instructions generated by
text-davinci-003(see SFT data construction and quality control for the problems with that data), and QLoRA (Dettmers et al., 2023) notes that ordinary 16-bit fine-tuning of LLaMA 65B needs more than 780 GB of GPU memory while QLoRA brings it under 48 GB; see LoRA fine-tuning in practice for how. - “Train for longer” was pushed further. The Llama 3 paper (2024) says that its scaling laws suggest the flagship model (405B parameters, 15.6T tokens) is approximately compute-optimal in size for its training budget, but that the smaller models are trained for much longer than is compute-optimal and perform better than compute-optimal models at the same inference budget. That is the idea LLaMA introduced; see scaling laws for more.
- The recipe was reused. Pre-Norm, RMSNorm, SwiGLU and RoPE became common settings for open models (see modern LLM architecture), and later models such as Mixtral and DeepSeek-V3 keep modifying that base configuration.
What to take away from this paper
- Choose model size by the total cost of training plus inference. The optimum for training compute alone gives a model that is too large; LLaMA’s small models spend more tokens to get cheaper inference.
- Tokens per parameter is a useful diagnostic. 148, 77, 43 and 21 against about 1.7 for GPT-3 shows the difference in training route at a glance.
- Public data plus careful preprocessing is enough. Deduplication, language identification, quality filtering and license filtering each have a concrete recipe, and data quality matters more than whether the source is exotic.
- The three architecture changes are sound rather than novel. Pre-Norm with RMSNorm, SwiGLU and RoPE all come from earlier work and the paper has no ablation, so be careful about attributing the gains.
- Read conclusions against the tables. The text has a claim that disagrees with a table, the comparison numbers are copied from elsewhere, and small gaps on a single benchmark are unstable; checking the numbers yourself is more reliable than trusting one sentence.
Further reading
- The paper: LLaMA: Open and Efficient Foundation Language Models.
- The trade-off between training tokens and parameters: the Scaling Laws for Neural Language Models breakdown and Training Compute-Optimal Large Language Models (Chinchilla).
- The efficient implementation the paper uses: the FlashAttention breakdown.
- Fine-tuning on top of LLaMA: the LoRA breakdown and QLoRA.
- Later models on the same configuration: the Mixtral breakdown, the DeepSeek-V3 breakdown and The Llama 3 Herd of Models.
FAQ
- What is the core idea of LLaMA?
- The paper puts the inference budget into the choice of model size. For a target level of quality, the best model is not the one that is fastest to train but the one that is fastest to serve, so a smaller model should be trained for longer. LLaMA's 7B and 13B models saw 1.0T tokens and the 33B and 65B models saw 1.4T tokens, which works out to 148, 77, 43 and 21 tokens per parameter, against about 1.7 for GPT-3. Two other traits are that it uses only public data and that it makes three changes to the Transformer, namely Pre-Norm with RMSNorm, SwiGLU and RoPE.
- Is LLaMA-13B really better than GPT-3 175B?
- On most of the paper's benchmarks, yes, but not on all of them. Table 3 has 7 zero-shot common-sense tasks where both models report a score, and LLaMA-13B wins 5, falling slightly behind on PIQA (80.1 vs 81.0) and OpenBookQA (56.4 vs 57.6). On NaturalQuestions zero-shot it scores 20.1 against 14.6, and on five-shot MMLU 46.9 against 43.9. The GPT-3 numbers are copied from its own paper, with different prompts and evaluation protocols, so small gaps should not be over-read.
- What data was LLaMA trained on, and can it be reproduced?
- Seven public sources. English CommonCrawl is 67%, C4 is 15%, GitHub, Wikipedia and books are 4.5% each, ArXiv is 2.5% and Stack Exchange is 2%, about 1.4T tokens in total. The paper describes the preprocessing of every source (deduplication, language identification, quality filtering, license filtering) but does not release the processed dataset, so you can rebuild a similar corpus by following the steps, but not a token-identical one.
- How does LLaMA differ from the original Transformer?
- The paper lists three changes. Normalization moves to the input of each sublayer and uses RMSNorm. SwiGLU replaces ReLU, with a hidden size of two thirds of 4d so that three matrices have the same parameter count as the original two. Absolute position embeddings are removed, and rotary position embeddings (RoPE) are added to the queries and keys in every layer. The paper has no ablation study, so it does not say how much each change contributes.
- How much compute and electricity did training LLaMA-65B take?
- The paper reports about 380 tokens per second per GPU on 2048 A100-80GB GPUs, so 1.4T tokens take about 21 days; Table 15 lists 1,022,362 GPU hours, which under the paper's assumptions is about 449 MWh and 173 tonnes of CO2 equivalent. By the $6ND$ approximation the total is about 5.5×10²³ FLOPs, which corresponds to a model FLOPs utilization of about 48% (our estimate, not a number from the paper).