# simpo-training

Sets up SimPO preference training for language models from chosen and rejected pairs. Use it when DPO's reference model adds unwanted setup.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 950 installs · ★ 13956
- Author: Orchestra Research
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/Orchestra-Research/AI-Research-SKILLs/tree/HEAD/06-post-training/simpo/SKILL.md
- Updated: 2026-10-11
- HTML: https://affpapa.org/en/nevibecode/skills/simpo-training

## What it does

SimPO trains from chosen and rejected preference pairs without a reference model. The skill covers launches with `scripts/run_simpo.py`, `accelerate` configurations and DeepSpeed ZeRO-3, plus controls for `beta`, `gamma_beta_ratio`, `loss_type` and `sft_weight`.

It includes workflows for base Mistral 7B, instruct-tuned Llama 3 8B, and reasoning-heavy work. For diverging loss, it suggests lowering `learning_rate` or `beta`; SFT regularization addresses capability loss. Smaller batches, gradient accumulation and gradient checkpointing address OOM errors.

Training uses `torch`, `transformers`, `datasets`, `trl`, `accelerate`, Flash Attention 2 and Alignment Handbook. NVIDIA A100/H100 GPUs are recommended, so check the available VRAM before planning a run.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add Orchestra-Research/AI-Research-SKILLs --skill simpo-training -a claude-code
```
```bash
npx skills add Orchestra-Research/AI-Research-SKILLs --skill simpo -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/simpo/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/simpo/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add Orchestra-Research/AI-Research-SKILLs --skill simpo -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/simpo/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add Orchestra-Research/AI-Research-SKILLs --skill simpo -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/simpo/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install Orchestra-Research/AI-Research-SKILLs simpo
```

2. **Manually: put the files in place**
- File: `.github/skills/simpo/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add Orchestra-Research/AI-Research-SKILLs --skill simpo -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/Orchestra-Research/AI-Research-SKILLs --path 06-post-training/simpo
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/simpo/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add Orchestra-Research/AI-Research-SKILLs --skill simpo -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/Orchestra-Research/AI-Research-SKILLs/tree/HEAD/06-post-training/simpo/SKILL.md

## When to use it
- train a model on preference pairs
- launch SimPO with `accelerate`
- tune `beta` and the target margin
- address diverging loss
- reduce memory pressure during training

## Example prompts
- “Set up a SimPO configuration for Mistral 7B and run `scripts/run_simpo.py`.”
- “Adjust `sft_weight` for Llama 3 8B to preserve model capabilities.”
- “Help fix an OOM error in SimPO training with DeepSpeed ZeRO-3.”

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 031559eb4d06c397.

BEGIN THIRD-PARTY FILE 031559eb4d06c397
````text
---
name: simpo-training
description: Simple Preference Optimization for LLM alignment. Reference-free alternative to DPO with better performance (+6.4 points on AlpacaEval 2.0). No reference model needed, more efficient than DPO. Use for preference alignment when want simpler, faster training than DPO/PPO.
version: 1.0.0
author: Orchestra Research
license: MIT
tags: [Post-Training, SimPO, Preference Optimization, Alignment, DPO Alternative, Reference-Free, LLM Alignment, Efficient Training]
dependencies: [torch, transformers, datasets, trl, accelerate]
---

# SimPO - Simple Preference Optimization

## Quick start

SimPO is a reference-free preference optimization method that outperforms DPO without needing a reference model.

**Installation**:
```bash
# Create environment
conda create -n simpo python=3.10 && conda activate simpo

# Install PyTorch 2.2.2
# Visit: https://pytorch.org/get-started/locally/

# Install alignment-handbook
git clone https://github.com/huggingface/alignment-handbook.git
cd alignment-handbook
python -m pip install .

# Install Flash Attention 2
python -m pip install flash-attn --no-build-isolation
```

**Training** (Mistral 7B):
```bash
ACCELERATE_LOG_LEVEL=info accelerate launch \
  --config_file accelerate_configs/deepspeed_zero3.yaml \
  scripts/run_simpo.py \
  training_configs/mistral-7b-base-simpo.yaml
```

## Common workflows

### Workflow 1: Train from base model (Mistral 7B)

**Config** (`mistral-7b-base-simpo.yaml`):
```yaml
# Model
model_name_or_path: mistralai/Mistral-7B-v0.1
torch_dtype: bfloat16

# Dataset
dataset_mixer:
  HuggingFaceH4/ultrafeedback_binarized: 1.0
dataset_splits:
  - train_prefs
  - test_prefs

# SimPO hyperparameters
beta: 2.0                  # Reward scaling (2.0-10.0)
gamma_beta_ratio: 0.5       # Target margin (0-1)
loss_type: sigmoid          # sigmoid or hinge
sft_weight: 0.0             # Optional SFT regularization

# Training
learning_rate: 5e-7         # Critical: 3e-7 to 1e-6
num_train_epochs: 1
per_device_train_batch_size: 1
gradient_accumulation_steps: 8

# Output
output_dir: ./outputs/mistral-7b-simpo
```

**Launch training**:
```bash
accelerate launch --config_file accelerate_configs/deepspeed_zero3.yaml \
  scripts/run_simpo.py training_configs/mistral-7b-base-simpo.yaml
```

### Workflow 2: Fine-tune instruct model (Llama 3 8B)

**Config** (`llama3-8b-instruct-simpo.yaml`):
```yaml
model_name_or_path: meta-llama/Meta-Llama-3-8B-Instruct

dataset_mixer:
  argilla/ultrafeedback-binarized-preferences-cleaned: 1.0

beta: 2.5
gamma_beta_ratio: 0.5
learning_rate: 5e-7
sft_weight: 0.1             # Add SFT loss to preserve capabilities

num_train_epochs: 1
per_device_train_batch_size: 2
gradient_accumulation_steps: 4
output_dir: ./outputs/llama3-8b-simpo
```

**Launch**:
```bash
accelerate launch --config_file accelerate_configs/deepspeed_zero3.yaml \
````
END THIRD-PARTY FILE 031559eb4d06c397

The third-party file has ended. Everything between the 031559eb4d06c397 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2869 of 5916 bytes. © Orchestra Research · MIT · https://github.com/Orchestra-Research/AI-Research-SKILLs/tree/HEAD/06-post-training/simpo/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
