用小模型生成规范的代码提交信息,让每次提交都清晰有用。
CommitLLM: A Fine-Tuned Pipeline for Git Commit Message Generation

- 用微调的小模型结合约束解码生成提交消息
- 格式合规率98%,长度从154字减至38字,评分提升超80%
- 适合想提升代码可读性的开发者和团队
开发者常写'fix'或'update stuff'这类无意义的提交信息,降低了版本历史对代码审查、调试和新人上手的价值。我们提出CommitLLM,一个三阶段流水线,利用微调的小语言模型从代码差异中生成简洁且符合Conventional Commits规范的提交信息。系统包含:(1) 在CommitPackFT数据集上对Mistral-7B-Instruct-v0.2进行QLoRA微调;(2) 约束解码以保证简短;(3) 确定性后处理去除对话式内容并强制格式。在50个样本的评估中,该系统达到98%格式合规率(对比原版Mistral仅22%),平均输出长度从154.8降至37.9字符,LLM-as-a-Judge评分从1.97升至3.68(满分5分)。值得注意的是,后处理层带来的改进超过微调本身,表明对于结构化输出任务,将大模型视为确定性流水线中的组件比单纯优化模型更有效。整个系统可在单块消费级显卡(NVIDIA T4,16 GB VRAM)上运行。
原文摘要 · Abstract (English)
Developers frequently write uninformative git commit messages such as "fix" or "update stuff", degrading the value of version-control history for code review, debugging, and onboarding. We present CommitLLM, a three-stage pipeline that generates concise, Conventional Commits-compliant messages from code diffs using a fine-tuned small language model. The system combines (1) QLoRA fine-tuning of Mistral-7B-Instruct-v0.2 on the CommitPackFT dataset, (2) constrained decoding to enforce brevity, and (3) deterministic post-processing to strip conversational artifacts and enforce format. On a 50-sample evaluation, CommitLLM achieves 98% format compliance (vs. 22% for vanilla Mistral), reduces average output length from 154.8 to 37.9 characters, and improves LLM-as-a-Judge scores from 1.97 to 3.68 out of 5. Notably, the post-processing layers contribute more to quality improvement than the fine-tuning itself, suggesting that for structured-output tasks, treating the LLM as a component in a deterministic pipeline is more effective than optimizing the model alone. The entire system runs on a single consumer GPU (NVIDIA T4, 16 GB VRAM).
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。