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:

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.

Two more rounds of training turn a base model into a chat model. Here are all three rounds:

  1. Round 1๐Ÿ“š Read text

    Reads trillions of tokens (lakhs of crores) and learns to continue text.

  2. Round 2๐Ÿ’ฌ Learn to answer

    Trains on thousands of questions paired with good answers.

  3. 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.

QuestionWhat is the capital of India?AnswerNew Delhi (kept for the check)

Chance of each next word after the question (made-up numbers)

  • 2.โ€“
  • Isโ€“
  • Newโ€“
  • other wordsโ€“

Green marks New, the first word of the example's answer.

Step 1 of 5

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:

How one reply happens:

  1. You type What is 1 + 1?
  2. The chat app puts markers around it, and adds <|assistant|> at the end.
  3. The model continues the text. After <|assistant|>, an answer is the likely next text.
  4. Instruction tuning made it likely. Its training pairs were written with the answer after <|assistant|>.
  5. When the answer is finished, the model writes <|end|>. The app stops asking for more words.
  6. 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.

A question and two answers the model wrote (made-up answers and scores)

QuestionHow do I make my chai less bitter?

Answer ABoil it for less time, or use fewer tea leaves.๐Ÿ‘ Picked ยท score 9
Answer BChai tastes bitter because of tannins in the tea leaves.Not picked ยท score 3

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.

Step 1 of 5

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):

RequestMy payment failed twice.Answer you wantbilling

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:

โŒ Bad for facts:

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.

  1. โœ๏ธ A better prompt. Say exactly what you want, and show an example. Example: Reply in 3 short points, like this: โ€ฆ
  2. ๐Ÿ“„ RAG, for your own documents. Example: the two pages about returns from a 500-page policy PDF. Lesson 9 shows how.
  3. ๐Ÿ”ง 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.

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.

← Lesson 6  ·  All lessons  ·  Next lesson →

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 messages list of user and assistant turns), 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.