Working with Pretrained Language Models

Dive into Deep Learning · §18

Checking and measuring released models
files · port · prompts · scoring · error bars · inside · behind an API

A Model Is a Download Away; the Work Is to Check and Measure It

The problem

We can build a small GPT and load GPT-2 by hand. The models that people consult we can only download, and then three questions are ours to answer.

question why it is not obvious
What did we download? the name of one model says 2B, and its file of 4.55 GB holds 2,274,069,824 numbers
Does it run the same in our code? two correct programs do not agree to the last bit, and a wrong one may agree to the third digit
Is a difference between two scores real? a score belongs to a model, a prompt, a rule for reading the answer and a sample of questions

A released checkpoint becomes an instrument once we can answer all three.

By the End of This Chapter You Can

Goals

  • read a configuration into parameters, cache bytes and decode time;
  • run a released checkpoint in the book’s code, and show agreement with its reference to rounding;
  • name the prompt and the scoring convention that a score depends on;
  • put a paired interval and a minimum detectable effect on a difference;
  • test a claim about the inside of a model by overwriting an activation;
  • measure the cost, the throughput and the limits of a hosted model.

Running example: open checkpoints of 0.6 to a few billion parameters on one GPU with 24 GB; 500 science questions and 100 arithmetic problems.

Idea: know what the files hold, run the tensors yourself, and put an error bar on every score.

Open a Checkpoint, Measure It, Look Inside and from Outside

Chapter map

movement section question
open a checkpoint Pretrained Models with Hugging Face what is in a checkpoint, and what does it cost to run?
A Released Checkpoint in the Book’s Own Code do its tensors run the same in our code?
measure it Prompting and In-Context Learning how much does the prompt decide?
Scoring Language Models which convention gives which score?
Evaluation Suites, Judges and Error Bars is a difference real?
inside and outside Interpretability how is a claim about the inside tested?
Models behind an API what does a hosted model withhold?
  • Uses: d2l.GPT with GPT-2’s weights, the key-value cache.
  • Skips: fine-tuning, new architectures, serving engines.