| 摘要: |
| 提交日志是一类描述代码变更的自然语言文本, 对理解代码及代码演化过程十分重要. 受限于软件开发成本等因素, 开发人员往往不会精心撰写提交日志, 导致现有软件项目的提交日志质量堪忧. 鉴于此, 提交日志自动生成任务受到了广泛关注. 现有工作主要从开源软件项目中收集提交日志数据, 并基于此训练深度学习模型完成任务. 然而, 受限于开源项目数据质量, 现有工作难以取得令人满意的效果. 大语言模型通过在大规模代码和文本数据上的预训练, 学习了丰富的语言规律和世界知识, 能够生成高质量、自然且符合上下文的文本, 为提交日志生成提供了新的思路. 提出基于大语言模型的提交日志生成方法, 通过上下文学习、模型微调等手段将大语言模型用于提交日志生成, 使用两种示例检索方法增强上下文学习方法, 并从自然性和相关性角度分析生成文本, 研究大语言模型方法的优势与不足以及如何应对不足. 实验证实了大语言模型表现超过基线方法, 且思维链及更大规模模型能应对对代码变更理解不足的情况. |
| 关键词: 提交日志生成 大语言模型 上下文学习 模型微调 |
| DOI:10.13328/j.cnki.jos.007640 |
| 分类号:TP311 |
| 基金项目:国家自然科学基金(62025202, 62072225); 江苏省前沿技术研发计划(BF2024059) |
|
| Commit Message Generation Based on Large Language Models |
|
XU Sheng-Bin1, JIA Lin-Jie1, XU Tang-Zhi1, ZHU Xiao-Rui2, YU Ping1, XU Feng1, MA Xiao-Xing1
|
|
1.State Key Laboratory for Novel Software Technology (Nanjing University), Nanjing 210023, China;2.College of Information Engineering, Nanjing Xiaozhuang University, Nanjing 211171, China
|
| Abstract: |
| Commit messages are natural language text that describe code changes and are crucial for understanding code and its evolution. Constrained by software development costs and related factors, developers often fail to carefully craft commit messages, resulting in unsatisfactory quality in existing software projects. As a result, commit message generation has gained widespread attention. Current work mainly involves collecting commit message data from open-source software projects and training deep learning models on this data to accomplish the task. However, due to the quality issues of open-source project data, existing methods struggle to achieve satisfactory performance. Large language models, by pre-training on vast amounts of code and text data, learn rich linguistic patterns and world knowledge, enabling the generation of high-quality, natural, and contextually appropriate text, thus providing new directions for commit message generation. This study proposes a commit message generation method based on large language models, in which large language models are applied to commit message generation through techniques such as in-context learning and model fine-tuning. Two example retrieval methods are employed to enhance the in-context learning approach. The generated text is then analyzed in terms of naturalness and relevance, and the strengths and limitations of the large language model-based methods, as well as ways to address these limitations, are examined. Experiments demonstrate that large language models outperform baseline methods. In addition, chain-of-thought reasoning and larger-scale models can address the issue of insufficient understanding of code changes. |
| Key words: commit message generation large language model (LLM) in-context learning model fine-tuning |