Continued pre-training

Continued pre-training resumes the next-token training of an existing base model on new text, such as code, a specialist field or more recent data, instead of training a new model from scratch.

Pre-training is the expensive first stage in which a model learns from a vast amount of text by predicting the next token. Continued pre-training takes a model that has already been through that stage and keeps going with the same objective on new, unlabelled text. It differs from fine-tuning, which usually uses curated examples or instructions to change how a model behaves. Continued pre-training changes what the model knows, and it often uses far more data than fine-tuning.

An early, influential study was Don't Stop Pretraining by Suchin Gururangan and colleagues, published in April 2020 and presented at ACL 2020. They took a pre-trained model and trained it further on text from four domains: biomedical papers, computer science papers, news and reviews. This domain-adaptive pre-training improved results on eight classification tasks, and a further round on each task's own unlabelled text helped again.

Code Llama, released by Meta in August 2023, is a clear example at scale. Instead of training a coding model from scratch, Meta started from Llama 2 and trained the 7, 13 and 34 billion parameter versions on 500 billion further tokens, and a 70 billion parameter version, added months later, on 1 trillion. The paper reported that starting from Llama 2 beat the same architecture trained only on code for a given budget.

The main risk is that new training overwrites old skills, and the shift to new data can also make the model adapt poorly. A March 2024 study by Adam Ibrahim and colleagues found a simple recipe that works: raise the learning rate again, let it decay again, and mix in some of the original training data. With that combination, continued pre-training matched retraining from scratch on all the data, at far lower cost, both for a mild shift between two English datasets and for a stronger shift from English to German.

In practice, continued pre-training is how labs build specialist versions of a general model and bring newer data into a model without paying for a full training run. When release notes mention additional training on code, maths or recent text before fine-tuning, this is usually what they describe.

Common questions

What is the difference between continued pre-training and fine-tuning?

Continued pre-training keeps training a base model on large amounts of raw text with the same next-token objective, adding knowledge of a domain or newer material. Fine-tuning usually uses a smaller set of curated examples, such as instructions and answers, to shape how the model responds. Many pipelines do both, continued pre-training first.

Why not train a new model from scratch instead?

Starting from an existing model reuses the very expensive learning it has already done. Meta reported that Code Llama, built by continuing to train Llama 2 on code, outperformed the same architecture trained only on code for a given budget. Retraining from scratch every time new data arrives would waste most of that earlier investment.

Does continued pre-training make a model forget?

It can, because training heavily on new data can overwrite earlier skills. A March 2024 study found that re-warming and re-decaying the learning rate while mixing in some of the original data largely avoided this, matching the results of retraining from scratch on all the data.

Finding more

Search for "continued pretraining LLM", "domain-adaptive pretraining" or "continual pre-training forgetting" to see methods and results. Research papers on arXiv and the training sections of model technical reports, such as Code Llama's, are the most reliable sources. Release notes that mention a new knowledge cutoff or a specialist variant often point to continued pre-training, and the accompanying technical report gives the details.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.