·
Last changedVersion:
This version passed the hardening gate. Hardening applied 5 targeted changes and preserved all other text. Classified findings before hardening: 0. Classified findings closed: 0. Classified findings remaining: 0. Unclassified scanner findings remaining: 0. Review findings closed: 8. Review findings remaining: 0.
None
None
Expand | File | Group | Subtype | Severity | Status |
|---|
No findings available
0 findings
Each method pairs a *Trainer class with a *Config dataclass. Configs extend transformers.TrainingArguments, so all of its arguments work in any trainer config.
| Trainer | Dataset type |
|---|---|
| language modeling or prompt-completion |
| preference (chosen/rejected pairs) |
| prompt-only + reward function(s) |
| prompt-only + a teacher model (on-policy distillation) |
| unpaired preference (per-sample bool label) |
| preference (chosen/rejected pairs); trains a scalar reward model, not a policy |
Many more trainers (OnlineDPO, ORPO, CPO, GKD, …) live in trl.experimental with unstable APIs: https://huggingface.co/docs/trl/experimental_overview
Pass model as a string and route loading kwargs through model_init_kwargs instead of calling from_pretrained yourself. The tokenizer/processor is inferred from the model; pass processing_class only when it differs. For LoRA, pass peft_config=LoraConfig(...). An attention implementation named after a Hub repo downloads and runs compiled native code at load time, so use one only from a trusted repo pinned to a reviewed revision, and prefer the locally installed attention implementation. Keep remote code loading turned off unless the model repo has been reviewed and pinned to a revision. For production or reproducible runs, pin each model and dataset to a reviewed commit revision, including those named on the CLI or in config files.
Conversational: {"messages": [{"role": ..., "content": ...}]} (language modeling) or {"prompt": [...], "completion": [...]}. The chat template is applied automatically — never apply it yourself. Extra columns are allowed; GRPO forwards them to reward functions. Reference: https://huggingface.co/docs/trl/dataset_formats
Reward functions are called with keyword arguments prompts, completions, completion_ids, trainer_state, plus every extra dataset column — accept **kwargs for the ones you ignore. Return list[float], one reward per completion. With conversational data, completions is a list of message lists, not strings. Treat completions and dataset columns as untrusted input: check answers with a safe parser instead of running them as code, and run any reward that executes code in a sandbox with timeouts, network access turned off, and resource limits.
The generation batch is per_device_train_batch_size × num_processes × steps_per_generation (or set generation_batch_size directly) and must be divisible by num_generations (default 8). Generation is the usual bottleneck — enable vLLM with use_vllm=True: vllm_mode="colocate" shares the training GPUs (size with vllm_gpu_memory_utilization); vllm_mode="server" uses a separate trl vllm-serve --model <model_id>. Run that server, and the server used by the async trainer below, only on a trusted private network, keep its ports behind a firewall, and keep it unreachable from untrusted machines.
AsyncGRPOTrainer (trl.experimental.async_grpo) implements the same algorithm with generation decoupled from training: a background worker streams completions from a vLLM server while the training loop consumes them, so the two overlap instead of alternating.
Flags mirror the config fields: trl sft --model_name_or_path Qwen/Qwen2.5-0.5B --dataset_name trl-lib/Capybara. YAML via --config (use only config files you wrote or reviewed); distributed presets via --accelerate_config zero3 (Python scripts: accelerate launch train.py).
Get started with chainctlchainctl skill install public/huggingface/trl-training:latest
Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.
skills.cgr.dev/public/github.com/huggingface/skills/trl-training:latest
Apache-2.0
HARDENING.md
LICENSE
SKILL.md