rlhf
БесплатноБез исполняемых скриптовНе проверенUnderstanding Reinforcement Learning from Human Feedback (RLHF) for aligning language models. Use when learning about preference data, reward modeling, policy…
Об этом скилле
Understanding RLHF
Reinforcement Learning from Human Feedback (RLHF) is a technique for aligning language models with human preferences. Rather than relying solely on next-token prediction, RLHF uses human judgment to guide model behavior toward helpful, harmless, and honest outputs.
Table of Contents
- Core Concepts
- The RLHF Pipeline
- Preference Data
- Instruction Tuning
- Reward Modeling
- Policy Optimization
- Direct Alignment Algorithms
- Challenges
- Best Practices
- References
Core Concepts
Why RLHF?
Pretraining produces models that predict likely text, not necessarily good text. A model trained on internet data learns to complete text in ways that reflect its training distribution—including toxic, unhelpful, or dishonest patterns. RLHF addresses this gap by optimizing for human preferences rather than likelihood.
The core insight: humans can often recognize good outputs more easily than they can specify what makes an output good. RLHF exploits this by collecting human judgments and using them to shape model behavior.
The Alignment Problem
Language models face several alignment challenges:
- Helpfulness: Following instructions and providing useful information
- Harmlessness: Avoiding toxic, dangerous, or inappropriate outputs
- Honesty: Acknowledging uncertainty and avoiding fabrication
- Intent alignment: Understanding what users actually want, not just what they say
RLHF provides a framework for encoding these properties through preference data.
Key Components
- Preference data: Human judgments comparing model outputs
- Reward model: A learned function approximating human preferences
- Policy optimization: RL algorithms that maximize expected reward
- Regularization: Constraints preventing deviation from the base model
The RLHF Pipeline
The standard RLHF pipeline consists of three main stages:
Stage 1: Supervised Fine-Tuning (SFT)
Start with a pretrained language model and fine-tune it on high-quality demonstrations. This teaches the model the desired format and style of responses.
Input: Pretrained model + demonstration dataset Output: SFT model that can follow instructions
Stage 2: Reward Model Training
Train a model to predict human preferences between pairs of outputs. The reward model learns to score outputs in a way that correlates with human judgment.
Input: SFT model + preference dataset (chosen/rejected pairs) Output: Reward model that scores any output
Stage 3: Policy Optimization
Use reinforcement learning to optimize the SFT model against the reward model, while staying close to the original SFT distribution.
Input: SFT model + reward model Output: Final aligned model
Alternative: Direct Alignment
Direct alignment algorithms (DPO, IPO, KTO) skip the reward model entirely, optimizing directly from preference data. This simplifies the pipeline but trades off some flexibility.
Modern Post-Training Variants
Current post-training stacks often mix these stages rather than using a single linear pipeline:
| Method | Data Signal | Best Fit |
|---|---|---|
| SFT | Demonstrations | Format, style, instruction following |
| DPO/IPO/KTO/ORPO | Offline preferences or binary feedback | Simpler alignment without online rollouts |
| PPO/RLOO | Reward model scores on sampled responses | Reward-model RL with explicit KL control |
| GRPO | Grouped completions scored by reward functions/models | Reasoning and verifiable-task optimization |
Preference Data
Preference data encodes human judgment about model outputs. The most common format is pairwise comparisons.
Pairwise Preferences
Given a prompt, collect two or more model outputs and have humans indicate which is better:
Prompt: "Explain quantum entanglement"
Response A: [technical explanation]
Response B: [simpler explanation with analogy]
Human preference: B > A
This creates (prompt, chosen, rejected) tuples for training.
Collection Methods
Human annotation: Trained annotators compare outputs according to guidelines. Most reliable but expensive and slow.
AI feedback: Use a capable model to generate preferences. Faster and cheaper but may propagate biases. This is the basis for Constitutional AI (CAI) and RLAIF.
Implicit signals: User interactions like upvotes, regeneration requests, or conversation length. Noisy but abundant.
Data Quality Considerations
- Annotator agreement: Low agreement suggests ambiguous criteria or subjective preferences
- Distribution coverage: Preferences should cover the range of model behaviors
- Prompt diversity: Diverse prompts prevent overfitting to narrow scenarios
- Preference strength: Some comparison
Установить rlhf в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл rlhf?
Understanding Reinforcement Learning from Human Feedback (RLHF) for aligning language models. Use when learning about preference data, reward modeling, policy optimization, or direct alignment algorithms like DPO.
Как установить скилл rlhf?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл rlhf запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic