> ## Documentation Index
> Fetch the complete documentation index at: https://starforge.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 用 TRL 训练

> Accelerate + TRL Trainer、必填模型/数据、OPSD teacher、镜像

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
sf new my-sft --method trl/sft
sf submit my-sft --profile h200:4 \
  --model Qwen/Qwen2.5-7B --train-data data/train.parquet
```

Hugging Face TRL **1.10.0**作为独立运行时，不走 `custom` 转发。方法有：`trl/sft`、`dpo`、
`grpo`、`rm`、`kto`、`rloo`、`opsd`。

可观测性是 `platform`。TRL 自己的指标名（`loss`、`eval_loss`、`learning_rate`）
会被映射到控制台的曲线上，所以你不用改名字曲线就会有数据。

## 创建

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
sf new my-sft --method trl/sft
sf new my-kto --method trl/kto
sf new my-opsd --method trl/opsd
```

入口是实验目录里的 `train.py`（`kind: experiment`）。除非你明确要改入口，超参写在 `config.yaml` / `--set` 里。

## 提交：模型和数据必填

和 verl 一样：`--model` 和 `--train-data`（通常还有 `--validation-data`）必填，除非配置里绑定字段已经有了。

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
sf submit my-sft --profile h200:8 \
  --model Qwen/Qwen3.5-9B \
  --train-data data/train.parquet \
  --validation-data data/val.parquet
```

`trl/opsd` 需要词表一致的 teacher（recipe 参数里的 `teacher_model`）。缺了校验会失败。

门禁 Hub 仓库：在控制台关联 HuggingFace，提交预检才能核对权限。[HuggingFace](/zh-Hans/integrations/huggingface)。

## 启动

adapter 用 Accelerate（`adapter_options.launcher: accelerate`）。卡数仍来自 `--profile` / `FORGE_CLUSTER_GPUS_PER_NODE`。

## 训练之后

checkpoint 是 HuggingFace 布局（`checkpoint-*`、`final_model`）。recipe 声明了 export/eval 生命周期（`starforge.lifecycle.export_complete`、实验里的 `eval.py`）。

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
sf export my-sft --checkpoint <path> --checkpoint-format huggingface
```
