MLCrack

    LLMS & TRANSFORMERS · INTERVIEW QUESTION

    Explain RLHF (Reinforcement Learning from Human Feedback). What are the key steps and challenges?

    🔴 advanced · RLHF & Alignment

    Hint: Think about the reward model, PPO, and the KL penalty.

    Answer

    RLHF aligns language models with human preferences through a three-stage pipeline.

    Pipeline

    Base Model → SFT → Reward Model → PPO → Aligned Model

    Stage 1: Supervised Fine-Tuning (SFT)

    Train on high-quality human-written demonstrations of ideal behavior.

    Stage 2: Reward Model Training

    Collect human preference comparisons (A vs B), train a reward model R(x,y)R(x, y) to predict which output humans prefer.

    Stage 3: RL Optimization (PPO)

    max⁡θE[R(x,y)−β⋅DKL(πθ∥πref)]\max_\theta \mathbb{E}\left[R(x, y) - \beta \cdot D_{KL}(\pi_\theta \| \pi_{\text{ref}})\right]

    The KL penalty prevents the model from diverging too far from the SFT model.

    Challenges

    • Reward hacking: model exploits reward model weaknesses
    • Distribution shift: reward model trained on narrow data
    • Labeling inconsistency: humans disagree on preferences
    • Computational cost: requires training 3 separate models

    Alternatives

    • DPO: directly optimizes on preference pairs, skips reward model — simpler and often competitive
    • Constitutional AI: self-critique against principles
    • RLAIF: AI feedback instead of human