simpo-implementation
Guidelines for implementing the SimPO loss function as per the SimPO paper.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 8
01 前言 Front Matter
- name
- simpo-implementation
- description
- Guidelines for implementing the SimPO loss function as per the SimPO paper.
03 SKILL.md 正文
SimPO Loss Implementation
The SimPO loss is designed to optimize language models by maximizing the gap between positive and negative response log-probabilities, normalized by the length of the response.
Mathematical Formulation
The SimPO loss $L_{SimPO}$ is defined as: $L_{SimPO} = -\mathbb{E}{(x, y_w, y_l) \sim D} \left[ \log \sigma \left( \beta \left( \frac{1}{|y_w|} \log \pi\theta(y_w|x) - \frac{1}{|y_l|} \log \pi_\theta(y_l|x) - \gamma \right) \right) \right]$
Where:
- $y_w$ is the winning response.
- $y_l$ is the losing response.
- $\beta$ is the reward margin scale.
- $\gamma$ is the reward margin threshold.
- $\pi_\theta(y|x)$ is the model's likelihood for sequence $y$ given $x$.
Implementation Steps
- Calculate Log Probabilities: Use the model to compute the log-likelihood of tokens in $y_w$ and $y_l$.
- Sum Log Probabilities: Sum the log-likelihoods over the generated sequence.
- Normalize: Divide the sum by the sequence length (or use a length-normalized log-prob implementation).
- Compute Margin: Calculate the difference between normalized log-probs of $y_w$ and $y_l$, then subtract $\gamma$.
- Apply Sigmoid and Log: Apply the sigmoid function to $\beta \times \text{margin}$, take the negative log, and compute the mean over the batch.
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.