Lesson 7
How did a text-finisher become an assistant?
A model trained only to continue text does not answer questions. Ask it What is 1 + 1? and it writes more questions (lesson 1). This lesson shows the two extra rounds of training that turn it into an assistant that answers. Then it shows when a company should add one more round of training on its own examples, and what to try before that.
1What can a model do after reading the internet?
A model that has only read text can continue text. It cannot do anything else yet.
Pre-training is the first round of training: the model reads a huge amount of text and learns to guess the next word.
How pre-training works, with lesson 2's ๐ฏ guess, ๐ check and ๐ง nudge:
- ๐ฅWhat goes in: text from web pages, books and more. Llama 3, a model from Meta, read over 15 trillion tokens (15 lakh crore).
- ๐ฏGuess: the model reads part of a sentence and gives every next word a chance. It reads I have a pet. At the start, dog gets only 0.01% (lesson 2's made-up numbers).
- ๐Check: the guess is compared with the word that really comes next in the text. The text says I have a pet dog, so the right word is dog.
- ๐งNudge: the dials (parameters, lesson 2) move a tiny bit, so that dog gets a higher chance next time. One nudge moves dog from 0.01% to 0.012%. After all the nudges, dog has 38%, as in lesson 1.
- ๐งฉThe trained model is called a base model. It continues any text you give it. Send it Once upon a time and it writes the next lines of a story.
A base model does not answer your question. It writes what usually comes after text like yours.
Base model (pre-training only)
You sendWhat is 1 + 1?
It sends back2. What is 1 + 1 + 1?3. What is 1 + 1 + 1 + 1?โฆ
Chat model (after two more rounds)
You sendWhat is 1 + 1?
It sends back1 + 1 = 2.
The same question sent to two models, and the text each one sends back. The base model's reply comes from a book (see the sources below). The chat model's reply is our example.
- ๐To the base model, your question looks like question 1 in a list of maths questions. It writes question 2, What is 1 + 1 + 1?, then question 3.
- โช๏ธIt gives back more of your text. It does not give you the answer.
Two more rounds of training turn a base model into a chat model. Here are all three rounds:
- Round 1๐ Read text
Reads trillions of tokens (lakhs of crores) and learns to continue text.
- Round 2๐ฌ Learn to answer
Trains on thousands of questions paired with good answers.
- Round 3๐ Learn what people prefer
Learns from people picking the better of two answers.
2How does a model learn to answer a question?
Instruction tuning is the second round of training: the base model trains on questions, each paired with a good answer.
It uses the same three steps as pre-training: ๐ฏ guess, ๐ check, ๐ง nudge. The example below is a training pair from lesson 1. Use the buttons to go through it one step at a time:
๐ฅ 1. The question goes in
The model reads the question. It does not see the answer yet.
๐ฏ 2. The model guesses the next word
It gives every word a chance. A base model expects the next question in a list, as in section 1, so 2. gets the highest chance.
๐ 3. Check against the example
The example's answer starts with New. The model gave New only 5%, and 2. 40%.
๐ง 4. Nudge
The dials move a tiny bit, so that New gets a higher chance after this question. One nudge moves New from 5% to 6%.
๐ 5. Repeat with thousands of examples
After thousands of question-answer pairs, New gets 80%. The next word, Delhi, is learned the same way.
Green marks New, the first word of the example's answer.
- ๐ขInstruction tuning needs far less text than pre-training. Thousands of question-answer pairs here. Over 15 trillion tokens (15 lakh crore) for Llama 3 in section 1.
- ๐ง The model still only guesses the next word. Only the chances changed. After What is the capital of India?, New now has a higher chance than 2.
3What does a chat look like to the model?
To the model, a whole chat is one long piece of text. Markers that you never see show who is speaking.
Here are the real markers of Phi-3-mini, the small open model from Microsoft that lessons 4 and 5 used.
<|user|> What is 1 + 1?<|end|> <|assistant|> 1 + 1 = 2.<|end|>
One short chat, written out the way the model reads it. The markers are Phi-3-mini's real ones. The question and the answer are our example.
What each marker means:
- ๐
<|user|>Your message starts here. - ๐ค
<|assistant|>The reply starts here. - โน๏ธ
<|end|>A message ends here. It is the model's stop mark, like โน end in lesson 1.
How one reply happens:
- You type What is 1 + 1?
- The chat app puts markers around it, and adds
<|assistant|>at the end. - The model continues the text. After
<|assistant|>, an answer is the likely next text. - Instruction tuning made it likely. Its training pairs were written with the answer after
<|assistant|>. - When the answer is finished, the model writes
<|end|>. The app stops asking for more words. - The app removes the markers and shows you only 1 + 1 = 2.
4How does a model learn which answers people prefer?
Preference tuning is the third round of training: people pick the better of two answers, and the model is nudged towards the kind of answer they pick.
Here is one common way to do it. Use the buttons to go through it one step at a time:
๐ฅ 1. A question goes in
The model gets a question from a long list of questions.
โ๏ธ 2. The model writes two answers
Both answers are about chai. Both are true.
๐ 3. A person picks the better one
The person picks A, because it tells you what to do. B is true, but it does not help. In lesson 1, the ๐ went to 2 over 1 + 1 + 1, a reply that does not answer. Here both answers are true, and A still wins because it helps more.
๐งฎ 4. A scoring model learns from the picks
Tens of thousands of picks like this train a second model, the scoring model. It learns to give answers like A a higher score than answers like B.
๐ง 5. The chat model is nudged
The chat model writes answers to new questions. The scoring model gives each one a score, so no person is needed now. The chat model's dials move a little towards the answers with a high score. Next time, an answer like A is more likely.
QuestionHow do I make my chai less bitter?
One preference example: a question, two answers, a person's pick, and the score the scoring model gives each answer. A higher score means a better answer.
- ๐Preference tuning is not the same as instruction tuning. Instruction tuning gives the model an answer to copy: New Delhi. Preference tuning only says which of two answers is better: A, not B.
- โ๏ธSome newer methods skip the scoring model. They use the pick, A over B, to nudge the chat model directly: answers like A become more likely, answers like B less likely.
- ๐Most of a chat model's habit of saying no to harmful requests comes from this round. Asked how to use a neighbour's Wi-Fi without the password, people pick the answer that says no.
- โ๏ธThese two extra rounds can matter more than size. In a 2022 OpenAI test, people preferred the answers of a tuned model with 1.3 billion (130 crore) dials over GPT-3 with 175 billion (17,500 crore) dials, which had only pre-training.
5Should a company train a model on its own examples?
Sometimes. A company fine-tunes mostly to change how a model behaves, not what it knows.
Fine-tuning is more training for a model that is already trained, using your own examples.
How it works (the same way as instruction tuning in section 2):
- ๐ฅYou write requests, each with the answer you want. The card below: a support ticket, and the label billing.
- ๐ฏThe model guesses an answer. It guesses refund.
- ๐The guess is checked against your answer. Your answer says billing, so refund is wrong.
- ๐งThe dials are nudged. billing gets a higher chance after this ticket next time.
One fine-tuning example: a support ticket, and the label we want back. Our example. A real fine-tuning file holds many of these, one on each line.
โ Good for behaviour:
- ๐ฃ๏ธA fixed tone. Always short and polite, like your best support agent.
- ๐ท๏ธOne narrow job. Sort support tickets into five types, like the billing example above.
โ Bad for facts:
- ๐ The model keeps old facts. Your return window changes from 7 days to 10. The tuned model still says 7 until you train it again.
- ๐It can't show where an answer came from. Ask the tuned model how many days you have to return an item. It says 7, but it can't show you the policy page that says so. With RAG (section 6), the page itself is in the prompt.
6Which should you try first: a better prompt, RAG or fine-tuning?
Try a better prompt first, then RAG, then fine-tuning. RAG means your code finds the right pages in your own documents and puts them into the prompt. Each of the three takes more work than the one before.
- โ๏ธ A better prompt. Say exactly what you want, and show an example. Example: Reply in 3 short points, like this: โฆ
- ๐ RAG, for your own documents. Example: the two pages about returns from a 500-page policy PDF. Lesson 9 shows how.
- ๐ง Fine-tuning, for behaviour. Example: the ticket sorter from section 5.
Move to the next one only when the one before is not enough. The short rule: RAG for knowledge, fine-tuning for behaviour.
- ๐ปKnowledge that changes often belongs in the prompt, not in the dials. You want an assistant that knows your team's code. The code changes every day, so a fine-tuned model would soon hold old code. Coding tools like GitHub Copilot, Cursor and Claude Code read the right files and put that code into the prompt instead.
The training and every reply run on huge computers. Why does every token you send or get back cost money? The next lesson starts there.
Where this comes from
- Three training rounds: pre-training, instruction tuning, preference tuning: Hands-On Large Language Models (Alammar, Grootendorst; O'Reilly 2024), ch.12, PDF p.487-489, figure 12-3 (untrained, base, instruction-tuned, preference-tuned). Instruction tuning and preference tuning as separate stages: Rahul's course blueprint, Module 3.2-3.3 and Part 4, misconception 7 (notes/llm-course-blueprint.md).
- Base model: continues text, doesn't answer: Hands-On Large Language Models, ch.12, PDF p.488-489 (a base model is "harder for the end user to deal with"). How Large Language Models Work (Raff, Farris, Biderman; Manning 2025), ch.5, PDF p.90: a base model is "not trained to answer questions, think, summarize text, hold a conversation, or anything else".
- Llama 3, over 15 trillion tokens (15 lakh crore): Meta, "Introducing Meta Llama 3" (18 April 2024): "Llama 3 is pretrained on over 15T tokens". ai.meta.com/blog/meta-llama-3 (checked for lesson 2).
- "What is 1 + 1?" from a base model: Hands-On Large Language Models, ch.12, figure 12-5, PDF p.490: "2. What is 1 + 1 + 1? 3. What is 1 + 1 + 1 + 1? ...", because the model "will attempt to complete a question rather than answer it".
- Instruction tuning: question-answer pairs, still next-word guessing: Hands-On Large Language Models, ch.12, PDF p.489-492 (supervised fine-tuning on instruction-response pairs; still next-token prediction "based on a user input"). How Large Language Models Work, ch.5, PDF p.93-94 (the same training loop, starting from the base model, on "a little data, but specific"). After a question, the likely next text is an answer: Rahul's blueprint, Module 3.2.
- Thousands of question-answer pairs; tens of thousands of picks: How Large Language Models Work, ch.5, PDF p.96-97: "SFT can work with thousands of documents or samples, whereas RLHF often requires tens of thousands of examples".
- The chat markers: Hands-On Large Language Models, ch.6, figure 6-2, PDF p.238-239: Phi-3-mini's template, with
<|end|>marking the end of the prompt and of the output; the template "was used during the training of the model" and<|end|>tells it when to stop. Checked against the model's live files on 2026-10-31: tokenizer_config.json writes each message as<|user|>or<|assistant|>, a new line, the text, then<|end|>, and adds<|assistant|>at the end for a reply;<|end|>(token 32007) is one of the stop tokens in generation_config.json. The book's figure also shows a start marker,<s>; the current template no longer adds it, so the lesson leaves it out. ch.12, figure 12-19, PDF p.503: instruction-tuning data is written in the chat template. - Preference tuning: two answers, a person picks, a scoring model, a nudge: Hands-On Large Language Models, ch.12, PDF p.518-526: preference data is a prompt with an accepted and a rejected answer, often made by generating two answers and asking people which they prefer ("the two generations are both good, but ... one is better"); a reward model learns to score them, and the LLM is then trained towards higher-scoring answers. Methods that skip the reward model: ch.12, PDF p.526-527 (DPO "does away with the reinforcement-based learning procedureโฆ Instead of using the reward model to judge the quality of a generation, we let the LLM itself do that", and trains on the accepted and rejected answers). How Large Language Models Work, ch.5, PDF p.96-101 (RLHF and the reward model; "RLHF often requires tens of thousands of examples").
- Refusals come mostly from preference tuning: Rahul's blueprint, Module 3.3 and 3.7 (safety training mostly in preference tuning; chat apps also add separate filters, not covered here). Hands-On Large Language Models, ch.12, PDF p.525: Llama 2 trains two reward models, one for helpfulness and one for safety.
- 1.3 billion (130 crore) preferred to 175 billion (17,500 crore): Ouyang et al., "Training language models to follow instructions with human feedback" (OpenAI), arXiv v1 4 March 2022: "outputs from the 1.3B parameter InstructGPT model are preferred to outputs from the 175B GPT-3". arxiv.org/abs/2203.02155. InstructGPT was trained with both supervised examples and human rankings. "Dials" is the course's plain word for parameters (lesson 2).
- Your own fine-tune: behaviour yes, facts no: Rahul's blueprint, Module 3.4 and Part 4, misconception 8 ("RAG for knowledge, fine-tuning for behavior"); Part 5: custom fine-tunes are almost always supervised. How Large Language Models Work, ch.5, PDF p.92-93: any fine-tune gives "a new variant of an LLM with updated parameters".
- A fine-tuning file, one example on each line: OpenAI API docs, "Supervised fine-tuning", Formatting your data: "Use JSONL format, with one complete JSON structure on every line", in the chat completions format (a
messageslist ofuserandassistantturns), at least 10 lines. developers.openai.com/api/docs/guides/supervised-fine-tuning (via Context7, 2026-10-31). - Prompt first, then RAG, then fine-tuning: Rahul's blueprint, Module 3.6 ("Always try in this order: prompt โ RAG โ fine-tune"). How Large Language Models Work, ch.5, PDF p.93: prompting first, "fine-tuning is the next logical step if that does not work well".
- A team coding assistant doesn't need fine-tuning: Rahul's blueprint, Module 3.7 (give the model your code as context, as Copilot, Cursor and Claude Code do; code changes daily, so a tuned model goes stale).
- Made up on purpose: the chat model's reply "1 + 1 = 2."; every percentage in the India bars (2. 40 / Is 20 / New 5 / other 35%, then 39 / 20 / 6 / 35% after one nudge, then 2 / 1 / 80 / 17%); the chai question, both answers and the scores 9 and 3; the Wi-Fi refusal example; the "Once upon a time" story example; the support ticket, the guess "refund", the return-window example. The India and "1 + 1" question-answer pairs are lesson 1's examples. The base model's reply and Phi-3-mini's markers are real.