Qwen3.5-0.8B 微调:让日常英语变成 bash 命令的经验

我想要一个完全离线可用的终端助手,于是开始开发 dale:输入 dale "show the 5 largest files in this folder",微调小模型写出命令,确定性的风险检查器在执行前将其标注为 safe、caution 或 danger,未经确认任何命令都不会运行。
运行这个应用
我想要一个完全离线可用的终端助手,于是开始开发 dale。你输入 dale "show the 5 largest files in this folder",一个小型微调模型写出命令,一个确定性的风险检查器在执行前把它标注为 safe、caution 或 danger。未经你确认,任何命令都不会运行。
在 471 条英语和西班牙语留出(held-out)请求上的得分,所有模型均为 Q4_K_M、跑在同一个 llama.cpp 上:
| 模型 | GGUF | 正确 | 准确率 | 95% CI |
|---|---|---|---|---|
| dale-9b (GPU) | 5.6 GB | 420 | 89.2% | 86.0–91.7 |
| dale-4b (GPU) | 2.7 GB | 410 | 87.0% | 83.7–89.8 |
| dale-2b | 1.3 GB | 385 | 81.7% | 78.0–85.0 |
| dale-0.8b (CPU) | 529 MB | 374 | 79.4% | 75.5–82.8 |
| Qwen3.5-9B,原版 | 5.7 GB | 296 | 62.8% | 58.4–67.1 |
| Gemma 4 E4B-it,原版 | 5.0 GB | 296 | 62.8% | 58.4–67.1 |
| Qwen3.5-4B,原版 | 2.7 GB | 257 | 54.6% | 50.0–59.0 |
| Gemma 4 E2B-it,原版 | 3.1 GB | 254 | 53.9% | 49.4–58.4 |
| Qwen3.5-2B,原版 | 1.3 GB | 152 | 32.3% | 28.2–36.6 |
| Qwen3.5-0.8B,原版 | 533 MB | 70 | 14.9% | 11.9–18.4 |
在一台 2020 年、无 GPU 的笔记本上,0.8B 的中位回答耗时 1.7 秒;4B 在 16 GB 显存的 GPU 上经 Vulkan 为 1.2 秒。全部是一个内含 llama.cpp 的 51 MB 单一二进制文件,不依赖 Python,也没有服务器。
微调家族对比
差异长什么样。测试中的真实回答(请求有删节),dale-0.8b 对比原版 Qwen3.5-9B:
- 请求:Temporarily freeze PID 22601 without terminating it.
dale-0.8b:kill -STOP 22601
原版 Qwen3.5-9B:写 /proc/22601/oom_score_adj,什么都没冻结
- 请求:Copy offer.pdf into /mnt/usb/, but leave any existing offer.pdf there untouched.
dale-0.8b:cp -n …/offer.pdf /mnt/usb/
原版:sudo cp …/offer.pdf /mnt/usb/,会覆盖已有文件
- 请求:Can you give me the prime factorization of 1234567890 from the terminal?
dale-0.8b:factor 1234567890
原版:一条 180 字符、语法错误的 python3 -c 单行命令
- 请求:I just need the total disk usage of /opt/model-cache, in a readable size.
dale-0.8b:du -sh /opt/model-cache
原版:对文件夹用 os.path.getsize(),得到的是目录条目大小而非内容
- 请求:Lock the password of the local account archivebot.
dale-0.8b:sudo passwd -l archivebot
原版:sudo passwd archivebot,会设置新密码
- 请求:For this Bash session, make ll an alias for ls -alF.
dale-0.8b:alias ll='ls -alF'
原版:拒绝执行:"not possible with a single shell command"
当然是挑出来的:有 120 个用例只有 dale 做 对,42 个只有 9B 做 对。原版 9B 还特别爱用 sudo:给 35 条不需要的命令加了 sudo(dale:5 条)。
失败的对比
真希望早点有人告诉我这件事:四轮数据之后,0.8B 卡在了 74%。我试过只用它的失败案例做 DPO、用微调过的 27B 教师做五种蒸馏配置、第三个 epoch、学习率扫描,测试结果纹丝不动。我他妈为此浪费了好几天 :(,但至少弄明白了这个过程中什么才重要。
然后我去研究了请求是怎么写的。我的训练请求短小干净,测试请求更长、约束层层叠加,比如"只要名字、按日期排序、不要子文件夹"。https://preview.redd.it/oocu4a0qoe0i1.png?width=2304&format=png&auto=webp&s=fa30e71800cbc722c89f76a9210744f6acc7fb49
我按这些统计特征生成新请求,往数据集加了约 9k 条并重新训练:正确数从 348 → 375(p = 0.001)。https://preview.redd.it/11bdtj5soe0i1.png?width=2304&format=png&auto=webp&s=db8e2a2158263f25100424512595b7d2031a1025
所以,如果小模型在一个窄任务上停滞不前,先看看你的数据是怎么写的,再考虑更花哨的方法。
注意事项:基线模型未微调、使用 8-shot 提示,所以这是"微调的小模型 vs 提示工程的大模型"的对比,不是模型排名。测试集是合成的,由两家不同提供商的 LLM 打分(TOP TIER)。以上工作全部在租用的 GPU(RTX 5090 和 RTX Pro 6000)上完成。代码为 MIT 许可,模型是 Apache-2.0 的 GGUF,可直接用原版 llama.cpp 运行。
带全部图表和死胡同的完整记录:https://manuelgs.com/en/blog/dale-case-study/
代码:https://github.com/manuelgscom/dale
模型(0.8B 到 9B):https://huggingface.co/collections/manuelgscom/dale
有没有人真正让"从大得多的教师模型蒸馏"在 1B 以下见效?我没能做到。欢迎赐教 :) submitted by /u/AlternativeEnough352 [link] [comments]