liveBook · Manning

Fine-tuning

As explained in Build a Large Language Model (From Scratch)

Further training of a pretrained model on a smaller task-specific dataset to improve downstream performance.

Fine-tuning further trains a pretrained foundation model on a smaller, labeled dataset tailored to a task or domain. It follows broad pretraining and adapts the model for downstream performance, such as instruction following or text classification. section 1.3 section 1.8

A practical fine-tuning workflow is:

  • Start with a pretrained LLM rather than repeating the expensive large-corpus pretraining stage. section 1.5
  • Prepare a smaller labeled dataset representing the target task, such as instructions and expected responses. section 1.8 section 7.5
  • Load the pretrained model and reuse much of the preprocessing and training code used for pretraining. section 7.5
  • Compare the model's output before and after training to establish a baseline and assess the effect of fine-tuning. section 7.5

Instruction-following adaptation

A pretrained GPT model receives the instruction, "Convert the active sentence to passive: 'The chef cooks the meal every day.'" Fine-tuning on instruction-response pairs aims to make the model produce an appropriate answer instead of continuing the prompt as ordinary text. section 1.7 section 7.5

Figure 7.15 The three-stage process for instruction fine-tuning an LLM. After the dataset preparation, the process of fine-tuning an LLM for instruction-following begins with loading a pretrained LLM, which serves as the foundation for subsequent training.
figure

Use the three-stage workflow figure to locate dataset preparation, pretrained-model loading, and subsequent instruction fine-tuning. section 7.5

How Build a Large Language Model (From Scratch) covers it

How deep it goes
Explains the two-stage workflow and model-loading step, but defers detailed optimization and parameter-update mechanics.
Examples
Uses labeled instruction-response data, sentence transformation, personal assistants, and text classifiers as concrete applications.
What it assumes
Assumes familiarity with pretrained LLMs and training data, while treating the pretraining-to-fine-tuning progression as foundational.
What you can do after
Apply it to adapt pretrained GPT models for instruction following or classification with smaller task-specific datasets.
How it connects
Connects pretraining, foundation models, supervised learning, instruction following, text classification, and transformer-based LLMs.

Also explained in

Compare how 37 books explain fine-tuning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Large Language Model (From Scratch). The section links point to the parts of the book it draws on.