Machine learning with football · Chapter 10 · Large language models

Fine-tuning and distillation

From a general model to a useful one: fine-tuning, distillation and prompt engineering.

Estimated time: 15 minutes · page 3 of 4

From a general model to a useful one

A foundation model, also called a base or pre-trained model, knows grammar, words and idioms, but it isn't yet a solution to your problem. Three ways get it there.

Fine-tuning

Fine-tuning trains the foundation model further on examples from your task. A few hundred or thousand often suffice, say match reports labelled by sentiment. Standard fine-tuning updates every parameter, which is expensive. Parameter-efficient tuning updates only some. Either way the model keeps its size, ten billion parameters stay ten billion.

Distillation

Huge models are slow and costly to run. Distillation trains a small student model on labels from a big teacher. The teacher can label far more data than exists, and with probabilities instead of a bare yes or no, which gives the student a richer signal.

The board does it with football. The teacher is chapter 9's goals model, an attack and a defence number per club. It gives a home-win probability for every possible pairing, played or not. The student is a one-number logistic regression on the goal difference gap. One student learns only from the real results, the other from the teacher's probabilities. Both are tested on the latest matches.

Prompt engineering

End users steer a model with the prompt alone, without changing any parameters. Showing examples in the prompt is in-context learning:

  • Zero-shot: "Porto: ___" might come back about wine.
  • One-shot: "Arsenal: Premier League. Porto: ___" points it at football.
  • Few-shot: several examples, "Arsenal: Premier League. Inter: Serie A. Lyon: Ligue 1. Porto: ___", and it answers "Primeira Liga".

Large models can be too slow to run per request, so teams often use them offline. They label or generate in bulk and cache the results, which is chapter 11's static inference. This site works the same way. A language model rewrites news stories in the background, and the pages serve the stored results.

Check yourself

Which statement is true?
A prompt gives two examples, "Arsenal: Premier League" and "Inter: Serie A", then asks "Porto: ___". What is that called?

Leagues