arXivDaily arXiv每日学术速递 周一至周五更新
北美退伍军人节(Veterans Day),12 日无更新
arXiv 2408.09006cs.SE
收藏

Context-aware Code Summary Generation(上下文感知的代码摘要生成)

Context-aware Code Summary Generation

Chia-Yi Su, Aakash Bansal, Yu Huang, Toby Jia-Jun Li, Collin McMillan

AI总结:

针对现有LLM代码摘要仅关注局部代码、缺少函数存在原因及全局上下文作用的问题,提出含上下文的代码摘要方法,通过两步训练3.5亿参数本地模型,性能优于GPT-4。

摘要:

代码摘要生成是为一段源代码编写自然语言描述的任务。大语言模型(LLMs)及其他基于AI的技术的最新进展,已让自动代码摘要成为现实。然而,这些方法生成的摘要往往聚焦于代码的局部区域,最终得到的摘要仅解释函数内部的功能,却缺少对函数存在的原因,或是其在程序更广泛上下文中作用的描述。\n本文提出了一种将此类上下文融入当前基于LLM的代码摘要的方法。该方法的输入为一个Java方法及其所属的项目,输出是关于该方法为何存在于项目中的简洁英文描述。方法的核心是我们训练的一个拥有3.5亿(350m)参数的语言模型,该模型可在本地运行以保障隐私。模型训练分为两步:首先从一个大模型中蒸馏代码摘要相关的知识,随后利用一项针对人类程序员的研究数据对模型进行微调,该研究要求程序员编写代码摘要。实验发现,我们的方法在该任务上的表现优于GPT-4。

英文摘要:

Code summary generation is the task of writing natural language descriptions of a section of source code. Recent advances in Large Language Models (LLMs) and other AI-based technologies have helped make automatic code summarization a reality. However, the summaries these approaches write tend to focus on a narrow area of code. The results are summaries that explain what that function does internally, but lack a description of why the function exists or its purpose in the broader context of the program. In this paper, we present an approach for including this context in recent LLM-based code summarization. The input to our approach is a Java method and that project in which that method exists. The output is a succinct English description of why the method exists in the project. The core of our approach is a 350m parameter language model we train, which can be run locally to ensure privacy. We train the model in two steps. First we distill knowledge about code summarization from a large model, then we fine-tune the model using data from a study of human programmer who were asked to write code summaries. We find that our approach outperforms GPT-4 on this task.

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

↑