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
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.
: the token at position ; : the probability the model, reading the tokens before it, gave that token; : the sequence length.
Next-token prediction as drawn for DeepSeek‑V3.2‑Exp →That plate also draws multi-token prediction, fill-in-the-middle and DeepSeek-V3’s sequence-wise balance loss.
- 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
Architecture at this stageThe context grows to 128K. The paper mentions no RoPE change for this stage; the released Llama 3.1 scales its RoPE frequencies (catalogue use_scaled_rope; llama-models model.py 45–69), at a stage the paper does not name.
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
- Llama 3 paper, p. 14Context, Tokens, When a stage ends, Objective, Trainable
- Llama 3 paper, p. 10Batch
- models/sku_list.py, line 245RoPE
- models/sku_list.py, line 263RoPE
- models/sku_list.py, line 204RoPE
- models/sku_list.py, line 222RoPE
- models/llama3/model.py, lines 45–69RoPE
- Llama 3 paper, p. 7RoPE
- Llama 3 paper, pp. 6–7Attention mask
- Llama 3 paper, p. 3Objective
- Llama 3 paper, p. 1Trainable