Conversation
CLA Signature Guide@lltiaor , thanks for your pull request. The following commit(s) are not associated with a signed Contributor License Agreement (CLA).
To sign CLA, click here. To check if your email is configured correctly, refer to the FAQs. Once you've signed the CLA or updating your email, please comment |
|
/check-cla |
CLA Signature Passlltiaor, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
|
📖 文档预览:https://ascend.github.io/docs/pr-preview/pr-151/sources/trl/ 也可打开整站首页。 构建自 |
|
|
||
| - 可用的 Python 环境 | ||
| - 可用的 CANN(参考[快速安装昇腾环境](https://ascend.github.io/docs/sources/ascend/quick_install.html)) | ||
| - 与上面 CANN 匹配的 `torch` + `torch_npu`,且 `torch` 能正常 `import` 并 `torch.npu.is_available() == True`(参考 [Ascend PyTorch 安装文档](https://gitcode.com/Ascend/pytorch),按 torch ↔ torch_npu ↔ CANN 三方兼容矩阵选择版本) |
There was a problem hiding this comment.
就说安装匹配的torch_npu就可以了,安装torch_npu的地方会有验证方法的,这里不用赘述。
|
|
||
| **软件版本**: | ||
|
|
||
| | 组件 | 版本 | |
There was a problem hiding this comment.
这个我觉得没有必要展示版本,否则需要经常维护,这个跟楚阳和堆灿可以对齐下,看怎么做比较合适。
| python --version | ||
| ``` | ||
| 输出结果如下: | ||
| ```shell #test-result id="check-py" fuzzy='xxx' |
| 检查 NPU 设备运行时可用: | ||
|
|
||
| ```shell #test id="check-npu-runtime" | ||
| python -c "import torch, torch_npu; print(f'torch={torch.__version__}'); print(f'torch_npu={torch_npu.__version__}'); print('is_available:', torch.npu.is_available()); |
|
|
||
| 安装 `transformers` / `peft` / `modelscope`,装完打印版本验证。示例数据集来自 ModelScope: | ||
|
|
||
| ```shell #test id="install-deps" |
There was a problem hiding this comment.
格式有问题。 另外,这些依赖不能通过requirment.txt安装么?
|
|
||
| ## 安装 TRL | ||
|
|
||
| 用 uv 安装 PyPI 最新 release,装完打印版本验证: |
There was a problem hiding this comment.
使用uv的话,还需要安装uv工具,如果pip直接可以安装,那就世界使用pip即可。但是如果官网文档就使用的uv,那就保留
| ```shell #test-result id="trl-install-binary" fuzzy='xxx' | ||
| trl xxx | ||
| ``` | ||
| - xxx 表示最新的版本号 |
|
|
||
| 用 ModelScope 数据集 `HuggingFaceH4/ultrafeedback_binarized` 的 SFT 子集对 Qwen2.5-0.5B-Instruct 做 5 步 LoRA SFT。模型由脚本内的 `snapshot_download` 首次运行时自动下载到默认缓存(约 1 GB),数据集经 ModelScope 自动下载;`SFTTrainer` 通过 `peft_config` 注入 LoRA 适配器,底座权重冻结、只训练新注入的低秩矩阵;训练完成后把适配器保存到 `output/trl-sft-lora`。 | ||
|
|
||
| ```shell #test id="sft-lora" |
There was a problem hiding this comment.
格式显示不太好。 python << 会丢失代码高亮
|
|
||
| 同一个模型与 LoRA 配置,把 `SFTTrainer` / `SFTConfig` 换成 `DPOTrainer` / `DPOConfig` 就是偏好优化:ModelScope 数据集 `HuggingFaceH4/ultrafeedback_binarized` 的 `prompt` / `chosen` / `rejected` 三段对话让模型更倾向 `chosen` 而非 `rejected` 的回答。这里跑 3 步 DPO LoRA,产物保存到 `output/trl-dpo-lora`。 | ||
|
|
||
| ```shell #test id="dpo-lora" |
CLA Signature Passlltiaor, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
6a3566d to
2dfa106
Compare
CLA Signature Passlltiaor, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
2dfa106 to
dd23583
Compare
CLA Signature Passlltiaor, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
dd23583 to
7c44ecd
Compare
CLA Signature Passlltiaor, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
7c44ecd to
ed98dfa
Compare
CLA Signature Passlltiaor, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |



总结
新增对 TRL 快速上手文档的自动化测试看护。被看护的文档为
sources/trl/quick_start.md:示例在单张 NPU(Atlas 900 A2 / Ascend 910B4)上,使用 Qwen2.5-0.5B-Instruct 分别执行 SFT LoRA 和 DPO LoRA。模型和数据集均通过 ModelScope 自动下载。文档分别安装 TRL 和 SFT/DPO 示例依赖;训练脚本输出 LoRA 适配器的保存目录。
变更文件
新增:
sources/trl/index.rst、sources/trl/quick_start.md、.github/workflows/trl-quick-start.yml和tests/trl/。删除:已过时的
sources/trl/install.rst、quick_start.rst和images/image.png。调整:
conf.py将quick_start.md加入排除列表,由index.rst作为 TRL 侧边栏落地页;首页 toctree 和 TRL 卡片链接均指向sources/trl/index.rst。验证
手动触发workflow测试通过