liveBook · Manning

Transfer learning

As explained in LLMs in Production

Transfer learning is a machine-learning technique that adapts knowledge learned from one task or dataset to another task or domain.

Suppose a general-purpose language model needs to answer questions in a particular domain. Training a new model from scratch would repeat the expensive work of learning broad language patterns. Transfer learning reuses knowledge learned for a source problem and adapts it to a related target task or domain. For LLMs, that usually means starting with a pretrained model and finetuning it on a smaller, task-specific dataset. section 5.2.2

The practical sequence is:

  • Start with a foundation model pretrained on a large, diverse corpus. Its existing weights capture general language patterns; creating those weights requires substantial computation. section 5.2.2
  • Update the model using data representative of the target task or domain. This generally takes far less data and computation than pretraining, and can improve performance on tasks such as sentiment analysis, text classification, or question answering. section 2.3.3 section 5.2.2
  • Consider prompting when examples in a query are enough. Large models can sometimes perform specialized tasks without finetuning, so updating weights is not the only route to adaptation. section 2.4

Choose the adaptation path

A pretrained BERT model can be retrained on data representative of a particular task instead of being trained from scratch. For an LLM, the same general-to-specific pattern can produce an expert-task model from a foundation model and a small, curated dataset. If a few examples in the prompt already produce suitable results, prompting may avoid that finetuning step. section 2.3.3 section 5.2 section 2.4

Figure 5.3 Finetuning differs from training from scratch in that you don’t have to define model behavior, you can use the exact same training loop, and you have a fraction of the data requirement.
figure

The comparison makes the central resource trade-off visible: finetuning reuses an existing model and needs a fraction of the data required for training from scratch. section 5.2.2

How LLMs in Production covers it

How deep it goes
Defines source and target domains, explains pretraining followed by finetuning, and contrasts training costs without detailing weight-update internals.
Examples
Uses BERT task adaptation, sentiment analysis, text classification, question answering, and a finetuning-versus-scratch comparison.
What it assumes
Defines source and target domains and places adaptation after pretraining, without requiring the reader to create a foundation model.
What you can do after
Apply it via OpenAI fine-tuning jobs or a pretrained model, using target-specific data rather than training from scratch.
How it connects
Connects foundation models and finetuning to pretraining, curated datasets, and few-shot prompting.

Also explained in

Compare how 11 books explain transfer learning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of LLMs in Production. The section links point to the parts of the book it draws on.