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. Llama 3, April 2024, predecessor 2 stages
  3. Whether Llama 3.1 continues these checkpoints: not stated
  4. Llama 3 pre‑training15T+ tokens at 8K15T8KNTPWhat trains: all
  5. Llama 3 post‑trainingSFT, RS, PPO, DPOnot statednot statedSFTPPODPOnot statednot stated: tokens, context, what trains
  6. Llama 3 (April 2024)
  7. Initial pre‑trainingat 4K, then 8K15.6T8KNTPWhat trains: all
  8. Long‑context pre‑trainingsix stages, 8K to 128K800B128KNTPWhat trains: allcontext to 128K
  9. Annealinglearning rate to 040M128KNTPWhat trains: all
  10. Pre-trained model
  11. Off this path: Reward model 1 stage
  12. Reward modelin each roundnot statednot statedRMLlama 2’s, no marginnot statednot stated: tokens, context, what trains
  13. Reward model
  14. × 6 roundsRejection sampling and SFTthen DPO, each roundnot stated128KSFTRS and synthetic datanot statednot stated: tokens, what trains
  15. DPOafter SFT, each roundnot statedshort contextDPO+ NLL 0.2not statednot stated: tokens, what trains
  16. 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

Long-context pre-training

×

The context grows in six stages from 8K to 128K, on about 800B tokens. A document mask, which the paper calls important for continued pre-training on very long sequences, keeps attention within a document.

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.

Context
six stages, 8K to 128K
Tokens
approximately 800B
When a stage ends
When short-context evaluations have recovered completely and the model solves “needle in a haystack” tasks up to that length

Not disclosed Lengths of the intermediate stages · Learning rate

What the terms meanNeedle in a haystack
Needle in a haystack
A test that hides one fact at some depth of a long text and asks the model to retrieve it. Llama 3 paper §5.2.6, p. 38
All settings8
Context
Six stages, from 8K to 128K
Tokens
Approximately 800B
When a stage ends
When short-context evaluations have recovered completely and the model solves “needle in a haystack” tasks up to that length
Batch
16M tokens of 131,072-token sequences in the 128K configuration; the tokens per batch are kept constant
RoPE
Llama 3.1’s catalogue entries set use_scaled_rope, Llama 3’s set it False; it scales the frequencies by apply_scaling, a factor of 8 over an original context of 8,192 (llama-models model.py 45–69). The paper mentions no RoPE change for long-context pre-training; its one RoPE setting is the base frequency 500,000 (p. 7), which Llama 3 already has. At which stage the scaling enters is not stated
Attention mask
Attention between documents of one sequence is masked, which the paper calls important in continued pre-training on very long sequences
Objective
Next-token prediction
Trainable
All
Sources11