category: training ยท status: draft ยท updated: 2026-11-02

Domain CPT, LoRA, and Forgetting

Continued pre-training (CPT) means taking a base model that already finished general pre-training and training it more on your domain's raw text โ€” exploit-db entries, Sigma rules, kernel source, CTF writeups, CTI reports. It injects vocabulary, formats, and background knowledge that instruction tuning can't, because there are no instructions โ€” just text. The catch is as old as transfer learning itself: specialize too hard and the model forgets its general abilities. Every decision in this explainer is about buying domain skill without paying the forgetting tax.

What the evidence says

CPT works, at modest scale. Primus (EMNLP 2025) is the cleanest public datapoint: continued pre-training of Llama-3.1-8B on ~2.8B tokens of curated security text lifted the aggregate cyber score +15.9%; on a 70B base, 7.6B tokens of filtered cyber corpus gave +11.2%. Meanwhile general capability barely moved โ€” MMLU drifted from 67.56% to 66.29%, about a point. So billions of tokens of domain CPT is roughly a +10โ€“15% domain gain for ~1 point of general loss when the corpus is curated and the model is big enough to absorb it.

Forgetting is real and replay is the brake. Train on a narrow distribution for billions of tokens and gradient updates overwrite general knowledge โ€” outputs go domain-flavored, reasoning benchmarks sag. The standard mitigation is replay: mix a fraction of general + code data into the CPT corpus. We budget 20โ€“30% general/code replay as our starting band (industry practice clusters there; it's a starting point to fit, not gospel). Below ~20% you start leaking MMLU; above ~30% you're mostly not doing CPT anymore.

LoRA learns less and forgets less. Biderman et al., TMLR 2024 ran exactly our regime โ€” LoRA vs full fine-tuning on ~10โ€“20B tokens of code/math CPT โ€” and found a stable tradeoff: LoRA underperforms full FT on target-domain learning, but retains notably more of the original model's capabilities; full FT learns more and damages more. Rank and target-module choices only partially close the learning gap. LoRA also has an operational bonus for us: it's cheap, resumable, and merges back into the base with zero decode-time cost โ€” so the 200 t/s M5 Max decode floor from CyberTiel-class MTP builds survives.

The mix is predictable without the big run. Data mixing laws (Ye et al., ICLR 2025) show that loss as a function of mixture proportions follows fittable functional forms: nest a step-scaling law, a model-size law, and a mixing law, fit all three on small proxy runs, and you can predict โ€” and then optimize โ€” the large run's mixture before spending on it. Apple's follow-up confirms the extrapolation holds. This is how we pick our cyber:general:code ratio empirically instead of by folklore.

The tradeoff, compactly

Full-param CPTLoRA-CPT
Domain gain per tokenhigherlower (learning gap)
Forgettingworsebetter (retention)
Cost on 27Bbig multi-GPU rental, full checkpoint each timesmall rental or even M5 Max MLX, adapter per experiment
Reversibilityno (new weights)yes (drop adapter)
Decode speed after mergesamesame

Our decision

LoRA-CPT, 3โ€“5B tokens, only on base-model jumps, always gated. Concretely:

  1. Trigger. CPT is a rare event, not part of the weekly loop. When we jump bases โ€” say Qwen3.8-27B โ†’ the next Qwen refresh โ€” the new base re-enters CPT once. Between jumps, the factory trains via SFT/RL on verified trajectories ([[purple-loop]], [[capability-ladders]]), which is where the agent skill actually comes from; CPT only lays the background knowledge floor.
  2. Budget. 3โ€“5B tokens at ~25% replay โ€” inside the regime Primus showed pays off (their gains came at 2.8โ€“7.6B, with sub-point MMLU drift), and small enough that LoRA's learning gap costs little (Biderman's gap is measured over 10โ€“20B tokens; at 3โ€“5B we're buying vocabulary and format priors, not deep domain reasoning).
  3. Gate. Every candidate adapter must hold MMLU within ~2 points of the base and MT-Bench within noise, plus no regression on the CyberTiel speed floor. Fail the gate โ†’ raise replay ratio to 30%, refit, retry. A domain gain that costs general assistant quality is a dead build for a dual red+blue model.
  4. Proxy before payload. Fit the mixing law on small runs (a 1โ€“2B-parameter proxy or short token budgets on the real base via LoRA), solve for the predicted-optimal cyber:general:code ratio, then spend the one big run.

Worked example

Suppose the next Qwen base lands and we green-light a CPT event for our 27B build. Corpus target: 4B tokens = 3B cyber (exploit/advisory/Sigma-auditd-Sysmon-telemetry/tool-source mix from Stream A's tier-1 datasets, license-screened) + 1B replay (โ‰ˆ600M general web + 400M code). First, five proxy runs at ~200M tokens each sweeping replay 15/20/25/30/35%; fit the mixing law, find predicted loss-optimal at 24% replay with MMLU constraint satisfied at 26% โ€” take 26%. Then one LoRA-CPT run on rented 8ร—H100, gate on MMLU (โˆ’1.4 observed, passes), MT-Bench (โˆ’0.05, passes), and harness scores (ExploitBench Tier-1/2 rates up). Merge the adapter, tag the checkpoint, and the weekly SFT/RL loop resumes on the new floor. Total CPT cost: a few thousand dollars and two weeks โ€” because it's LoRA-sized and proxy-optimized, not a 256-GPU re-pretrain like the CyberFactory paper's 397B build ([[cyberfactory-openaegis]]).

See also

[[purple-loop]] ยท [[capability-ladders]] ยท [[cyberfactory-openaegis]] ยท [[landscape-2026]] ยท [[index]]