PROGRAM ZERO 18-month live AI, LLM & full-stack programme · ₹17,999 for all 18 months · Starts 9 January 2027
Explore Program Zero →
Careers Ninza — business and startup leadership training
JOIN ZERO NINZA KIDS
JOIN ZERO NINZA KIDS
See all programs → Free live masterclass → Guides & articles → Newsletter →
Careers Ninza
AI & AUTOMATION 9 min read · Updated 13 October 2026

RLHF and DPO explained: how language models learn to be helpful

A pretrained model predicts text; an assistant follows instructions. The bridge is alignment: instruction tuning, RLHF and DPO. How each works, how they differ, and their honest limitations.

CN
Careers Ninza AI faculty
Careers Ninza · Kolkata, India
Learn this live in Program Zero

Alignment turns a pretrained language model, which only predicts the next token, into an assistant that follows instructions helpfully and safely. It usually happens in stages: supervised instruction tuning on example conversations, then preference training, either RLHF, which trains a reward model and optimises against it with reinforcement learning, or DPO, which learns directly from preferred and rejected answers.

If you have ever wondered why a raw pretrained model rambles while a chat assistant answers your question, this is the reason. Alignment is also one of the most active research areas, and understanding it helps you reason about model behaviour, refusals and failure modes.

Why does a pretrained model need alignment?

Pretraining teaches a model to continue text the way the internet does. Ask it a question and it might continue with more questions, a forum argument or an unrelated paragraph. It has knowledge, but no reliable sense of what a helpful, honest, safe answer looks like. Alignment teaches that behaviour.

What is instruction tuning?

Supervised fine-tuning (SFT) trains the model on curated examples of instructions paired with good responses. It is ordinary fine-tuning, but on carefully written or selected conversations. SFT alone already transforms behaviour, and its quality depends heavily on the quality and diversity of the examples.

How does RLHF work?

—Collect comparisons: for many prompts, people rank or choose between several model answers.
—Train a reward model: a model learns to predict which answer people prefer.
—Optimise the policy: the language model is trained with reinforcement learning, commonly PPO, to produce answers the reward model scores highly.
—Stay close to the original: a penalty keeps the model from drifting too far and exploiting quirks of the reward model.

This approach was described in research on training language models to follow instructions with human feedback, which became the template for many chat assistants.

What is DPO and why did it become popular?

Direct Preference Optimization starts from the same preference data but skips the separate reward model and reinforcement learning step. Its authors noted that RLHF is complex and often unstable; DPO instead uses a simple classification-style loss that increases the probability of preferred answers relative to rejected ones. It is simpler to implement and tune, which is why it spread quickly.

RLHF (PPO)DPO
Needs a reward modelYesNo
Uses reinforcement learningYesNo
ComplexityHigh: several models and careful tuningLower: a single training objective
DataHuman preference comparisonsThe same kind of preference pairs
Typical useLarge-scale assistant trainingWidely used for open models and research

What are the limitations of alignment?

—Models learn what raters prefer, which is not always what is true.
—Preference data can encode the biases of whoever wrote or rated it.
—Optimising hard against a reward model can produce answers that look good but are wrong, sometimes called reward hacking.
—Alignment does not add knowledge; it shapes behaviour around what the model already learned.
—Over-cautious tuning can make models refuse reasonable requests.

Alignment is one layer of safety, not the whole of it. Production systems still need evaluation, guardrails, monitoring and human oversight for consequential decisions.

Where does preference data come from?

From people comparing answers, from experts writing ideal responses, and increasingly from AI-assisted labelling checked by humans. The quality and diversity of this data matter more than its size. For an Indian product, that means raters who understand local context, languages and expectations, otherwise the model learns preferences that do not fit its users.

What is constitutional or AI-assisted feedback?

Some approaches reduce the need for human ratings by having a model critique and revise answers against a written set of principles, then train on those preferences. These methods can scale feedback, but the principles and the checking still come from people, and the results still need evaluation.

Can you do preference tuning on a small budget?

Yes, at small scale. With an open model, parameter-efficient methods such as LoRA and a few thousand preference pairs, you can run DPO on modest hardware and see real behaviour changes. It is an excellent learning project because it connects data, training and evaluation. Our walkthrough of how small language models are trained shows where this fits in the pipeline.

What does an alignment project look like for a learner?

A practical project: take a small open model, write or collect a few hundred instruction examples for a narrow task such as answering course-fee questions politely and accurately, fine-tune with LoRA, then create preference pairs where one answer is clearly better and run DPO. Compare the base, SFT and DPO versions on the same test prompts, including attempts to make the model promise outcomes it should not. The before-and-after comparison teaches more than any lecture.

How does this connect to evaluation?

You cannot tell whether alignment helped without testing. Build a set of prompts covering helpfulness, honesty and safety, compare outputs before and after, and include adversarial prompts. Our guide to evaluating LLM applications covers how.

Where do you learn alignment hands-on?

Program Zero’s advanced LLM engineering phase includes an SFT pipeline, instruction-data curation, reward model training, PPO for RLHF, DPO, red-teaming and guardrail design, building on the earlier phase where you train a small GPT.

Program Zero runs live online, so you can learn this from anywhere in India: metros such as Bengaluru, Pune, Hyderabad and Noida, growing cities such as Lucknow, Kanpur, Visakhapatnam and Madurai, and smaller towns such as Siliguri, Jamshedpur, Durgapur and Cuttack. Every learner joins the same evening classes, at the same fee.

Want to learn this live, with mentors?

In Program Zero you implement SFT, a reward model, RLHF and DPO hands-on, after building a small GPT yourself, over 18 months of live evening classes. ₹17,999 for all 18 months; the batch starts 9 January 2027.

PROGRAM ZERO · 18-MONTH LIVE PROGRAMME
Program Zero: AI, LLM & Full-Stack Developer Programme

Learn AI, large language models and full-stack development live with mentors: from your first line of code to building and deploying your own language model.

₹17,999 for all 18 monthsStarts 9 January 2027Mon–Fri, 9:00–10:30 PM ISTEvery class recorded

Frequently asked questions

What is RLHF in AI?+

RLHF, reinforcement learning from human feedback, aligns a language model by collecting human comparisons of answers, training a reward model to predict preferred answers, and then optimising the model with reinforcement learning to score highly while staying close to its original behaviour.

What is DPO in machine learning?+

DPO, Direct Preference Optimization, aligns a language model directly from pairs of preferred and rejected answers, without training a separate reward model or using reinforcement learning. It uses a simpler training objective, which makes it easier to implement and tune.

What is the difference between RLHF and DPO?+

Both use human preference data. RLHF trains a reward model and then optimises the language model with reinforcement learning, which is complex. DPO skips both steps and directly increases the probability of preferred answers relative to rejected ones.

What is instruction tuning?+

Instruction tuning, or supervised fine-tuning, trains a pretrained model on examples of instructions paired with good responses. It teaches the model to follow requests helpfully and is usually the first alignment step before preference training.

Does alignment make AI models safe?+

It reduces harmful and unhelpful behaviour but does not guarantee safety. Models can still be wrong, biased or manipulated, so production systems also need evaluation, guardrails, monitoring and human oversight for important decisions.

What is a reward model?+

A reward model is a model trained to predict which of several answers people would prefer. In RLHF it provides the signal the language model is optimised against, so its quality strongly affects the final behaviour.

Can I fine-tune a model with DPO myself?+

Yes, at small scale. With an open model, LoRA and a modest set of preference pairs, DPO can run on limited hardware. It is a valuable learning project that connects data preparation, training and evaluation.

Where can I learn LLM alignment in India?+

Program Zero by Careers Ninza covers SFT, reward models, RLHF with PPO, DPO, red-teaming and guardrails in its advanced LLM engineering phase, within an 18-month live programme for Rs 17,999.

Related reading

AI & AUTOMATION LLM Course: What You Should Learn to Build Large Language Models Most LLM courses teach you to call an API. Building and adapting language models needs more: tokenisers, transformers, training, fine-tuning, alignment, evaluation and serving. Here is the full syllabus, in order. 10 min read AI & AUTOMATION Agentic AI Course: The Skills You Need to Build AI Agents in 2027 Building reliable AI agents takes more than chaining prompts. The skills an agentic AI course should teach, from tool use and memory to evaluation, security and deployment, and how to judge a course. 10 min read AI & AUTOMATION What Is Tokenization in LLMs? BPE, WordPiece and SentencePiece Explained Before a language model reads a word, a tokenizer chops text into pieces. How BPE, WordPiece and SentencePiece work, why tokens decide cost and context, and why Indian languages are affected most. 9 min read

We teach this, live

Every article here comes from something we teach. Sit in on a free masterclass and judge the mentors yourself.