Training

Pinned sources The Llama 3 Herd of Models (arXiv 2407.21783v3), whose results are all for Llama 3.1 · for Llama 3, its model card (meta‑llama/llama3 @ a0940f9) and Meta’s post of April 2024 · no training code is published

  1. Start of training
  2. Initial pre‑trainingat 4K, then 8K15.6T8KNTPWhat trains: all
  3. Long‑context pre‑trainingsix stages, 8K to 128K800B128KNTPWhat trains: allcontext to 128K
  4. Annealinglearning rate to 040M128KNTPWhat trains: all
  5. Pre-trained model
  6. Off this path: Reward model 1 stage
  7. Reward modelin each roundnot statednot statedRMLlama 2’s, no marginnot statednot stated: tokens, context, what trains
  8. Reward model
  9. × 6 roundsRejection sampling and SFTthen DPO, each roundnot stated128KSFTRS and synthetic datanot statednot stated: tokens, what trains
  10. DPOafter SFT, each roundnot statedshort contextDPO+ NLL 0.2not statednot stated: tokens, what trains
  11. Llama 3.1 405B Instruct
  • tokens, log scale
  • NTPdashed: concluded, no source names it
  • not stated by the sources
  • the architecture changes
  • checkpoint
  • checkpoint, weights published
  • a join the sources leave unexplained
  • data from a branch into a stage
  • stages repeated together

Annealing

×

The learning rate goes linearly to zero over the last 40M tokens, on upsampled data of very high quality; the checkpoints are averaged.

Next-token prediction

L=−1T∑i=2T+1log⁡Pi[ti]\mathcal L=-\frac1T\sum_{i=2}^{T+1}\log P_i[t_i]
In words

At every position the model gives each token of the vocabulary a probability of coming next; the loss is the negative logarithm of the probability it gave the token that does come next, averaged over the sequence.

tit_i: the token at position ii; Pi[ti]P_i[t_i]: the probability the model, reading the tokens before it, gave that token; TT: the sequence length.

Tokens
the final 40M
Learning rate
linearly to 0
Averaging
Polyak averaging of checkpoints during annealing gives the final pre-trained model

Why

Annealing on small amounts of high-quality code and mathematics data can boost key benchmarks: with the GSM8k and MATH training sets in the annealing mix, a pre-trained 8B model rose by 24.0% and 6.4% on their validation sets, while for the 405B the gain was negligible. The final annealing data excludes benchmark training sets. Llama 3 paper §3.1.3, p. 6

What the terms meanPolyak averaging
Polyak averaging
The weights of the checkpoints saved over the last part of a run are averaged into one model. Llama 3 paper §3.4.3, p. 15
All settings8
Tokens
The final 40M, as printed
Optimizer steps
About 2 to 3derived40M tokens over Table 4’s 16M tokens per batch is 2.5; the paper does not count the steps.
Learning rate
Linearly annealed to 0
Context
128K
Data
Sources of very high quality upsampled; no training sets of common benchmarks
Averaging
Polyak averaging of checkpoints during annealing gives the final pre-trained model
Objective
Next-token prediction
Trainable
All
Sources5