agentsclimarketplace

Huggingface trl

Skill cxcscmu/SkillLearnBench/skills/b1-one-shot-gemini-3.1-pro-preview/nlp-paper-reproduction/huggingface-trl

Using Hugging Face TRL library for building custom trainers for Preference Optimization methods like DPO, SimPO, etc.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill huggingface-trl

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

1.1 KB, 240 tokens by cl100k_base, as published. Nobody here has run it

Hugging Face TRL (Transformer Reinforcement Learning)

TRL is a library by Hugging Face that provides tools to train language models using Reinforcement Learning and Preference Optimization (like PPO, DPO, etc.).

Custom Trainers

To implement custom loss functions like SimPO, you can subclass the DPOTrainer and override its specific methods (like dpo_loss or in this case, simpo_loss).

from trl import DPOTrainer
import torch
import torch.nn.functional as F

class CustomTrainer(DPOTrainer):
    def custom_loss(self, policy_chosen_logps, policy_rejected_logps):
        pi_logratios = policy_chosen_logps - policy_rejected_logps
        logits = pi_logratios - self.margin
        losses = -F.logsigmoid(self.beta * logits)
        return losses

Setup & Dependencies

Commonly requires transformers, torch, trl, and accelerate. Make sure you have the matching versions as defined in the project's requirement file (e.g. environment.yml or requirements.txt).

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.