Syllabus Lesson 212 of 246 · Module 20: Adapting a trained model cheaply
Module 20: Adapting a trained model cheaply

Fine-tune the GPT on your own text

Why it matters This is the everyday use: a general model, your text, a cheap adapter. The test is whether it learned your text and kept the rest.

Put your own text in my_text: notes, an essay, code you wrote, at least 5,000 characters (the default is a slice of the Python solutions so the lesson runs as given). Characters the model has never seen are dropped. The last 20% is kept aside to test on.

Train LoRA, rank 8, for 60 steps of 8 windows. Pass when the held-out part of your text scores at least 0.3 better than the base model did, and the English loss rose by less than 0.5. For scale, on the default text: LoRA raises English by about 0.29, full fine-tuning by about 0.69, and both learn the text about equally well.

Words and symbols in this lesson
fine-tuning
continuing to train a trained model on new data
LoRA
low-rank adaptation: a frozen weight matrix plus two thin trainable ones, x W + (alpha / r) x A B
rank (r)
how thin LoRA's two matrices are: (d_in + d_out) x r trainable weights per matrix
Your turn

Fill base_scores and tuned_scores: (English loss, loss on the held-out 20% of your text) before and after training the LoRA model.

Spotted a problem in this lesson? Report it · Ask about this lesson

This exercise opens soon

Finish the lesson before it and this one unlocks. The whole course is free, no account needed, and you can read this lesson right now.