CPT
How it works
1) The starting point is the weights of an already-pretrained base model. 2) An additional unlabeled corpus is gathered — domain-specific (DAPT), task-specific (TAPT), newer, or in another language. 3) Training continues the same self-supervised objective as pretraining (e.g. next-token prediction). 4) The learning rate is typically re-warmed and then decayed; the choice of maximum LR and warmup length is critical (Gupta et al., 2023). 5) To limit forgetting, a fraction of the original data is replayed alongside the new data; combining LR re-warming, LR re-decaying and replay can match full from-scratch retraining at a fraction of the cost (Ibrahim et al., 2024). 6) After this phase the model is usually fine-tuned (supervised) for a specific task.
Problem solved
Training large models from scratch for every new domain or data batch is expensive, and a general base model may handle specialized vocabulary, a new language, or more recent knowledge poorly. Continued Pretraining cheaply adapts an existing model to such data using large unlabeled corpora, without needing labels.
Components
A previously pretrained model whose weights are the starting point for further training.
Domain, task, newer, or other-language text, without labels.
The same objective as in pretraining (e.g. autoregressive next-token prediction or masked language modeling).
Re-warming and decaying the LR; affects adaptation speed and forgetting.
Mixing in a fraction of the original data to limit degradation on the old distribution.
Implementation
Distribution shift from new data degrades performance on the original distribution.
LR re-warming transiently increases loss on both upstream and downstream data before improving (Gupta et al., 2023).
Skipping re-warming limits adaptation and compute efficiency (Gupta et al., 2023).
Evolution
Systematic demonstration that a second phase of in-domain (DAPT) and task-data (TAPT) pretraining improves results.
Example of domain adaptation of a modern LLM: Code Llama continued on Proof-Pile-2.
Study of the role of learning-rate re-warming when switching to a new corpus.
Combining LR re-warming, re-decaying and replay matches full from-scratch retraining at a fraction of the cost.
Hyperparameters (configurable axes)
Peak LR after re-warming; critical for adaptation efficiency and stability.
What fraction of original data is mixed with the new data to limit forgetting.
Number of steps of linear LR warmup before decay.
Corpus composition and selection (domain, language, quality) determine the adaptation effect.
Number of continued-training tokens; affects degree of adaptation and cost.
Compute bottleneck
Cost scales with the number of processed tokens and model size; dominated by matrix operations on accelerators and memory bandwidth.
Parallelism
Distributed data/model-parallel training across devices; optimization steps are sequential.
Hardware requirements
Large self-supervised training runs on GPU clusters with tensor cores.
Language-model training is also run on TPUs.