[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EVSA7XCDKCYBDQNVEHXJE9":3,"skill-same:01M7EVSA7XCDKCYBDQNVEHXJE9":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M7EVSA7XCDKCYBDQNVEHXJE9","rlhf-pipeline",null,"Build the full reinforcement-learning-from-human-feedback stack — preference data, reward model, and policy optimization.","TanNhatCMS\u002Fjarvis","TanNhatCMS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F113796420?v=4","01M753MV17KG5CD3152G3WQEQY","KietNT","01M7EKEDYVYQ6PWVJJMZ911VMX",0,"MIT","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fams-rlhf-pipeline\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: rlhf-pipeline\ndescription: Build the full reinforcement-learning-from-human-feedback stack — preference data, reward model, and policy optimization.\ncategory: ai-research\n---\n\n## Overview\n\nRLHF aligns a language model to human preferences in three stages. First, collect\npreference data: human annotators rank or choose between pairs of model responses\nto prompts. Second, train a reward model on these comparisons, typically with a\nBradley-Terry loss that predicts which response a human would prefer. Third,\noptimize the policy — usually with PPO (proximal policy optimization) — to maximize\nreward while staying close to the original model via a KL penalty, preventing\ncollapse into reward-hacking gibberish.\n\nVariants replace pieces of this stack: DPO skips the reward model and optimizes\nthe policy directly on preference pairs; RLAIF uses AI-generated preferences;\nonline RLHF re-collects preferences as the policy changes. The classic three-stage\npipeline remains the reference design because each stage is independently\ninspectable: you can audit the preference data, probe the reward model, and\nmonitor the KL budget during policy training.\n\nThe economic reality: RLHF is the most expensive common alignment method, in\nlabeling cost and engineering complexity. It earns that cost when nuanced human\njudgment — tone, helpfulness trade-offs, refusal style — is the actual product\nrequirement.\n\n## When to use\n\n- Aligning a base or instruction-tuned model to nuanced human preferences that can't\n  be captured by supervised data alone (tone, helpfulness trade-offs, refusal\n  style).\n- Building an assistant product where \"which response is better\" judgments matter\n  more than \"which is correct.\"\n- Reducing harmful or unwanted outputs while keeping the model helpful, via a\n  reward model that encodes those trade-offs.\n- Researching alignment: each stage is a separate object of study (labeler\n  agreement, reward model generalization, optimization dynamics).\n- When you have the labeling budget and infrastructure for a multi-stage pipeline\n  and the scale to justify it.\n- As the final polish stage after SFT, when supervised data has taken you as far\n  as demonstrations can.\n\n## Core concepts\n\n- **Preference pairs**: (prompt, chosen, rejected) triples. Quality dominates\n  quantity: clear, well-annotated comparisons beat large volumes of noisy ones.\n  Annotator guidelines are the real specification of your model's values.\n- **Reward model**: usually the policy-sized (or smaller) model with a scalar head,\n  trained to score responses. Evaluated by accuracy on held-out human preferences\n  and by calibration on out-of-distribution prompts.\n- **Bradley-Terry model**: the standard loss — the probability that response A is\n  preferred over B is a sigmoid of their score difference. Simple, but assumes\n  transitive, noise-free preferences; real data isn't.\n- **PPO with KL penalty**: the policy update maximizes expected reward minus\n  β·KL(policy || reference). The KL term is the guardrail against reward hacking.\n  Track reward and KL jointly — rising reward with rising KL is a warning sign,\n  not success.\n- **Reward hacking**: the policy learns to exploit quirks of the reward model\n  (verbosity, sycophancy, confident tone) rather than genuine quality. The single\n  biggest failure mode of the whole pipeline.\n- **Online vs. offline**: offline RLHF trains on a fixed preference dataset;\n  online variants (iterative RLHF) generate new responses from the current policy\n  and get fresh preferences, correcting distribution shift.\n- **KL budget**: the total allowed divergence from the reference, spent across\n  training. Spend it deliberately — monitor cumulative KL, not just the\n  coefficient.\n- **Annotator agreement**: the noise floor of your signal. Low inter-annotator\n  agreement means the reward model learns noise; fix guidelines before scaling\n  collection.\n\n## Practical workflow\n\n1. **Write annotation guidelines.** Specify what \"better\" means for your use case:\n   factuality first? refusal style? tone? Include edge-case examples. Pilot with\n   200–500 examples and measure inter-annotator agreement before scaling.\n2. **Collect preference data.** Sample prompts covering the target distribution;\n   generate 2–4 responses per prompt from the current policy; have annotators rank\n   or pick best\u002Fworst. Aim for tens of thousands of pairs minimum for a serious\n   run.\n3. **Train the reward model.** Fine-tune from the policy or a smaller model with a\n   scalar head. Validate on held-out pairs and on adversarial prompts; check that\n   scores correlate with human judgment on a fresh sample.\n4. **Probe the reward model.** Before PPO, test it on edge cases: does it prefer\n   longer answers regardless of quality? Does it penalize refusals correctly? Fix\n   what you find — PPO will amplify every flaw.\n5. **Run PPO.** Standard hyperparameters: KL coefficient β tuned so KL stays in a\n   target band, learning rate lower than SFT, batch sizes large enough for stable\n   advantage estimates. Log reward, KL, response length, and win-rate against the\n   base policy throughout.\n6. **Evaluate holistically.** Reward score is not the metric — human win-rate on a\n   blind eval set, plus targeted safety evals, plus capability regression checks\n   (the aligned model shouldn't forget facts or reasoning).\n7. **Iterate online if needed.** If you see distribution shift (the policy exploits\n   regions the reward model never saw), collect fresh preferences on current-policy\n   outputs and repeat.\n\nChecklist before shipping an RLHF model:\n- Held-out human win-rate beats the SFT baseline by a meaningful margin.\n- Capability benchmarks haven't regressed (no \"alignment tax\" surprises).\n- Reward hacking probes: verbosity, sycophancy, refusal-bait prompts tested.\n- KL divergence stayed within the planned budget through training.\n- Annotator guidelines versioned and agreement metrics recorded.\n\n## Common pitfalls\n\n- **Optimizing the reward, not the goal.** Goodhart's law is the default outcome.\n  Treat the reward model as a proxy and validate with humans continuously.\n- **Bad preference data.** Inconsistent annotators, unclear guidelines, or prompts\n  that don't match deployment produce a reward model that encodes the wrong values\n  precisely.\n- **KL too loose or too tight.** Too loose → reward hacking and degenerate outputs.\n  Too tight → the RL stage changes nothing and you've paid for nothing.\n- **Ignoring length bias.** Reward models systematically prefer longer responses.\n  Control for length in evaluation or the policy learns to ramble.\n- **Single-turn optimization.** PPO on single responses can degrade multi-turn\n  behavior (e.g., the model becomes agreeable rather than truthful across a\n  conversation). Evaluate multi-turn explicitly.\n- **Skipping the SFT stage.** RLHF on a raw base model is unstable; a solid\n  supervised fine-tune first gives the policy a sensible starting distribution.\n- **Reward model never probed.** Going straight from reward training to PPO without\n  adversarially testing the reward model. Its flaws become the policy's features.\n- **No online correction.** Running one offline round and declaring victory while\n  the policy has drifted off the reward model's training distribution.\n","## Overview\n\nRLHF aligns a language model to human preferences in three stages. First, collect\npreference data: human annotators rank or choose between pairs of model responses\nto prompts. Second, train a reward model on these comparisons, typically with a\nBradley-Terry loss that predicts which response a human would prefer. Third,\noptimize the policy — usually with PPO (proximal policy optimization) — to maximize\nreward while staying close to the original model via a KL penalty, preventing\ncollapse into reward-hacking gibberish.\n\nVariants replace pieces of this stack: DPO skips the reward model and optimizes\nthe policy directly on preference pairs; RLAIF uses AI-generated preferences;\nonline RLHF re-collects preferences as the policy changes. The classic three-stage\npipeline remains the reference design because each stage is independently\ninspectable: you can audit the preference data, probe the reward model, and\nmonitor the KL budget during policy training.\n\nThe economic reality: RLHF is the most expensive common alignment method, in\nlabeling cost and engineering complexity. It earns that cost when nuanced human\njudgment — tone, helpfulness trade-offs, refusal style — is the actual product\nrequirement.\n\n## When to use\n\n- Aligning a base or instruction-tuned model to nuanced human preferences that can't\n  be captured by supervised data alone (tone, helpfulness trade-offs, refusal\n  style).\n- Building an assistant product where \"which response is better\" judgments matter\n  more than \"which is correct.\"\n- Reducing harmful or unwanted outputs while keeping the model helpful, via a\n  reward model that encodes those trade-offs.\n- Researching alignment: each stage is a separate object of study (labeler\n  agreement, reward model generalization, optimization dynamics).\n- When you have the labeling budget and infrastructure for a multi-stage pipeline\n  and the scale to justify it.\n- As the final polish stage after SFT, when supervised data has taken you as far\n  as demonstrations can.\n\n## Core concepts\n\n- **Preference pairs**: (prompt, chosen, rejected) triples. Quality dominates\n  quantity: clear, well-annotated comparisons beat large volumes of noisy ones.\n  Annotator guidelines are the real specification of your model's values.\n- **Reward model**: usually the policy-sized (or smaller) model with a scalar head,\n  trained to score responses. Evaluated by accuracy on held-out human preferences\n  and by calibration on out-of-distribution prompts.\n- **Bradley-Terry model**: the standard loss — the probability that response A is\n  preferred over B is a sigmoid of their score difference. Simple, but assumes\n  transitive, noise-free preferences; real data isn't.\n- **PPO with KL penalty**: the policy update maximizes expected reward minus\n  β·KL(policy || reference). The KL term is the guardrail against reward hacking.\n  Track reward and KL jointly — rising reward with rising KL is a warning sign,\n  not success.\n- **Reward hacking**: the policy learns to exploit quirks of the reward model\n  (verbosity, sycophancy, confident tone) rather than genuine quality. The single\n  biggest failure mode of the whole pipeline.\n- **Online vs. offline**: offline RLHF trains on a fixed preference dataset;\n  online variants (iterative RLHF) generate new responses from the current policy\n  and get fresh preferences, correcting distribution shift.\n- **KL budget**: the total allowed divergence from the reference, spent across\n  training. Spend it deliberately — monitor cumulative KL, not just the\n  coefficient.\n- **Annotator agreement**: the noise floor of your signal. Low inter-annotator\n  agreement means the reward model learns noise; fix guidelines before scaling\n  collection.\n\n## Practical workflow\n\n1. **Write annotation guidelines.** Specify what \"better\" means for your use case:\n   factuality first? refusal style? tone? Include edge-case examples. Pilot with\n   200–500 examples and measure inter-annotator agreement before scaling.\n2. **Collect preference data.** Sample prompts covering the target distribution;\n   generate 2–4 responses per prompt from the current policy; have annotators rank\n   or pick best\u002Fworst. Aim for tens of thousands of pairs minimum for a serious\n   run.\n3. **Train the reward model.** Fine-tune from the policy or a smaller model with a\n   scalar head. Validate on held-out pairs and on adversarial prompts; check that\n   scores correlate with human judgment on a fresh sample.\n4. **Probe the reward model.** Before PPO, test it on edge cases: does it prefer\n   longer answers regardless of quality? Does it penalize refusals correctly? Fix\n   what you find — PPO will amplify every flaw.\n5. **Run PPO.** Standard hyperparameters: KL coefficient β tuned so KL stays in a\n   target band, learning rate lower than SFT, batch sizes large enough for stable\n   advantage estimates. Log reward, KL, response length, and win-rate against the\n   base policy throughout.\n6. **Evaluate holistically.** Reward score is not the metric — human win-rate on a\n   blind eval set, plus targeted safety evals, plus capability regression checks\n   (the aligned model shouldn't forget facts or reasoning).\n7. **Iterate online if needed.** If you see distribution shift (the policy exploits\n   regions the reward model never saw), collect fresh preferences on current-policy\n   outputs and repeat.\n\nChecklist before shipping an RLHF model:\n- Held-out human win-rate beats the SFT baseline by a meaningful margin.\n- Capability benchmarks haven't regressed (no \"alignment tax\" surprises).\n- Reward hacking probes: verbosity, sycophancy, refusal-bait prompts tested.\n- KL divergence stayed within the planned budget through training.\n- Annotator guidelines versioned and agreement metrics recorded.\n\n## Common pitfalls\n\n- **Optimizing the reward, not the goal.** Goodhart's law is the default outcome.\n  Treat the reward model as a proxy and validate with humans continuously.\n- **Bad preference data.** Inconsistent annotators, unclear guidelines, or prompts\n  that don't match deployment produce a reward model that encodes the wrong values\n  precisely.\n- **KL too loose or too tight.** Too loose → reward hacking and degenerate outputs.\n  Too tight → the RL stage changes nothing and you've paid for nothing.\n- **Ignoring length bias.** Reward models systematically prefer longer responses.\n  Control for length in evaluation or the policy learns to ramble.\n- **Single-turn optimization.** PPO on single responses can degrade multi-turn\n  behavior (e.g., the model becomes agreeable rather than truthful across a\n  conversation). Evaluate multi-turn explicitly.\n- **Skipping the SFT stage.** RLHF on a raw base model is unstable; a solid\n  supervised fine-tune first gives the policy a sensible starting distribution.\n- **Reward model never probed.** Going straight from reward training to PPO without\n  adversarially testing the reward model. Its flaws become the policy's features.\n- **No online correction.** Running one offline round and declaring victory while\n  the policy has drifted off the reward model's training distribution.\n",{"name":5,"category":24,"description":7},"ai-research","main","af388a77c2fe5e0b4fd879cca4300a0ffa9a6579","skills\u002Fams-rlhf-pipeline",1,"https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis","https:\u002F\u002Fgithub.com\u002FTanNhatCMS","https:\u002F\u002Fmrkiet.name.vn","2026-11-07 14:23:08",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add TanNhatCMS\u002Fjarvis --skill rlhf-pipeline",{"tool":39,"command":40},"bunx","bunx skills add TanNhatCMS\u002Fjarvis --skill rlhf-pipeline",{"tool":42,"command":43},"pnpm","pnpm dlx skills add TanNhatCMS\u002Fjarvis --skill rlhf-pipeline","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fams-rlhf-pipeline\u002FSKILL.md",true,[],[48,55,63,70,77,84],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7EWYJR0J8DARY7E59Z6Y9MV","web-scrape","Turn web pages into LLM-ready markdown via the Firecrawl API (renders JS, anti-bot handling). Use when browser_open\u002Ffetch fails on JS-heavy pages, or when you need clean markdown\u002Fstructured extraction from a site. Requires FIRECRAWL_API_KEY.","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fweb-scrape\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":59,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7EWYBN5P6F2AJG3FR24T9BP","design-taste-frontend","tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One Page Love, Awwwards Sites of the Day). Deals researched directions (idea, composition, type, palette, photographs, section blueprints) from a library, enforces a strict no-slop house style with a real-browser inspector, and runs a look-and-fix loop on screenshots. Use this whenever you build, design, redesign, restyle, polish or review a landing page, marketing site, portfolio, product page, one-pager, hero or any public-facing web page, in any stack (HTML\u002FCSS, React, Next.js, Vue, Svelte, Astro, Tailwind) — also when the user says a page looks generic, templated, \"AI-made\", sloppy, or asks to make it look designed, premium, award-level or less like every other site. Not for dashboards or app screens.","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Ftaste-design\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Ftaste-design\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7EWY8FQFNQ2GB7NZZWGSSDX","test-driven-development","Use when implementing any feature or bugfix, before writing implementation code","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-tdd\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7EWY5SHBFRH1HDHVWM9K7TV","systematic-debugging","Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-debugging\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7EWY3NM0Z0JAKS7HDZ24K66","requesting-code-review","Use when completing tasks, implementing major features, or before merging to verify work meets requirements","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-code-review\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7EWY0WRMWX4M9ZFY0WKC593","brainstorming","You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-brainstorming\u002FSKILL.md",[],[]]