part II · chapter 11 of 17

Fine-tuning and model adaptation

Changing a model's weights to fit a task, a format or a domain.

why it matters

You learn when prompting and retrieval are not enough, and when fine-tuning is the wrong tool.

before this: chapter 10, Multimodal AI

being written

This chapter is being written. Here is what it will cover; until then, the full topic list is in our notes.

  • supervised fine-tuning, dataset preparation
  • loss, overfitting, forgetting
  • LoRA, QLoRA, adapters
  • preference tuning, distillation
the topic list on GitHub (opens in a new tab)

you reached the end of the chapter

build this

LoRA-tune a small open model to follow one strict output format.

the maths underneath

  • maths note 7

    Calculus: derivatives, chain rule, gradients

    dydx=dydu⋅dudx\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}

    Training is following the gradient of the loss downhill, and backpropagation is the chain rule run backwards.

  • maths note 8

    Optimization, loss and low-rank matrices

    W′=W+BA,r≪min⁡(d,k)W' = W + BA, \quad r \ll \min(d, k)

    The optimizer, the learning rate and why LoRA trains 0.39% of the weights and still fits on a small GPU.

  • maths note 11

    Information theory: entropy, cross-entropy, perplexity

    L(θ)=−1T∑t=1Tlog⁡pθ(xt∣x<t)L(\theta) = -\frac{1}{T} \sum_{t=1}^{T} \log p_\theta(x_t \mid x_{<t})

    What loss means when you fine-tune, what perplexity measures, and why a tuned model is held close to its base.

check yourself

Tick what you could explain to someone else, out loud, without notes.