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 · 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

Rank, SVD and the shape of data

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

: the fine-tuning board. LoRA, the small correction drawn beside the frozen model, rests on one fact about tables of numbers. This lesson is that fact.

On 2 October 2006 Netflix offered one million dollars to anyone whose film recommendations beat its own system, Cinematch, by 10 percent. It released about 100 million ratings that viewers had given to films. Lay those ratings out as a table with one row per viewer and one column per film. Most cells are empty, because nobody watches every film. The job was to guess the empty cells.

On 11 December 2006, a competitor called Simon Funk posted his method on his blog. He gave every viewer a short list of numbers and every film a short list of numbers, and multiplied the two lists to guess a rating. The idea underneath is the subject of this lesson.

By the end you will be able to say what the rank of a table is, read a singular value decomposition, derive PCA in five lines, and explain why LoRA can train a few thousand numbers instead of millions.

The history (optional)

In 1936 Carl Eckart and Gale Young published “The approximation of one matrix by another of lower rank” in the journal Psychometrika. They showed how to find, for any table, the closest table of a smaller rank.

Before you start. A dot product multiplies two lists slot by slot and adds the results, and a matrix is a table of numbers that does many dot products at once, as Vectors, Dot Products and Matrix Multiply showed. LoRA adds a small pair of matrices B and A beside a frozen weight matrix, and the rank is how many columns B has, as A LoRA Run ran. Fine-tuning changes how a model behaves by moving its weights a little, as Fine-tuning & Alignment showed. An average over many cases is called an expectation, and the spread around it is called variance, as Odds and surprise: probability and information for ML set up.

Lesson 15 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

  • Rank: how many rows a table cannot build from the others
  • Eigenvector: a direction a matrix only stretches
  • Singular value decomposition: any table is a stack of rank-one layers, strongest first
  • Low-rank approximation: keep the strong layers, drop the rest
  • PCA: the direction where the data spreads most
  • Why LoRA works: the change is a low-rank table
  • PCA in five lines
  • The rank, the SVD and the cut-down table
  • Eigenvectors and PCA
  • LoRA’s bet, measured on a made-up change
  • Edge cases and real systems

Terms it explains: rank, eigenvector, eigenvalue, singular value decomposition, singular values, low-rank approximation, principal component, principal component analysis, Common mistakes, 2, " sum:", (s, 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