RLHF & DPO Explained: How Human Feedback Shapes AI | LLM Course #27
Beginner-level AI & ML video in Tamil by Programming Line, 5 minutes long, published 1 Dec 2026.
How do chat models learn which answers people prefer? In Lecture 27 of the LLM Masterclass we cover RLHF (human rankings, a reward model and PPO, as in InstructGPT), DPO (one simple loss on chosen and rejected replies, against a frozen reference), and constitutional AI in a sentence. Then we run DPO on ChotuGPT and watch its rude replies turn polite, and see what happens without the extra fluency term. 💻 Code for this lecture (branch lecture-27): https://github.com/programmingline/chotugpt/tree/lecture-27 Lecture 27 of 32 — LLM Masterclass · Module 5: Training an LLM ⚠️ ChotuGPT is a simplified teaching model, tuned here on only 6 preference pairs. The reward-model scores in the RLHF diagram are illustrative numbers for teaching only; every ChotuGPT number comes from the real script output. In this lecture: • Why preferences: SFT copies its examples (including bad ones), and comparing two answers is easier than writing one • RLHF: people rank answers (InstructGPT: 4 to 9 per prompt), a reward model learns to score preferred answers higher • PPO in plain words: generate, score with the reward model, nudge toward higher scores, with a penalty to stay close to the SFT model • InstructGPT (2022): people preferred the 1.3B InstructGPT over the 175B GPT-3 • DPO (Rafailov et al., 2023): no reward model, no RL loop; loss = −log σ(β · margin) against a frozen reference • Constitutional AI (Bai et al., 2022): written principles, self-critique and AI feedback • ChotuGPT DPO: 6 pairs, β = 0.1, 40 steps; loss 0.8562 → 0.0586, mean margin 0 → 57.35 • "No. Make it yourself." → "Yes, please sit down and have some tea."; pure DPO (no NLL term) breaks the end marker Chapters: 00:00 Lecture 26 quiz answer 00:13 RLHF, reward models and DPO 00:26 Why preferences? 00:41 RLHF: the reward model 01:07 What people like 01:13 PPO in plain words 01:41 DPO: direct preference optimization 02:11 Constitutional AI 02:26 DPO on ChotuGPT 02:48 chotugpt/dpo.py 03:17 Quiz 03:39 DPO results 04:09 Why the extra term? 04:28 Recap & next lecture ✅ Lecture 26 quiz answer: A, to follow instructions, from example conversations. ❓ Quiz: In RLHF, what does the reward model learn? A) How to split text into tokens B) The size of the vocabulary C) Which answers people prefer. Comment your answer. I reveal it in Lecture 28! 👍 Like, subscribe and comment your quiz answer. ⏮ Previous: Lecture 26 — From base model to assistant: SFT ⏭ Next: Lecture 28 — Decoding: greedy, temperature, top-k, top-p Sources: L. Ouyang et al., "Training language models to follow instructions with human feedback" (InstructGPT), arXiv:2203.02155, 2022. R. Rafailov et al., "Direct Preference Optimization: Your Language Model is Secretly a Reward Model", NeurIPS 2023, arXiv:2305.18290. Y. Bai et al., "Constitutional AI: Harmlessness from AI Feedback", arXiv:2212.08073, 2022. A. Dubey et al. (Llama Team, Meta), "The Llama 3 Herd of Models", arXiv:2407.21783, 2024 (DPO with an NLL term on chosen responses). #LLM #RLHF #DPO…more
How do chat models learn which answers people prefer? In Lecture 27 of the LLM Masterclass we cover RLHF (human rankings, a reward model and PPO, as in InstructGPT), DPO (one simple loss on chosen and rejected replies, against a frozen reference), and constitutional AI in a sentence. Then we run DPO on ChotuGPT and watch its rude replies turn polite, and see what happens without the extra fluency term. 💻 Code for this lecture (branch lecture-27): https://github.com/programmingline/chotugpt/tree/lecture-27 Lecture 27 of 32 — LLM Masterclass · Module 5: Training an LLM ⚠️ ChotuGPT is a simplified teaching model, tuned here on only 6 preference pairs. The reward-model scores in the RLHF diagram are illustrative numbers for teaching only; every ChotuGPT number comes from the real script output. In this lecture: • Why preferences: SFT copies its examples (including bad ones), and comparing two answers is easier than writing one • RLHF: people rank answers (InstructGPT: 4 to 9 per prompt), a reward model learns to score preferred answers higher • PPO in plain words: generate, score with the reward model, nudge toward higher scores, with a penalty to stay close to the SFT model • InstructGPT (2022): people preferred the 1.3B InstructGPT over the 175B GPT-3 • DPO (Rafailov et al., 2023): no reward model, no RL loop; loss = −log σ(β · margin) against a frozen reference • Constitutional AI (Bai et al., 2022): written principles, self-critique and AI feedback • ChotuGPT DPO: 6 pairs, β = 0.1, 40 steps; loss 0.8562 → 0.0586, mean margin 0 → 57.35 • "No. Make it yourself." → "Yes, please sit down and have some tea."; pure DPO (no NLL term) breaks the end marker Chapters: 00:00 Lecture 26 quiz answer 00:13 RLHF, reward models and DPO 00:26 Why preferences? 00:41 RLHF: the reward model 01:07 What people like 01:13 PPO in plain words 01:41 DPO: direct preference optimization 02:11 Constitutional AI 02:26 DPO on ChotuGPT 02:48 chotugpt/dpo.py 03:17 Quiz 03:39 DPO results 04:09 Why the extra term? 04:28 Recap & next lecture ✅ Lecture 26 quiz answer: A, to follow instructions, from example conversations. ❓ Quiz: In RLHF, what does the reward model learn? A) How to split text into tokens B) The size of the vocabulary C) Which answers people prefer. Comment your answer. I reveal it in Lecture 28! 👍 Like, subscribe and comment your quiz answer. ⏮ Previous: Lecture 26 — From base model to assistant: SFT ⏭ Next: Lecture 28 — Decoding: greedy, temperature, top-k, top-p Sources: L. Ouyang et al., "Training language models to follow instructions with human feedback" (InstructGPT), arXiv:2203.02155, 2022. R. Rafailov et al., "Direct Preference Optimization: Your Language Model is Secretly a Reward Model", NeurIPS 2023, arXiv:2305.18290. Y. Bai et al., "Constitutional AI: Harmlessness from AI Feedback", arXiv:2212.08073, 2022. A. Dubey et al. (Llama Team, Meta), "The Llama 3 Herd of Models", arXiv:2407.21783, 2024 (DPO with an NLL term on chosen responses). #LLM #RLHF #DPO