Paper loss implementation

From XuShuwenn/RedAct · View interactive version

Paper loss implementation is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Implement a paper-defined pairwise preference loss in an ML repo, wire it to config, run the provided unit test deterministically, and log the Python environment for reproducibility.

How to use this skill

Skill file

Implementing Paper-Defined Pairwise Loss with Reproducible Test Execution

This skill guides you to implement a pairwise preference loss described in a paper (e.g., SimPO-style objectives) inside an existing trainer class, integrate configuration parameters correctly, and run a fixed-input unit test to generate deterministic outputs while logging the exact Python environment.

When to Use

Use this skill when:

Core Workflow

  1. Locate and Understand the Code Paths
  1. Extract the Objective from the Paper

L = (1 − s) × [−log(sigmoid(logits))] + s × [−log(sigmoid(−logits))]

  1. Implement the Loss Function
  1. Environment Setup and Test Execution
  1. Reproducibility Logging

Verification

Common Pitfalls

Success Criteria

Optional Script Usage

The helper script below provides a standalone, dependency-light implementation of the pairwise margin logits and losses (sigmoid with optional label smoothing, hinge). It can be used to validate formulas and shapes outside the repo before coding the trainer method.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.