preference-optimization
Align a fine-tuned model with preference data using DPO, ORPO, KTO, or SimPO
Install / Use
npx skills add wshobson/agents --skill preference-optimizationInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Development & EngineeringSupported Platforms
Tags
Our assessment of preference-optimization
preference-optimization scores 92/100 on our quality scale, 243rd of 1,937 Development & Engineering skills we index (top 13%).
Its SKILL.md is 7.7 KB long, well organised into 10 sections with 1 code example: a thorough specification that gives an agent plenty to work with.
With 39,920 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated 5 days ago, so preference-optimization is actively maintained.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-09-26. Automated pattern scan on 2026-09-25. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
preference-optimization compared with similar skills
All 4 of these similar skills score higher than preference-optimization; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| preference-optimization (this skill)by wshobson | 92 | 39.9k | 5d ago | SKILL.md |
| ai-job-searchby MadsLorentzen | 100 | 44.0k | 4d ago | CLAUDE.md |
| claude-howtoby luongnv89 | 100 | 41.7k | 6d ago | CLAUDE.md |
| algorithmic-artby anthropics | 100 | 177.9k | 3d ago | SKILL.md |
| pptxby anthropics | 100 | 177.9k | 3d ago | SKILL.md |
Frequently asked questions
- How do I install preference-optimization?
- Run
npx skills add wshobson/agents --skill preference-optimization. The install tabs above show the steps for each supported agent. - Which AI agents does preference-optimization work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is preference-optimization safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is preference-optimization still maintained?
- The repository was last updated 5 days ago, so preference-optimization is actively maintained.
Skill content
View source on GitHubname: preference-optimization description: Align a fine-tuned model with preference data using DPO, ORPO, KTO, or SimPO. Use when preference pairs or thumbs-up/down feedback exist, when choosing between preference-optimization methods, or when a DPO run needs hyperparameters or debugging.
Preference Optimization
This skill assumes finetuning-method-selection
already routed here because the data shape is
preference pairs or unpaired thumbs-up/down
feedback, not demonstrations (that's
lora-qlora-recipes) or a verifiable reward
signal (that's grpo-rlvr-training). What
follows is method selection among the DPO family,
the evidence for how much that selection actually
matters, the production training pattern, and how
to build the pairs in the first place.
Input: a routing decision (preference
optimization) plus preference pairs or unpaired
feedback, usually from an SFT checkpoint.
Output format: a validated method choice plus
a config — the kwarg values in
references/method-configs.md, not free-form
advice — that llm-finetuning-training-engineer
consumes directly.
Method Selection
| Data shape | Method | Key parameters | |---|---|---| | Preference pairs, default case | DPO | β=0.1, LR 5e-7–1e-6, 1–2 epochs | | Memory-bound or no SFT checkpoint | ORPO | reference-free, fused SFT+preference in one loss | | Unpaired thumbs-up/down | KTO | binary label per example, no pairing needed | | Length bias observed, sweep budget available | SimPO | reference-free; see sweep grid below |
- DPO is the safe default. Use β=0.1 and a learning rate of 5e-7 to 1e-6 for 1–2 epochs. This LR is lower than the SFT LR that produced the checkpoint being aligned — porting an SFT- scale LR into a DPO run is the most common misconfiguration here, not an edge case.
- ORPO routes in when memory is the constraint, or when there's no separate SFT checkpoint to start from — it's reference-free and fuses the SFT and preference objectives into one loss, skipping the separate SFT pass and the reference-model memory cost DPO carries.
- KTO routes in when feedback is unpaired binary signal (thumbs-up/down) rather than matched preference pairs — don't force unpaired feedback into synthetic pairs to use DPO instead.
- SimPO fixes DPO's length bias but only pays off with disciplined sweeping — its published gains are a ceiling reported under a tuned sweep, not a baseline any single config will reproduce. Route here only when there's sweep budget; use DPO instead if there isn't.
- Classic RLHF (reward model + PPO) is retired outside frontier labs. Don't reach for it in a production pipeline — every method above is cheaper and better-supported for the same data shapes.
Worked Examples
- "We have an SFT checkpoint and clean paired preference data, no length-bias complaints yet." → default case → DPO at β=0.1.
- "Reviewers click thumbs-up/down per response; nothing is paired." → unpaired signal → KTO, not DPO — don't synthesize pairs to force DPO onto unpaired data.
- "GPU budget doesn't cover a separate SFT pass plus a DPO reference model." → memory-bound, no separate checkpoint → ORPO.
- "DPO output favors longer answers regardless of quality, and there's time to run a sweep." → length bias plus sweep budget → SimPO. Skip it if the sweep budget isn't actually there.
The Low-Leverage Truth
A 2026 240-H100-run study (arXiv 2603.19335) is the load-bearing evidence behind the table above: loss-function choice is worth roughly 1 percentage point of leverage, model scale is worth roughly 50. Zero of 20 DPO variants tested beat vanilla DPO. Rankings also invert with scale — a variant that wins in a small pilot can lose at deployment size.
Two practical consequences:
- Don't spend a routing decision agonizing over DPO-variant bake-offs. The table above is sufficient; deeper variant selection is low-leverage compared to data quality and scale.
- Validate at deployment scale before trusting a ranking. A method comparison run on a small pilot model doesn't transfer to the production size class — re-check the winner once scale changes.
This is also why the Method Selection table above is deliberately short: it encodes the ~1pp lever, not a ranking of DPO variants that the same study shows doesn't hold up across scale. Treat any variant-selection advice that isn't in that table — including advice that claims a specific variant "wins" — as unproven until it's been validated at the target deployment size.
Production Pattern: Iterative On-Policy DPO
A single offline DPO pass on a static preference dataset is a starting point, not the production pattern. The policy drifts away from the distribution the pairs were sampled from as training proceeds, and a static dataset goes stale against that drift. Production pipelines run DPO iteratively and on-policy instead:
- Sample completions from the current policy checkpoint.
- Score or rank the completions (reward model, judge, or task grader).
- Run a DPO pass using the current checkpoint as the reference model.
- The resulting checkpoint becomes both the new policy and the new reference for the next round.
Repeat. Each round's reference model is the prior round's output, not a fixed initial checkpoint — that's what keeps the preference signal on-policy instead of scoring against an increasingly stale distribution.
A single-pass DPO run is still a reasonable first iteration — it just isn't the whole pipeline. Plan for at least one more round once the first checkpoint exists, rather than treating pass one as the finished artifact.
Pair Construction
Build DPO/ORPO pairs from same-task passing-vs-failing trajectories — two attempts at the same underlying task, not unrelated best-and-worst examples pulled from different tasks. Within that trajectory set, select the rejected member at μ−2σ of the reward distribution, never the minimum. Naive best-vs-worst pair construction (max reward vs. absolute minimum) degrades as scale increases; the μ−2σ selection is more robust to the same scale sensitivity the low-leverage study surfaced above.
sorted_by_reward = sort(trajectories, key=reward)
chosen = sorted_by_reward[-1] # highest reward
mu, sigma = mean(rewards), stdev(rewards)
rejected = closest(sorted_by_reward, mu - 2 * sigma)
# NOT sorted_by_reward[0] — the absolute minimum
# is the naive best-vs-worst construction that
# degrades as scale increases.
For the mechanics of turning graded traces into
these pairs — including rejection sampling and
judge-scored delta selection — see
trace-to-training-data.
References
Complete TRL config blocks per method —
DPOConfig, ORPOConfig, KTOConfig, and the
SimPO sweep grid — plus Unsloth wrappers and a
catastrophic-forgetting note live in
references/method-configs.md. Those configs use
the same current-TRL API conventions established
in lora-qlora-recipes's
references/unsloth-trl-mapping.md
(processing_class, not tokenizer=).
references/method-configs.md also carries the
catastrophic-forgetting note: a too-high learning
rate is the usual cause when a preference-tuned
checkpoint loses general capability, and the fix
is almost always to drop the LR toward the low end
of the range in the Method Selection table above
before reaching for any other remediation.
Related skills: finetuning-method-selection
routes here once preference pairs or unpaired
feedback exist; lora-qlora-recipes produces the
SFT checkpoint DPO/KTO/SimPO align (ORPO's
fused path can skip it); trace-to-training-data
converts passing/failing trajectories into the
pairs this skill's Pair Construction section
consumes.
Related Skills
ai-job-search
44.0kThe job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.
claude-howto
41.7kA visual, example-driven guide to Claude Code — from basic concepts to advanced agents, with copy-paste templates that bring immediate value.
algorithmic-art
177.9kCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems.
pptx
177.9kUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an em…
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
