Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Covers TRL library for LLM post-training: SFT, reward modeling, PPO, DPO, KTO, and GRPO for RLHF alignment.
Use this skill ↓56% 44%−11 ptsof checks passed
Scored 44% with the skill and 56% without it.
3 of 3 safety checks passed
Not used yet
TRL (Transformer Reinforcement Learning) is Hugging Face's library for RLHF — SFT, reward modeling, PPO, DPO, KTO, and GRPO. It's the standard post-training toolkit for aligning language models with human preferences.
uv pip install trl
from trl import SFTTrainer
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B-Instruct")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-1.5B-Instruct")
trainer = SFTTrainer(
model=model, tokenizer=tokenizer,
train_dataset=dataset,
args=dict(per_device_train_batch_size=4, learning_rate=2e-5, max_seq_length=2048),
)
trainer.train()
from trl import DPOTrainer
dpo = DPOTrainer(
model=model, ref_model=ref_model, tokenizer=tokenizer,
train_dataset=preference_dataset,
args=dict(per_device_train_batch_size=4, max_length=2048),
)
dpo.train()
Published skills whose descriptions closely match this one, with their benchmark result.
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.