Mid-training: The Phase Between Pre-training and Alignment
A Story: The Last Week Before the Exam
A student spends six months reading broadly: textbooks, papers, lecture notes, whatever comes to hand. Then, in the last week before the exam, the regime changes completely. The general reading stops, and everything goes into past papers, summary sheets and worked solutions, the densest, best-targeted material available.
Everyone knows why: what you see last counts out of all proportion. The six months of broad reading built general knowledge; the last week decides the grade.
Large language models are trained on exactly this pattern. And that "last week" has ended up with a name: mid-training.
A warning up front: "mid-training" is practitioner jargon. It doesn't have the stability of "pretraining" or "post-training." Depending on the team, the same operations are called annealing, the decay phase, cooldown, late-stage pretraining, mid-training, or simply "the end of pretraining." The first academic survey proposing a taxonomy of mid-training only appeared in 2025, and it says as much itself: the word covers "multiple annealing-style phases" rather than one operation.
So, the honest position: the phenomenon is solid and well measured; the division into phases is a convenient convention, not a natural boundary. This page describes what the word covers in practice, and avoids giving it a firm definition no source would support.
The "Before": The Two-Stage Pipeline
The standard story you still find in most explanations goes like this:
- Pretraining: swallow trillions of tokens of web text while the model learns to predict the next word. Out comes a base model, knowledgeable, but unable to answer a question; it can only continue a text.
- Post-training: teach it how to behave. First instruction tuning, then alignment on human preferences, RLHF (Reinforcement Learning from Human Feedback), DPO (Direct Preference Optimization), GRPO (Group Relative Policy Optimization). Out comes a usable model.
That story isn't wrong, it's incomplete. It implies pretraining is one homogeneous block: a single data mixture, a single regime, start to finish. That is not remotely how recent models are built.
What Actually Happens at the End of Pretraining
In modern practice, the last tens or hundreds of billions of tokens get separate treatment. Several things typically happen at once:
1. Annealing the Learning Rate on Curated Data
This is the central operation. The learning rate is the size of the step taken at each weight update: large, it moves the model a lot; small, it fine-tunes it. See gradient descent.
You decay it rapidly ("annealing," by analogy with the controlled cooling of a metal, which lets its internal structure settle into a stable state) and at the same time you swap the ordinary data mixture for a far richer one: textbooks, technical documentation, clean code, mathematical proofs, carefully filtered corpora, high-quality synthetic data.
2. Rebalancing the Data Mixture
During the long high-learning-rate phase, volume wins: web text, lots of it, because you need trillions of tokens and no clean source exists at that volume. During mid-training, quality wins: fewer tokens, far better chosen, with a much heavier share of STEM (Science, Technology, Engineering, Mathematics), code and reasoning. What "quality" does and does not mean here is covered on data quality.
3. Extending the Context Window
Taking a model from 4,000 to 32,000 or 128,000 tokens of context almost always happens here: you adjust the scale of the position encoding (RoPE, Rotary Position Embedding, explained on its own page) and train on long documents. It isn't a separate phase, it's an operation housed inside mid-training.
4. Injecting Capabilities
This is where it gets decided that a model will be good at code, or math, or ten languages. You heavily overweight that data during the anneal rather than diluting it across the preceding trillions of tokens.
5. Sometimes, Reasoning Data
Some teams introduce reasoning traces at this stage, chains of thought, worked solutions. The goal isn't to teach reasoning in the post-training sense, but to make reasoning familiar before reinforcement learning arrives, so that it has something to bite on.
Why This Phase Exists
The Empirical Reason: The End Weighs Heavily
This is the observation everything else rests on. With a schedule that holds the learning rate high for a long time and then drops it, the loss curve is flat throughout the stable phase and then falls off a cliff the moment decay starts. Most of the model's final quality is won during that drop.
The direct consequence: the data seen during the anneal has influence far out of proportion to its volume. A few percent of the total token budget, but a major share of the final model's character.
Two complementary mechanisms are usually offered. One: at a high learning rate the model takes large steps, explores broadly and settles on nothing; at a low rate the steps are small, it settles into a specific dip in the loss surface, and the data seen last determines which one. Two: large steps partly erase what was just learned, while the small steps at the end no longer do, so what's learned last survives. That is exactly the overwriting mechanism described on continual pre-training, seen here from its good side.
Both are plausible and consistent with what's observed, but the precise attribution is still debated. The effect itself is reproduced everywhere; it's the explanation that remains partly conjectural.
The Economic Reason: Good Data Is Scarce
Genuinely clean corpora (textbooks, documentation, quality code, licensed books, well-made synthetic data) exist in vastly smaller quantities than the web. You cannot make them the bulk of trillions of tokens.
But you can make them the bulk of the last 5%. And since that's where it counts most, the return is excellent. Mid-training is, very concretely, a way of spending a scarce resource where it pays best.
The Industrial Reason: One Trunk, Several Branches
A quieter advantage, but decisive in practice. The checkpoint taken at the end of the stable phase is a reusable asset. From one expensive trunk, a team can launch several different anneals (a code-heavy one, a multilingual one, a reasoning-heavy one) each costing a fraction of the trunk.
That's exactly the logic of OctoThinker, which studies how different mid-training strategies affect what reinforcement learning can subsequently achieve.
The strategy the paper proposes, which it calls Stable-then-Decay, gives the real proportions: 200 billion tokens at a constant learning rate for the trunk, then 20 billion spread across three branches focused on reasoning chains. A tenth of the trunk, spent three times.
Its other findings, as stated: a high-quality mathematical corpus significantly improves both the base model and what reinforcement learning extracts from it, while another available mathematical corpus fails to do so, so corpus quality matters, not merely the fact that it is mathematical. Adding long chain-of-thought examples improves outcomes, but also makes responses verbose and training unstable. And the gain grows consistently as mid-training is scaled up.
The underlying finding is this: two base models that look comparable can respond very differently to reinforcement learning depending on what they were fed during mid-training.
The Link with the WSD Schedule
It's no accident that mid-training became standard practice at the same time as the WSD schedule (Warmup–Stable–Decay; see learning rate scheduling). The two are two faces of one idea.
With a cosine schedule you must declare the total training duration at the very start: the whole curve depends on it. Decay is spread across the entire run, and there's no identifiable moment where "the final phase begins."
With WSD the structure is explicit: a warmup, a long constant-learning-rate phase, then a short sharp decay you trigger whenever you want. That decay phase is a perfect container for mid-training:
- it has clear boundaries, so you know exactly what data goes in it;
- you can trigger it when you judge the trunk good enough, without having planned it;
- you can run several of them from the same stable checkpoint, with different mixtures;
- and you can redo it if a mixture disappoints, without throwing away the trunk.
The Warmup–Stable–Decay schedule was popularized by the MiniCPM paper, which introduces it explicitly as "conducive to continuous training and domain adaptation." Its loss curves show each run plateauing during the stable phase and then plunging the moment decay is triggered. Visually, it's the clearest argument for mid-training: you can watch the value being created during the anneal.
The paper also draws an unexpected benefit from it, worth noting because it partly explains the rapid adoption: since decay can be triggered whenever you want, you can study the optimal ratio between model size and data quantity without rerunning a full training for every measurement point.
On the open-model side, OLMo 2 is one of the best-documented examples: its authors explicitly describe introducing a specialized data mixture during the annealing phase of pretraining, and measure the downstream benchmark gains. They call it "late-stage curriculum training" rather than mid-training, a perfect illustration of how unsettled the vocabulary is.
2 OLMo 2 Furious (OLMo Team, 2025)Don't Confuse It with Its Two Neighbors
Two other pages in this course cover adjacent operations. Here's how they sit relative to each other.
Versus Continual Pre-Training
Continual pre-training, often abbreviated CPT, starts from an already released model (often someone else's) and pushes it further on a target domain. The learning rate has to be re-warmed, the main risk is forgetting what the model already knew, and you guard against it by replaying general data alongside the domain data. The mechanism of that forgetting is explained in detail on that neighbouring page, and it is worth going there: it is the same overwriting mechanism that explains, here, why the end of pretraining weighs so much.
Mid-training happens inside the original run, at the same lab, before any release, using the tail of the schedule that was already planned. There's nothing to re-warm and not much forgetting to fear: there's no finished model yet to damage.
The boundary is real but blurry. A continual pre-training run that ends with an anneal on curated data looks a lot like mid-training. The difference is mostly who does it, on what artifact, and within what continuity of schedule.
Versus Context Extension
Context extension isn't a competing phase: it's an operation, and it's most often performed during mid-training. Position interpolation, NTK-aware scaling (NTK for Neural Tangent Kernel), YaRN, then training on long sequences, all of it fits naturally into the final anneal, because that's when you have high-quality long documents and an already-low learning rate.
A table to fix the picture:
| Pretraining (stable phase) | Mid-training | Continual pretraining | Post-training | |
|---|---|---|---|---|
| Who | original team | original team | often a third party | product team |
| Starting point | from scratch | internal checkpoint | released model | base model |
| Learning rate | high, constant | decaying fast | re-warmed, then low | very low |
| Typical volume | trillions of tokens | a few % of the total | 0.5–10% of pretraining | far less |
| Data | massive web, volume first | curated, quality first | target domain + replay | instructions, preferences |
| Goal | broad knowledge | targeted capabilities, long context | domain adaptation | behavior, format |
| Main risk | instability | benchmark contamination | forgetting prior knowledge | capability regression |
What's Still Debated
Resist the temptation to present any of this as settled science. Several points are open.
- Quality or recency? When annealing on curated data improves benchmarks, is it because the data is better, or simply because it arrives last? The two effects are confounded in most published reports, and separating them cleanly requires ablations (rerunning the anneal changing one ingredient at a time) each of which costs the price of a training run. This is exactly the difficulty met in curriculum learning, where the effect of ordering also cannot be separated from the effect of quantity.
- The contamination risk. Putting data very close to the benchmarks into the anneal mechanically produces nice numbers. The line between "injecting a capability" and "teaching to the test" is thin, and rarely discussed with the rigor it deserves. This is the main reason to read post-mid-training scores with caution, see how to read a benchmark.
- Where does pretraining end? Once you inject reasoning traces and conversational-format data during the anneal, you're already doing something that looks like post-training. The word "mid" names precisely that grey zone.
- How durable are the capabilities? Does a capability installed during mid-training survive post-training better than one installed afterwards? Several teams believe so, but a systematic demonstration is missing.
- No public recipes. The exact mixtures, proportions and anneal lengths are among labs' best-kept secrets. What is published is real, but it's a fraction of what's practiced.
Why It Matters
Because it moves where a model's quality actually gets decided. The "pretraining for knowledge, post-training for behavior" story suggests capabilities are mostly won at the end, through alignment. What's observed is more nuanced: a good share of what a model can do is determined in a narrow window at the very end of pretraining, by data very few people ever see.
It also explains why two models announced with the same size and the same training volume can feel so different in use. The difference isn't in the trillions of web tokens, those are broadly the same everywhere. It's in the last few percent.
Key Takeaways
- The pipeline has three phases, not two: a long stable phase at high learning rate on massive data, a short intermediate phase, then post-training. The middle one is what people call mid-training.
- What happens there: learning-rate annealing on very high-quality data, rebalancing the mixture toward STEM/code/reasoning, context-window extension, targeted capability injection, and sometimes the first reasoning traces.
- Why it works: the last tokens seen weigh disproportionately on the final model (the loss plunges during decay) so that's where the scarce, expensive data should be spent.
- The link with WSD: the decay phase of the Warmup–Stable–Decay schedule is the natural container for mid-training, and lets you launch several different anneals from one reusable trunk. OctoThinker gives the order of magnitude: 200 billion tokens for the trunk, 20 billion per branch.
- Don't confuse them: continual pretraining starts from an already released model and fights forgetting; context extension is an operation that lives inside mid-training. Mid-training itself happens within the original run.
- Handle with care: the term is practitioner vocabulary more than literature, the "quality" and "recency" contributions are rarely disentangled, and the benchmark contamination risk is real.
1. With a WSD-style schedule, the loss curve stays flat during the long stable phase, then plunges as soon as the decay is triggered. What practical conclusion follows?
2. What distinguishes mid-training from continual pre-training?
3. An anneal on curated data improves the scores. Can you conclude that the quality of that data explains the gain?
4. Why reserve the genuinely clean corpora (textbooks, quality code, well-made synthetic data) for the last few percent of training rather than spreading them across the whole run?
5. Why should scores obtained after mid-training be read with caution?