Files
2026-05-12 17:01:39 +08:00

73 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# DPO Qwen3.5-9B Server Bundle
这个目录是可直接拷到 Linux 服务器上的独立 DPO 训练包。
包含内容:
- `data/train_dpo_clean.jsonl`
- `data/dev_dpo_clean.jsonl`
- `data/raw_final_train_pairs.jsonl`
- `data/raw_final_dev_pairs.jsonl`
- `reports/final_train_pairs_report.json`
- `reports/final_dev_pairs_report.json`
- `scripts/train_dpo.py`
- `scripts/analyze_token_lengths.py`
- `run_train.sh`
- `requirements.txt`
## 设计说明
- 训练数据来自你已经组装好的 `final_train_pairs.jsonl / final_dev_pairs.jsonl`
- bundle 默认输出 `clean` 版数据:
- 保留 `strong_model / rule` chosen
- 保留 `weak_model_actual_error / constructed` rejected
- 删除 `weak_model_actual_error + parse_fail` 这种纯脏 rejected
## 推荐训练流程
1. 安装依赖
```bash
pip install -r requirements.txt
```
2. 先看 token 长度
```bash
python scripts/analyze_token_lengths.py --model-name Qwen/Qwen3.5-9B --train-file data/train_dpo_clean.jsonl --dev-file data/dev_dpo_clean.jsonl
```
3. 直接开训练
```bash
bash run_train.sh
```
## 默认策略
- 基座模型:`Qwen/Qwen3.5-9B`
- 训练方式:`QLoRA + DPO`
- 设备:`2 x A100 40G`
- 启动方式:`torchrun --nproc_per_node=2`
- 默认长度:`max_length=6656``max_prompt_length=6144`
## 关于长度
你这批 clean 数据的统计显示:
- prompt token `max ≈ 6611`
- pair token `max ≈ 9294`
因此默认训练脚本采用:
- `max_prompt_length=6144`:覆盖大多数 prompt仅截断极少数最长尾 prompt
- `max_length=6656`:把 DPO 的激活显存压力压到更稳的区间
这是更适合 `2 x A100 40G` 的 pilot 配置;优先保证能稳定开训。
## 你最需要看的文件
- 数据清单:`manifest.json`
- 训练脚本:`scripts/train_dpo.py`
- 启动脚本:`run_train.sh`