Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 02 · AI · From a model to an app · with code: Python · about 19 min to read

Watch: What fine-tuning actually is: prompting, retrieval, LoRA and the order to try them in
▶ VideoPlay it as a journeyTutor comes with a plan

A LoRA Run

Fine-tuning and Alignment
Fine-tuning and Alignment · Open board

The Fine-tuning and Alignment board draws how a model that finishes text becomes one that answers. This lesson runs its cheapest tool on a real job: what it costs, what to feed it, and how to tell it worked.

Before you start. A weight is one adjustable number inside a model, and the loss is one number for how wrong it is. Training nudges the weights to shrink the loss, as How It Learns (loss, gradient descent, backprop) showed. A layer is a grid of weights, called a matrix, that the input is multiplied by, as Vectors, Dot Products and Matrix Multiply showed. A 7B is a model with seven billion weights, and an A100 is NVIDIA’s 80 GB data-centre GPU. Fine-tuning is a second, small round of training on examples of one job. It changes how a model behaves and adds no facts, as Fine-tuning & Alignment showed. Adam, the standard training method, keeps two extra numbers for every weight it trains, as Why the Loss Won't Go Down showed. The returns desk is an online shop’s support assistant running on a 7B; What the Model Sees (one string, every turn, from the top) builds it in full later.

Lesson 14 of 83 in AI

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • March 2023: Alpaca, a 7B model fine-tuned on eight A100s
  • Full fine-tuning: 112 GB to move every weight of a 7B
  • 26 March 2023: the same run on one gaming card, and the adapter
  • Rank: how many directions the correction can move in
  • The run: rank 1, 2, 4 and 8 against every weight, scored on a held-out set
  • Curation: 200 checked replies beat 800 raw transcripts
  • Distillation: when a bigger model writes the examples
  • How a thin pair learns to move a big grid
  • What the pair saves on the 7B
  • Why rank 2 wins the toy run
  • The archive and the drafter
  • All of it in code

Terms it explains: Fine-tuning and Alignment, trainable parameters, adapter, rank, held-out set, distillation, synthetic data, alignment, alignment tax, base vs aligned model, Constitutional AI, fine-tuning, HHH, instruction tuning, KL penalty, LoRA, PPO, reward hacking, reward model, RLAIF, RLHF, SFT.

Lab

Fine-tuning a 7B model with LoRA trains a small correction beside the frozen weights. How big should the correction be?

Drag How big each correction is from r = 1 to r = 256 and watch Memory to train climb while Quality stalls.

Open The LoRA rank

Related papers

Review AI