Notes

Continued Pretraining (LLM)

A pretrained model knows what the public web taught it. If your field's language barely appears there — radiology reports, Kannada, Verilog — no amount of instruction tuning will install knowledge the model never read. Continued pretraining puts it in the only way that works: more reading.

What it actually is

You take the finished base model and keep going with the same self-supervised objective, predicting the next token, on a large corpus of your domain's text. No labels, no question-and-answer format, just text, usually billions of tokens of it. The learning rate is warmed up again and decayed, and a slice of the original general-purpose data is mixed back in so the model does not forget English while learning law. Code Llama is the textbook example: Llama 2, continued on 500 billion tokens of code.

Where it sits and what it costs
  • It changes what the model knows; supervised fine-tuning and instruction tuning change how it behaves. This stage comes first, and the instruction stage has to be redone afterwards.
  • It is the expensive option, needing thousands of GPU-hours and a real corpus, so reach for RAG or LoRA first and escalate only when the vocabulary itself is foreign.
  • Catastrophic forgetting is the standard failure: a model that aces your domain and has lost its general reasoning. Replaying general data and a conservative learning rate are the defences.

It is also the standard route for adding a new language or extending a context window — anything that has to be learned at scale rather than demonstrated in a few thousand examples.

Continued pretraining is further training of a finished base model on a large domain corpus using the original next-token objective — no labels, no task format, just text measured in billions of tokens. It adds knowledge and vocabulary the original data lacked, as with Code Llama continuing Llama 2 on code. It precedes any instruction tuning, costs far more than LoRA or RAG, and risks catastrophic forgetting unless general data is replayed alongside.

Picture someone who has read a huge general library and now needs to work in a hospital. They are not short on intelligence; they are short on medical reading. So you sit them down with years of medical journals and let them keep reading, the same way they read before. That is continued pretraining. It is how an AI model is given a subject it barely saw the first time round — a language, a legal system, a programming style. It is slow and expensive, and there is a catch: read nothing but medicine for long enough and you start losing your everyday knowledge, so some general reading is kept in the mix.