Skip to main content

The Alignment Stack: RLHF → DPO → GRPO — Training & Alignment

[ ABORT TO HUD ]
SEQ. 1
SEQ. 2

The Alignment Stack: RLHF → DPO → GRPO

⚖️ Training & Alignment⏱ 12 min⭐ 150 BASE XP⌨ HANDS-ON LAB

Modern Post-Training Pipeline

Raw pre-trained models are "completion engines" - they continue text, not follow instructions. Alignment transforms them into useful assistants.

The Three Stages

StagePurposeTechnique
1. SFTInstruction following, format, conversational styleSupervised Fine-Tuning on instruction datasets
2. PreferenceAlign with human values and preferencesDPO, KTO, SimPO (no reward model needed)
3. RLPush beyond training data for reasoningGRPO, RLVR (for math/code verification)

Technique Comparison

MethodComplexityMemoryBest For
RLHF (PPO)High (needs reward model + critic)~4x model sizeClassic, proven approach
DPOLow (direct from preference pairs)~2x model sizeSimple, stable preference alignment
GRPOMedium (group-wise comparison)~2x model sizeReasoning, no critic needed

GRPO (popularized by DeepSeek-R1) generates multiple answers per prompt, compares them within the group, and optimizes accordingly - eliminating the separate "critic" model that PPO requires.

Runnable GRPO & DPO with Hugging Face TRL

from trl import GRPOTrainer, GRPOConfig, DPOTrainer, DPOConfig

# Verifiable reward function for math/code reasoning (GRPO)
def format_and_answer_reward(completions, **kwargs):
    return [1.0 if "<think>" in c and "</think>" in c else 0.0 for c in completions]

grpo_trainer = GRPOTrainer(
    model="Qwen/Qwen3-4B",
    reward_funcs=[format_and_answer_reward],
    args=GRPOConfig(output_dir="./grpo_out", learning_rate=5e-6, bf16=True, use_vllm=True),
    train_dataset=reasoning_dataset,
)
grpo_trainer.train()
💡 2026 Consensus: The era of one-size-fits-all alignment is over. Modern stacks are modular: SFT for format → DPO for preferences → GRPO for reasoning. Mix and match based on your use case.
⌨ HANDS-ON LABTrain Preference Adapter with TRL DPO
⭐ +200 XP

Run Direct Preference Optimization using Hugging Face TRL to align model responses with human preferences without a separate reward model.

1Invoke the TRL DPO CLI with a model path and preference dataset.
lab-sandbox — simulated environment
INFINITY LAB SANDBOX v2.6 — simulated shell
Type the command for the current objective. Helpers: "hint", "solution", "clear".
$
OBJECTIVE 1 / 1 — type "hint" if stuck
KNOWLEDGE CHECK
QUERY 1 // 2
What does DPO eliminate compared to RLHF?
The training data
The need for a separate reward model
The base model
The tokenizer