arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2304.06815cs.SEcs.LG
收藏

语言模型提示的自动语义增强(用于代码摘要)

Automatic Semantic Augmentation of Language Model Prompts (for Code Summarization)

University of California, Davis(加州大学戴维斯分校);University College London(伦敦大学学院);Google Brain(谷歌大脑)

Toufique Ahmed, Kunal Suresh Pai, Premkumar Devanbu, Earl T. Barr

AI总结:

本文研究在代码摘要任务中显式地向LLM提示添加自动提取的语义事实是否有效,实验表明该方法在多种设置和两个LLM上均提升性能,多数提升接近或超过2 BLEU,PHP上超过30 BLEU。

摘要:

大型语言模型(LLM)是一类新的计算引擎,通过提示工程进行“编程”。我们仍在学习如何最好地“编程”这些LLM以帮助开发者。我们从一种直觉出发:开发者在处理编码任务时,往往会有意识或无意识地在脑海中持有一组语义事实。这些大多是浅层、简单的事实,来源于快速阅读。对于一个函数,事实的例子可能包括参数和局部变量名、返回表达式、简单的前置条件和后置条件,以及基本的控制流和数据流等。\n\n人们可能会假设,transformer风格LLM强大的多层架构使其在处理代码时天生具备这种简单级别的“代码分析”能力,并能隐式地提取这些信息:但它们真的能做到吗?如果做不到,显式地添加这些信息是否会有帮助?我们的目标是利用代码摘要任务来研究这个问题,并评估自动用语义事实显式增强LLM的提示是否真的有效。\n\n先前的工作表明,LLM在代码摘要上的性能受益于从同一项目中抽取的少样本示例,或通过信息检索方法(如BM25)找到的示例。尽管摘要性能自早期以来稳步提升,但仍有改进空间:LLM在代码摘要上的性能仍落后于其在翻译和文本摘要等自然语言任务上的表现。\n\n我们发现,添加语义事实确实有帮助!这种方法在先前工作提出的多种不同设置中提升了性能,包括针对两种不同的大型语言模型。在大多数情况下,提升接近或超过2 BLEU;对于具有挑战性的CodeSearchNet数据集中的PHP语言,这种增强实际上使性能超过了30 BLEU。

英文摘要:

Large Language Models (LLM) are a new class of computation engines, "programmed" via prompt engineering. We are still learning how to best "program" these LLMs to help developers. We start with the intuition that developers tend to consciously and unconsciously have a collection of semantics facts in mind when working on coding tasks. Mostly these are shallow, simple facts arising from a quick read. For a function, examples of facts might include parameter and local variable names, return expressions, simple pre- and post-conditions, and basic control and data flow, etc. One might assume that the powerful multi-layer architecture of transformer-style LLMs makes them inherently capable of doing this simple level of "code analysis" and extracting such information, implicitly, while processing code: but are they, really? If they aren't, could explicitly adding this information help? Our goal here is to investigate this question, using the code summarization task and evaluate whether automatically augmenting an LLM's prompt with semantic facts explicitly, actually helps. Prior work shows that LLM performance on code summarization benefits from few-shot samples drawn either from the same-project or from examples found via information retrieval methods (such as BM25). While summarization performance has steadily increased since the early days, there is still room for improvement: LLM performance on code summarization still lags its performance on natural-language tasks like translation and text summarization. We find that adding semantic facts actually does help! This approach improves performance in several different settings suggested by prior work, including for two different Large Language Models. In most cases, improvement nears or exceeds 2 BLEU; for the PHP language in the challenging CodeSearchNet dataset, this augmentation actually yields performance surpassing 30 BLEU.

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

↑