|
Download README_axis_dpo_transfer.md from bingqin111/axis_dpo_scripts: direct link, hf CLI and curl.
- Browser
- Download file 8.42 kB
-
https://huggingface.co/datasets/bingqin111/axis_dpo_scripts/resolve/main/README_axis_dpo_transfer.md
- Command line
-
hf download hf://datasets/bingqin111/axis_dpo_scripts/README_axis_dpo_transfer.md
-
curl -L -o README_axis_dpo_transfer.md https://huggingface.co/datasets/bingqin111/axis_dpo_scripts/resolve/main/README_axis_dpo_transfer.md
8.42 kB
| # Axis-controlled DPO Eval Transfer Notes | |
| 这个 README 用来在换到 H20 或其它机器后快速恢复当前实验上下文。 | |
| ## 1. 当前实验目标 | |
| 继续执行 Stage 3 的 Exp 5: | |
| ```text | |
| Axis-controlled Long-context DPO Behavior Eval | |
| ``` | |
| 目标是用已经筛好的 A/B/C/D 四个语义轴长上下文 prompt,让每个 DPO 后模型生成下一条 assistant 回复,然后做 blind LLM-as-judge,分析 A6.3-DPO 在哪些轴和哪些能力指标上胜出。 | |
| 保留的 judge 指标: | |
| ```text | |
| context_continuity | |
| relationship_consistency | |
| emotional_trajectory | |
| plot_progression | |
| boundary_control | |
| overall_quality | |
| ``` | |
| ## 2. 当前状态 | |
| 已经完成: | |
| 1. 四轴 prompt pool 已经筛好。 | |
| 2. 每个 axis 保留 80 条,共 320 条。 | |
| 3. 每条 prompt 是 `system/persona + 最近 5 个 user 轮次 + 中间 4 个 assistant 轮次`。 | |
| 4. 最后一条一定是 user,等待 DPO 模型生成下一条 assistant。 | |
| 5. 原始 `chosen/rejected` 文本没有放进 prompt pool,只保留 hash。 | |
| 6. 本机 4090 上错误参数跑出的 DPO generation 已经删除。 | |
| 还没有完成: | |
| 1. 8 个 DPO 模型对 320 条 prompt 的正式生成。 | |
| 2. blind pairwise judge request 构造。 | |
| 3. LLM-as-judge 实际打分。 | |
| 4. judge 结果汇总和报告更新。 | |
| ## 3. 已筛好的语料位置 | |
| 正式生成要用这个 JSONL: | |
| ```bash | |
| /home/bingqinshao/Data_Process/stage3/outputs/axis_prompt_pools/axis_prompt_pool_v1_80.jsonl | |
| ``` | |
| 人工审核版: | |
| ```bash | |
| /home/bingqinshao/Data_Process/stage3/outputs/axis_prompt_pools/axis_prompt_pool_v1_80_review.md | |
| /home/bingqinshao/Data_Process/stage3/outputs/axis_prompt_pools/axis_prompt_pool_v1_80_review.csv | |
| ``` | |
| 过滤统计: | |
| ```bash | |
| /home/bingqinshao/Data_Process/stage3/outputs/axis_prompt_pools/axis_prompt_pool_v1_80_reject_stats.csv | |
| ``` | |
| ## 4. 需要转到 H20 的脚本 | |
| 如果 prompt pool 已经带过去,不需要重新筛语料,所以不需要跑 `10_build_axis_prompt_pools.py`。 | |
| 需要用的脚本: | |
| ```bash | |
| /home/bingqinshao/Data_Process/stage3/11_generate_dpo_model_responses.py | |
| /home/bingqinshao/Data_Process/stage3/12_build_axis_judge_requests.py | |
| /home/bingqinshao/Data_Process/stage3/13_summarize_axis_judge_results.py | |
| ``` | |
| 可选保留,不需要重新执行: | |
| ```bash | |
| /home/bingqinshao/Data_Process/stage3/10_build_axis_prompt_pools.py | |
| ``` | |
| ## 5. DPO 模型目录 | |
| 模型目录: | |
| ```bash | |
| /home/bingqinshao/Data_Process/dpo_model | |
| ``` | |
| 当前发现 8 个 DPO 模型: | |
| ```text | |
| A0.0 | |
| A6.3 | |
| A9.4 | |
| A12.5 | |
| A18.8 | |
| A25.0 | |
| A37.5 | |
| A50.0 | |
| ``` | |
| 生成脚本默认会按这个顺序跑所有存在的模型。后续汇总重点看 `A6.3` vs 其它模型,尤其是 `A0.0 / A25.0 / A50.0`。 | |
| ## 6. H20 上正式生成命令 | |
| 建议在 tmux 里跑: | |
| ```bash | |
| tmux new -s stage3_axis_gen | |
| ``` | |
| 进入 stage3 目录: | |
| ```bash | |
| cd /home/bingqinshao/Data_Process/stage3 | |
| mkdir -p outputs/axis_dpo_generations | |
| ``` | |
| H20 显存足够时,建议不用 CPU offload,直接 `--device-map cuda`: | |
| ```bash | |
| CUDA_VISIBLE_DEVICES=0 /opt/conda/envs/llamafactory/bin/python \ | |
| 11_generate_dpo_model_responses.py \ | |
| --prompt-pool /home/bingqinshao/Data_Process/stage3/outputs/axis_prompt_pools/axis_prompt_pool_v1_80.jsonl \ | |
| --model-root /home/bingqinshao/Data_Process/dpo_model \ | |
| --output /home/bingqinshao/Data_Process/stage3/outputs/axis_dpo_generations/axis_prompt_pool_v1_80_generations.jsonl \ | |
| --status /home/bingqinshao/Data_Process/stage3/outputs/axis_dpo_generations/axis_prompt_pool_v1_80_generation_status.json \ | |
| --device-map cuda \ | |
| --max-new-tokens 192 | |
| ``` | |
| 如果想恢复原计划更长回复,可以把 `--max-new-tokens 192` 改成 `256`。建议先用 `192` 跑完第一版,保证 judge 成本和生成耗时可控。 | |
| 脚本支持断点续跑:如果输出 JSONL 已有部分成功结果,再次运行会跳过已经成功的 `(prompt_id, model_label)`。 | |
| ## 7. 生成完成后检查 | |
| 理论输出条数: | |
| ```text | |
| 320 prompts * 8 models = 2560 rows | |
| ``` | |
| 检查状态: | |
| ```bash | |
| cat /home/bingqinshao/Data_Process/stage3/outputs/axis_dpo_generations/axis_prompt_pool_v1_80_generation_status.json | |
| ``` | |
| 检查行数: | |
| ```bash | |
| wc -l /home/bingqinshao/Data_Process/stage3/outputs/axis_dpo_generations/axis_prompt_pool_v1_80_generations.jsonl | |
| ``` | |
| 如果 `completed=2560` 且 `errors=0`,可以进入 judge request 构造。 | |
| ## 8. 构造 blind judge 请求 | |
| 生成完成后跑: | |
| ```bash | |
| cd /home/bingqinshao/Data_Process/stage3 | |
| mkdir -p outputs/axis_judge | |
| /opt/conda/envs/llamafactory/bin/python \ | |
| 12_build_axis_judge_requests.py \ | |
| --prompt-pool outputs/axis_prompt_pools/axis_prompt_pool_v1_80.jsonl \ | |
| --generations outputs/axis_dpo_generations/axis_prompt_pool_v1_80_generations.jsonl \ | |
| --output outputs/axis_judge/axis_prompt_pool_v1_80_pairwise_judge_requests.jsonl \ | |
| --comparison primary | |
| ``` | |
| `--comparison primary` 默认比较: | |
| ```text | |
| A6.3 vs A0.0 | |
| A6.3 vs A9.4 | |
| A6.3 vs A12.5 | |
| A6.3 vs A18.8 | |
| A6.3 vs A25.0 | |
| A6.3 vs A37.5 | |
| A6.3 vs A50.0 | |
| ``` | |
| 理论 judge request 数量: | |
| ```text | |
| 320 prompts * 7 comparisons = 2240 requests | |
| ``` | |
| 如果要做 8 模型全 pairwise,改成: | |
| ```bash | |
| --comparison all | |
| ``` | |
| 但第一版建议先用 `primary`,更聚焦 A6.3 解释。 | |
| ## 9. Judge 结果格式 | |
| judge 结果需要和 request 通过 `judge_id` 对齐。每条结果里需要包含 judge 输出 JSON,字段至少包括: | |
| ```json | |
| { | |
| "judge_id": "...", | |
| "response": { | |
| "context_continuity": "A_better/B_better/tie", | |
| "relationship_consistency": "A_better/B_better/tie", | |
| "emotional_trajectory": "A_better/B_better/tie", | |
| "plot_progression": "A_better/B_better/tie", | |
| "boundary_control": "A_better/B_better/tie", | |
| "overall_quality": "A_better/B_better/tie", | |
| "short_reason": "..." | |
| } | |
| } | |
| ``` | |
| 汇总脚本也能解析这些字段名: | |
| ```text | |
| parsed_judge | |
| judge_json | |
| judge_output | |
| response | |
| ``` | |
| 其中 `response` 可以是 dict,也可以是包含 JSON 的字符串。 | |
| ## 10. Judge 结果汇总 | |
| 假设 judge 结果保存为: | |
| ```bash | |
| /home/bingqinshao/Data_Process/stage3/outputs/axis_judge/axis_prompt_pool_v1_80_pairwise_judge_results.jsonl | |
| ``` | |
| 运行: | |
| ```bash | |
| cd /home/bingqinshao/Data_Process/stage3 | |
| /opt/conda/envs/llamafactory/bin/python \ | |
| 13_summarize_axis_judge_results.py \ | |
| --requests outputs/axis_judge/axis_prompt_pool_v1_80_pairwise_judge_requests.jsonl \ | |
| --results outputs/axis_judge/axis_prompt_pool_v1_80_pairwise_judge_results.jsonl \ | |
| --output-dir outputs/axis_judge/summary | |
| ``` | |
| 输出: | |
| ```bash | |
| outputs/axis_judge/summary/axis_model_dimension_win_rates.csv | |
| outputs/axis_judge/summary/axis_a63_vs_each_model_win_rates.csv | |
| outputs/axis_judge/summary/judge_parse_summary.csv | |
| ``` | |
| 最重要看: | |
| ```bash | |
| outputs/axis_judge/summary/axis_a63_vs_each_model_win_rates.csv | |
| ``` | |
| 它会按 `axis + dimension + opponent` 统计 A6.3 的胜率。 | |
| ## 11. 后续报告要写什么 | |
| 生成和 judge 完成后,回到这台机器或继续在 H20 上更新报告: | |
| ```bash | |
| /home/bingqinshao/Data_Process/stage3/stage3_results_analysis_report.md | |
| ``` | |
| 需要新增 Exp5 结果: | |
| 1. A6.3 在 A/B/C/D 哪些 axis 胜出。 | |
| 2. A6.3 在哪些指标胜出:context continuity、relationship consistency、emotional trajectory、plot progression、boundary control、overall quality。 | |
| 3. 如果 A6.3 在 B/C/D 的长剧情指标胜出,同时 boundary control 不差,就能支撑论文叙事: | |
| ```text | |
| 少量 A 类让 RM 懂边界,大量 B/C/D 让 RM 保留角色质量; | |
| A6.3 的优势不是静态 RM accuracy,而是下游 DPO 后模型在长剧情承接、关系一致性、情绪轨迹和沉浸感上更稳。 | |
| ``` | |
| 4. 如果只在 A 轴 boundary control 胜出,B/C/D 不明显,则论文叙事要收窄为安全边界优势。 | |
| ## 12. 注意事项 | |
| 1. 不要重新跑 prompt pool 筛选,除非明确要改语料。 | |
| 2. 不要把原始 chosen/rejected 加回 prompt pool。 | |
| 3. 生成脚本输出可以断点续跑,不需要手动合并。 | |
| 4. 如果换机器路径不同,命令里的 `/home/bingqinshao/Data_Process` 改成对应路径即可。 | |
| 5. H20 上建议先跑 1 个模型 1 条样本 smoke: | |
| ```bash | |
| CUDA_VISIBLE_DEVICES=0 /opt/conda/envs/llamafactory/bin/python \ | |
| 11_generate_dpo_model_responses.py \ | |
| --models A6.3 \ | |
| --max-prompts 1 \ | |
| --max-new-tokens 64 \ | |
| --device-map cuda \ | |
| --output /tmp/stage3_axis_gen_smoke.jsonl \ | |
| --status /tmp/stage3_axis_gen_smoke_status.json | |
| ``` | |
| smoke 成功后再跑正式命令。 | |