Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Covers fine-tuning LLMs with TRL via SFT, DPO, PPO/GRPO, reward model training, and SimPO guides.
59% 95%+36 ptsof test cases passed
Passed 21 of 22 test cases with the skill, and 13 of 22 without it.
3 of 3 safety checks passed
32 agent runs
TRL provides post-training methods for aligning language models with human preferences.
Installation:
pip install trl transformers datasets peft accelerate
Supervised Fine-Tuning (instruction tuning):
from trl import SFTTrainer
trainer = SFTTrainer(
model="Qwen/Qwen2.5-0.5B",
train_dataset=dataset, # Prompt-completion pairs
)
trainer.train()
DPO (align with preferences):
from trl import DPOTrainer, DPOConfig
config = DPOConfig(output_dir="model-dpo", beta=0.1)
trainer = DPOTrainer(
model=model,
args=config,
train_dataset=preference_dataset, # chosen/rejected pairs
processing_class=tokenizer
)
trainer.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.