arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.13013cs.CL
收藏

代码需要注释:通过注释增强提升代码大语言模型

Code Needs Comments: Enhancing Code LLMs with Comment Augmentation

Shanghai AI Laboratory(上海人工智能实验室);School of Computer Science, Fudan University(复旦大学计算机科学技术学院);The Chinese University of Hong Kong(香港中文大学)

Demin Song, Honglin Guo, Yunhua Zhou, Shuhao Xing, Yudong Wang, Zifan Song, Wenwei Zhang, Qipeng Guo, Hang Yan, Xipeng Qiu, Dahua Lin

AI总结:

本文针对预训练中代码-注释对齐数据稀缺的问题,提出注释生成与数据过滤相结合的数据增强方法,在三个代码大语言模型上验证了其对编程能力的稳定提升效果。

摘要:

编程能力是大语言模型(LLMs)的一项关键能力,这需要深入理解编程语言(PLs)及其与自然语言(NLs)之间的关联。我们通过评估注释密度作为编程语言-自然语言对齐程度的度量指标,考察了预训练数据对以代码为核心的大语言模型性能的影响。鉴于预训练语料库中代码-注释对齐数据的稀缺性,我们提出了一种新颖的数据增强方法,为现有代码生成注释,并结合一种数据过滤策略,滤除与自然语言相关性较差的代码数据。我们在三个以代码为核心的大语言模型上进行了实验,并观察到它们在两个广泛使用的编程能力基准测试上的性能均获得了一致提升。值得注意的是,在增强数据上训练的模型,其表现优于用于生成注释的模型,也优于在未经增强的数据上进一步训练的模型。

英文摘要:

The programming skill is one crucial ability for Large Language Models (LLMs), necessitating a deep understanding of programming languages (PLs) and their correlation with natural languages (NLs). We examine the impact of pre-training data on code-focused LLMs' performance by assessing the comment density as a measure of PL-NL alignment. Given the scarcity of code-comment aligned data in pre-training corpora, we introduce a novel data augmentation method that generates comments for existing code, coupled with a data filtering strategy that filters out code data poorly correlated with natural language. We conducted experiments on three code-focused LLMs and observed consistent improvements in performance on two widely-used programming skill benchmarks. Notably, the model trained on the augmented data outperformed both the model used for generating comments and the model further trained on the data without augmentation.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑