Training stages as capability interventions
Pretraining establishes broad capabilities by fitting predictions across a corpus. Subsequent training inherits learned parameters rather than learning everything again from an initial, untrained state.
Midtraining means capability-focused continuation of an existing model. The terminology varies: the GLM-4.5 report includes instruction data in midtraining. A stage’s actual data, targets and updates define its operation more precisely than its name.
Training and inference produce different artifacts
The same learned state supports updates or request-conditioned computation.
Read the diagram as text
- Starting checkpoint.
- Corpus.
- Objective, schedules, budget.
- Training.
- New checkpoint.
- Request context.
- Inference.
- Output.
- Starting checkpoint → Training: Data: initial weights.
- Corpus → Training: Data: examples.
- Objective, schedules, budget → Training: Control: update policy.
- Training → New checkpoint: Data: updated state.
- Starting checkpoint → Inference: Data: fixed weights.
- Request context → Inference: Data: input.
- Inference → Output: Data: prediction.
| Stage specification | What it identifies |
|---|---|
| Starting checkpoint | Saved learned state, potentially accompanied by state needed to continue training. |
| Examples and objective | The information supplied and the predictions rewarded by training. |
| Exposure and budget | How much training occurs, with which model size and resource allocation. |
Supplying request context ordinarily changes the input computation without updating model parameters. Training changes learned state. A request’s cached intermediate representations are also distinct from newly learned weights.
Behavioral training uses demonstrations or feedback to shape responses. Its procedures belong in Post-training and Alignment.
Prediction objectives and transferable learning
An objective measures prediction error; optimization changes parameters to reduce it. Better fit on training examples does not establish performance on new cases. Generalization and independent assessment explains that boundary.
Self-supervision constructs prediction targets from the data itself.
One document, different prediction problems
ExampleVisible information and scored targets depend on construction.
Read the diagram as text
- red fox sleeps ..
- Visible: red fox.
- Target: sleeps.
- Visible: red [MASK] sleeps .. Selected tokens are not always masked.
- Selected target: fox.
- Visible: red S0 .. S0 marks the removed span.
- Target: S0 fox sleeps S1. S1 is the final sentinel.
- red fox sleeps . → Visible: red fox: Retain prefix.
- Visible: red fox → Target: sleeps: Predict continuation.
- red fox sleeps . → Visible: red [MASK] sleeps .: Corrupt selected token.
- Visible: red [MASK] sleeps . → Selected target: fox: Predict original.
- red fox sleeps . → Visible: red S0 .: Remove span.
- Visible: red S0 . → Target: S0 fox sleeps S1: Predict span sequence.
For causal prediction, future tokens must remain hidden when predicting them. Cross-entropy penalizes insufficient probability on the recorded target; Shifted targets and parallel sequence training supplies the computational detail.
Transfer reuses learned parameters for another task. Shared language or domain structure can make those parameters useful across tasks, but fitting one distribution does not establish competence on unfamiliar inputs. Factual correctness, instruction following and task success require their own evidence.
Corpus composition and capability coverage
A corpus is the collection available for training. A data mixture combines corpus components using specified sampling weights.
Useful coverage depends on the intended tasks. Correct but repetitive examples can offer little additional information; varied but irrelevant examples can consume the budget without supporting the desired capabilities. Difficulty, information density and diversity must be judged together.
| Component | Intended experience | Verification need |
|---|---|---|
| Prose and developer discussions | Explanations and connections between language and code | Application beyond familiar wording |
| Source code | Programming structures and completion patterns | Correctness on held-out code tasks |
| Multilingual text | Language-specific usage and broader linguistic coverage | Separate performance in intended languages |
| Engineering documents | Domain terminology and recurring technical relationships | Unseen domain inputs and multiple task types |
Accessible material may omit the intended users or workflows; coverage and sampling explains that mismatch. Permitted use also constrains selection. Replit’s code-training example explicitly combined source selection with licensing restrictions; collection and provenance covers the underlying records.
Generated material is another identifiable corpus component, not automatically independent coverage. Recipes differ on its role; Synthetic Data covers generation and verification.
From documents to scored examples
Tokenization converts text into vocabulary IDs; Tokenization defines that representation. Sequence construction then determines which content fits together. Truncation drops content beyond a limit; chunking divides it into examples. Either can separate related information before the model receives it.
Packing places multiple examples into a training sequence. Padding adds placeholders to fit a batch’s shape. Removing padding can avoid wasted work, while packing needs an explicit policy for whether separate examples can exchange information.
Placement, visibility and scoring
ExamplePacking does not determine either mask.
Separate documents.
Read the diagram as text
- A: red fox.
- B: blue bird.
- A IDs: red fox EOD.
- B IDs: blue bird EOD.
- red fox EOD | blue bird EOD.
- Attention. Causal; reset after EOD. blue sees blue; bird sees blue and bird.
- Scoring. Scored: red→fox, fox→EOD, blue→bird, bird→EOD. Ignored: EOD→blue.
- A: red fox → A IDs: red fox EOD: Encode.
- B: blue bird → B IDs: blue bird EOD: Encode.
- A IDs: red fox EOD → red fox EOD | blue bird EOD: Place A.
- B IDs: blue bird EOD → red fox EOD | blue bird EOD: Place B.
- red fox EOD | blue bird EOD → Attention: Visibility.
- red fox EOD | blue bird EOD → Scoring: Targets.
- Source records. Separate documents. Active: A: red fox, B: blue bird. New: A: red fox, B: blue bird.
- Encoded records. Append EOD. Active: A: red fox, B: blue bird, A IDs: red fox EOD, B IDs: blue bird EOD. New: A IDs: red fox EOD, B IDs: blue bird EOD.
- Packed sequence. Retain boundaries. Active: A: red fox, B: blue bird, A IDs: red fox EOD, B IDs: blue bird EOD, red fox EOD | blue bird EOD. New: red fox EOD | blue bird EOD.
- Independent masks. Attention blocks cross-document access; loss separately excludes EOD→blue. Active: A: red fox, B: blue bird, A IDs: red fox EOD, B IDs: blue bird EOD, red fox EOD | blue bird EOD, Attention, Scoring. New: Attention, Scoring.
An attention mask controls information access. A loss mask controls scored positions. Document-boundary attention resets, position resets and loss exclusion are independent settings.
A token can supply context without being a scored target. Consequently, processed-token counts and scored-target counts can differ. Ignored targets must also be excluded from a mean loss’s denominator, rather than contributing zero while still enlarging it.
Sampling, token exposure and loss contribution
Stored corpus size, selection probability and processed-token share answer different questions. If selection samples whole documents without truncation, longer documents contribute more tokens per selection. A domain’s sampling probability therefore need not equal its token share.
| Component | Tokens per document | Token share | Equal document-mean loss share |
|---|---|---|---|
| General text | 100 | 10% | 50% |
| Domain text | 900 | 90% | 50% |
Pooling all valid token losses gives the longer document nine times as many terms. Averaging document means gives each document equal weight. Explicit document or domain weights add another choice; PyTorch’s class-weight argument instead weights target classes. None of these weights specifies proportional capability gains.
Oversampling selects a component more often than a reference mixture would. An epoch is one pass through a corpus. Mixed streams can accumulate different effective passes through each component, so one global epoch count can obscure concentrated repetition.
Data, learning-rate and sequence-length schedules
A curriculum deliberately changes ordering or emphasis during training. A fixed mixture holds sampling policy constant; staged reweighting changes it at selected boundaries. Curriculum need not mean easy examples followed by difficult ones.
| Schedule | What changes |
|---|---|
| Data | Which sources receive exposure and when |
| Learning rate | Update scale: warmup raises it initially, rewarming raises it again, and decay lowers it |
| Sequence length | How much related material can occupy one training example |
Equal exposure, different placement
ExampleBoth schedules devote half the total tokens to the domain.
Fixed mixture
Domain share remains 0.5 throughout.
Scroll sideways if the figure extends beyond the screen.
- 1. Domain-token share
Read coordinates and regions as data
X: 0–1 dimensionless; Y: 0–1 dimensionless, increasing up. Axes scaled independently; screen angles and distances are not comparable.
(0, 0.5); (1, 0.5)
Staged mixture
Share changes from 0.25 to 0.75 halfway through; average exposure remains 0.5.
Scroll sideways if the figure extends beyond the screen.
- 1. Domain-token share
Read coordinates and regions as data
X: 0–1 dimensionless; Y: 0–1 dimensionless, increasing up. Axes scaled independently; screen angles and distances are not comparable.
(0, 0.25); (0.5, 0.25); (0.5, 0.75); (1, 0.75)
Equal aggregate exposure leaves ordering unspecified. Earlier examples affect the parameters that later examples update, potentially under a different learning rate. To investigate ordering, match per-source token totals, objective, compute and other schedules; to investigate mixture weights, retain the ordering policy.
GLM-4.5 changes data, lengths and packing across stages. Its combined recipe does not isolate an ordering-only benefit.
Model size, training tokens and compute
Parameter count measures learned numerical values. A processed-token budget measures training exposure. FLOPs, floating-point operations, measure arithmetic work. Empirical scaling laws fit relationships between these quantities and prediction loss within studied training regimes.
A fixed arithmetic-work budget
ExampleMore parameters leave fewer affordable training tokens.
Equal-compute allocations
The dense-model approximation is held fixed.
Scroll sideways if the figure extends beyond the screen.
- 1. Fixed training FLOPs
Read coordinates and regions as data
X: 0.4–4.3 billions; Y: 0–215 billions, increasing up. Axes scaled independently; screen angles and distances are not comparable.
(0.5, 200); (0.625, 160); (0.8, 125); (1, 100); (1.25, 80); (1.6, 62.5); (2, 50); (2.5, 40); (3.2, 31.25); (4, 25)
Kaplan’s historical fit favored increasing non-embedding parameters faster than data as compute grew, stopping large models before convergence. Chinchilla instead favored approximately equal proportional growth of parameters and tokens. It varied training horizons and matched learning-rate decay to them, helping explain why allocation conclusions differed.
A training-only optimum minimizes prediction loss under a training budget. A lifetime resource objective includes expected inference demand. Substantial serving demand can favor smaller models trained longer, but that conclusion depends on the demand estimate and loss model; extrapolating ordinary token ratios can overstate gains from extreme exposure.
Replit applied this reasoning to latency-sensitive code completion: spend more training effort on a smaller model and amortize it across later requests.
FLOPs alone do not determine elapsed time or price. Memory capacity and execution efficiency constrain feasible runs; Distributed Training and Inference covers distributing work and state when one device is insufficient.
Finite data and repeated exposure
Repeated passes can improve learning without adding unique material, but their marginal value declines. Some extensively repeated runs develop worsening validation loss. A saturation formula does not necessarily model that deterioration, and observed epoch ranges do not establish a universal safe limit.
| Intervention | Potential benefit | Decision evidence |
|---|---|---|
| Acquire additional material | Expand relevant coverage | Held-out gains justify acquisition and training costs |
| Relax filtering | Increase available volume | Added material helps despite lower selection standards |
| Repeat selected material | Spend updates on useful examples | Fixed validation slices continue improving |
| Stop earlier | Avoid low-value additional updates | Further exposure fails target or retention requirements |
Deduplication removes unintended repetition from the inventory; deliberate epochs control repeated exposure after selection. These are compatible choices. Overfitting explains why improving training fit can coexist with worsening held-out performance.
Small pilots can test whether data choices remain promising before a larger commitment. Preserve the intended scarcity and repetition regime; a small run with abundant fresh data may answer a different question from a large run repeatedly sampling a scarce component.
Checkpoint contents and training continuity
An inference artifact identifies a learned model. A resumable checkpoint must additionally identify the training process that produced its next update. Successful weight loading establishes only part of that contract.
| State or artifact | Role |
|---|---|
| Weights and architecture | Restore learned values within the corresponding computational structure |
| Tokenizer and input conventions | Preserve token-ID meanings; matching dimensions alone is insufficient. See compatibility. |
| Optimizer state | Preserve accumulated update information |
| Scheduler, scaler, counters and randomness | Restore update scale and stochastic process state; explicitly register or save components the framework does not cover |
| Sampler and worker state | Identify subsequent samples and random data transformations |
| Run record | Bind corpus snapshots, mixture, objective, sequence construction and software configuration to the checkpoint |
Identical weights, different continuation
Process state determines the next samples and updates.
Read the diagram as text
- Saved weights.
- Recorded process state.
- New process configuration.
- Restore interrupted run.
- Initialize new stage.
- Recorded continuation.
- New trajectory.
- Saved weights → Restore interrupted run: Recovery selected.
- Saved weights → Initialize new stage: Warm start selected.
- Recorded process state → Restore interrupted run: Restore state.
- New process configuration → Initialize new stage: Initialize state.
- Restore interrupted run → Recorded continuation: Resume updates.
- Initialize new stage → New trajectory: Begin updates.
A warm start reuses learned weights while intentionally resetting or changing process state. It begins a different trajectory. Document such resets at stage boundaries; they are design choices rather than inherently incorrect recovery.
Verify restored counters, learning rate, next sample identities and loss continuity. A wrong data position can repeat or skip exposure; matching weights cannot detect that error.
Logical-state restoration does not guarantee bitwise-identical execution across hardware or software changes. Random-state control and deterministic algorithms address different sources of variation, and deterministic execution can carry a performance cost.
Weights alone do not record processed examples. Keep the recipe and recorded artifact state together, with accessible corpus versions and execution configuration. Dataset releases and reproducible lineage explains snapshots and manifests.
Domain adaptation and retained capabilities
Domain-adaptive pretraining, or DAPT, continues language-model training on domain material. Task-adaptive pretraining, or TAPT, uses the target task’s unlabeled training inputs; task answers are not its prediction targets. The foundational study uses masked-token prediction. An autoregressive adaptation instead predicts continuations. Supervised response training belongs in Post-training and Alignment, even when both use token cross-entropy.
| Contract element | Proposed specification |
|---|---|
| Inherited model | One identified general checkpoint and its compatible tokenizer |
| Domain experience | Versioned, permitted engineering documents and code relevant to intended workflows |
| Targets | Ordinary corpus continuations, rather than demonstrated task answers |
| Exposure | Specify sampling units, general/domain shares, unique tokens, processed tokens and scored targets |
| Update policy | Declare duration, learning-rate policy and intentional process-state resets |
| Success and retention | Test unfamiliar domain tasks alongside earlier general and language capabilities |
Continuation inherits earlier learning; training from scratch must establish it again. Comparable incremental continuation budgets therefore do not imply comparable total training investment. Domain-trained weights also remain a predictive model, not an authoritative, automatically refreshed database.
Catastrophic forgetting is substantial degradation of earlier capabilities after new training. General-data share, domain emphasis, duration and learning-rate policy can affect adaptation and retention. Replay and regularization algorithms belong in Continual Learning; here, retention remains a separate acceptance requirement.
A reported legal midtraining example retained a majority of broadly representative data and improved domain performance without reported general regression. That supports testing mixed exposure, not prescribing a universal ratio or promising retention.
Training progress and capability evidence
| Measurement | Supported interpretation | Remaining gap |
|---|---|---|
| Training loss | Fit on processed training examples | Performance on unseen inputs |
| Fixed held-out loss | Prediction quality on a specified unseen distribution | Success on the intended task |
| Capability probe | Task performance under a defined elicitation and scoring protocol | Other tasks, languages or operating conditions |
Perplexity comparisons require compatible tokenization, data, available context and scoring conventions. This ordinary autoregressive definition does not directly apply to masked language models.
| Checkpoint | General loss | Domain loss | General/domain weights | Aggregate |
|---|---|---|---|---|
| Earlier | 1.0 | 3.0 | 50% / 50% | 2.0 |
| Later | 1.1 | 3.1 | 90% / 10% | 1.3 |
Track fixed validation slices and task probes against consumed tokens and compute. Define metric denominators explicitly; changing mixture composition must not silently change the population behind a progress claim.
For base-model comparisons, fix prompts, demonstrations, decoding and scoring. In-context examples change elicitation without updating weights; assistant-style polish is not the only evidence of capability.
Memorization can coexist with poor application. In Jack Morris’s financial-report demonstration, reproducing training text did not yield a useful differently formatted response. A transfer probe must require more than copying familiar sentences.
Contamination and assessment independence
Contamination occurs when assessment information enters training or training choices across a claimed independence boundary. Familiarity with the subject is not itself leakage. Independent data boundaries separates fitting, development and protected assessment.
Exact matching finds literal overlap. Matching n-grams, contiguous token sequences, can detect shared passages. Such checks are useful screening, but their thresholds determine which similarities are noticed and which material is removed.
Assessment exposure has indirect routes
Literal matching covers only one route.
Read the diagram as text
- Assessment material.
- Literal copies.
- Paraphrases or translations.
- Continuation corpus.
- Inherited checkpoint. Earlier corpus may be undisclosed.
- Candidate checkpoint.
- Assessment material → Literal copies: Copy.
- Assessment material → Paraphrases or translations: Transform.
- Literal copies → Continuation corpus: Possible inclusion.
- Paraphrases or translations → Continuation corpus: Possible inclusion.
- Continuation corpus → Candidate checkpoint: Training exposure.
- Inherited checkpoint → Candidate checkpoint: Inherited parameters.
Semantic investigations retrieve related candidates and inspect equivalence. Paraphrases, translations and transformed code can evade literal detectors. Negative scans do not establish absence; detected overlap alone does not quantify its score effect.
Adaptive reuse creates another dependency: assessment scores can guide later training decisions even when individual cases remain hidden. Use development evidence for iteration, then independently sampled untouched cases for an ordinary holdout claim. Dates alone cannot establish independence from an undisclosed inherited corpus.
Controlled comparisons and checkpoint selection
An ablation changes or removes a component to investigate its contribution. Controlled offline comparisons hold assessment conditions fixed. Training comparisons additionally need explicit data, objective, schedule and budget controls.
| Arm | Training intervention | Comparison purpose |
|---|---|---|
| Unchanged checkpoint | No additional updates | Measure total incremental change |
| General continuation | Additional broadly representative exposure | Control for extra training under comparable incremental compute |
| Targeted continuation | Engineering exposure with declared general-data mixing | Test targeted-data benefit beyond general continuation |
For a data comparison, match starting state, objective, sequence length and update schedule. Report remaining differences. Equal token counts need not mean equal compute, especially when model size or example construction changes. Small differences require uncertainty estimates, not merely a winning score.
Select checkpoints against predeclared target gains, named retention slices and resource limits. A blended score cannot substitute for each requirement. Use development assessments for selection and reserve protected assessment for the selected configuration’s final claim.
Bind the conclusion to checkpoint identity, recipe, corpus versions and evaluation configuration. Preserve unresolved inherited exposure as a limit on the claim.
Open questions
Isolating curriculum order remains difficult because recipes often change data shares, lengths and update policies together. Progress would be a replicated comparison with equal per-source exposure and matched remaining schedules, showing an ordering effect on specified downstream capabilities rather than only final training loss.
Small-corpus adaptation still needs reliable guidance on retaining earlier capabilities. Large incoming-data continuation studies do not determine the right policy for a narrow engineering collection. Progress would require separate target and retention curves across matched mixtures and durations, including regressions hidden by averages.
A complete recovery contract must connect saved process state with corpus identity and subsequent samples. Component restoration alone leaves integration failures possible. Progress would be an interruption fixture that verifies the next samples, counters and updates under a specified environment, while separately testing behavior after environment changes.











