Files
ti_coding_agent_probe/README.md

122 lines
3.5 KiB
Markdown
Raw 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.
# TI Coding Agent Training Probe
这个仓库用于复现一组 coding-agent SFT probing 实验:从 Hugging Face 下载已经构造好的 Open-SWE-Traces probe 数据集,下载 Qwen3.5-9B 和 Qwen3.6-27B然后用 ModelScope-SWIFT 依次跑四个 1 epoch 训练任务。
## 目录
- `third_party/modelscope-swift/`: ModelScope-SWIFT submodule。
- `scripts/setup_env.sh`: 一键创建 repo 内 `.venv` 并安装本项目和 SWIFT。
- `scripts/download_dataset.py`: 下载 Hugging Face 数据集并解压 `train.jsonl``validation.jsonl`
- `scripts/download_models.sh`: 下载 Qwen3.5-9B 和 Qwen3.6-27B 到 `models/`
- `scripts/train_qwen35_9b_lora.sh`: Qwen3.5-9B rank=32 LoRA。
- `scripts/train_qwen35_9b_full.sh`: Qwen3.5-9B bf16 full SFT。
- `scripts/train_qwen36_27b_lora.sh`: Qwen3.6-27B rank=32 LoRA。
- `scripts/train_qwen36_27b_full.sh`: Qwen3.6-27B bf16 full SFT。
- `scripts/run_all_experiments.sh`: 按 LoRA 9B -> full 9B -> LoRA 27B -> full 27B 的顺序执行完整实验。
- `runs/`: TensorBoard 日志目录。
- `logs/`: 训练 stdout/stderr 和实际命令记录。
- `outputs/`: checkpoint 和最终模型权重输出目录。
- `data/`: 下载后的训练和验证数据,默认不进 git。
- `models/`: 下载后的 base model默认不进 git。
## 环境部署
在 B300 上使用:
```bash
cd /ssd/workspace/yi/ti_coding_agent_probe
git submodule update --init --recursive
./scripts/setup_env.sh
```
脚本会显式设置 B300 代理:
```bash
http://100.72.0.101:8888
```
Python 依赖安装在仓库内 `.venv`,不会写入系统 Python。
## 下载数据集
数据集默认名是 `ti_coding_agent_training_probe_20260624`。如果环境里设置了 `HF_TOKEN`,脚本会用 token owner 自动拼成 `owner/ti_coding_agent_training_probe_20260624`。也可以显式指定:
```bash
export HF_ENDPOINT=https://hf-mirror.com
export HF_DATASET_REPO_ID=<owner>/ti_coding_agent_training_probe_20260624
./scripts/download_dataset.py
```
输出:
- `data/raw/training_probe/`: Hugging Face snapshot。
- `data/processed/training_probe/train.jsonl`
- `data/processed/training_probe/validation.jsonl`
训练数据里 `system``user``tool` 消息带 `loss=false`,只有 assistant 轨迹带 `loss=true`。system prompt 会作为上下文参与 attention但不作为预测目标计算 loss。
## 下载模型
```bash
./scripts/download_models.sh
```
默认模型 ID
- `Qwen/Qwen3.5-9B`
- `Qwen/Qwen3.6-27B`
如果 Hugging Face 上实际模型 ID 有变化,可以覆盖:
```bash
export QWEN35_9B_MODEL_ID=<actual-9b-id>
export QWEN36_27B_MODEL_ID=<actual-27b-id>
./scripts/download_models.sh
```
## 单步训练
每个训练脚本默认:
- `num_train_epochs=1`
- `lora_rank=32`
- `torch_dtype=bfloat16`
- `save_steps=1000`
- `eval_steps=1000`
- `report_to=tensorboard`
- `max_length=262144`
- `warmup_ratio=0.1`
- `learning_rate=1e-5`
命令:
```bash
./scripts/train_qwen35_9b_lora.sh
./scripts/train_qwen35_9b_full.sh
./scripts/train_qwen36_27b_lora.sh
./scripts/train_qwen36_27b_full.sh
```
## 一键完整实验
确认 GPU 空闲后执行:
```bash
./scripts/run_all_experiments.sh
```
执行顺序固定为:
1. Qwen3.5-9B LoRA
2. Qwen3.5-9B bf16 full SFT
3. Qwen3.6-27B LoRA
4. Qwen3.6-27B bf16 full SFT
## TensorBoard
```bash
./scripts/tensorboard.sh
```
训练日志会写到 `runs/<run_name>/`。SWIFT/Transformers 的 TensorBoard 标量通常包括 loss、learning rate、eval loss、runtime、samples/sec、steps/sec 等 throughput 指标;同时 stdout 会保存在 `logs/<run_name>.log`