CoaCor:基于强化学习的代码检索标注
CoaCor: Code Annotation for Code Retrieval with Reinforcement Learning
摘要:
为了加速软件开发,已经进行了许多研究来帮助人们理解和重用大量可用的代码资源。两个重要的任务已经被广泛研究:代码检索,其目的是从代码库中检索与给定自然语言查询相关的代码片段,以及代码注释,其中目标是用自然语言描述来注释代码片段。尽管这两项任务近年来取得了进展,但大多数情况下是分别探讨的。在这项工作中,我们调查了一个新的角度代码注释代码检索(因此称为“CoaCor'),其中代码注释模型被训练生成一个自然语言注释,可以表示一个给定的代码片段的语义含义,并可以利用代码检索模型,以更好地区分相关的代码片段。为此,我们提出了一个基于强化学习的有效框架,它明确鼓励代码注释模型生成可用于检索任务的注释。通过大量的实验,我们表明,我们的框架生成的代码注释更详细,更有用的代码检索,他们可以进一步提高现有的代码检索模型的性能显着。
英文摘要:
To accelerate software development, much research has been performed to help people understand and reuse the huge amount of available code resources. Two important tasks have been widely studied: code retrieval, which aims to retrieve code snippets relevant to a given natural language query from a code base, and code annotation, where the goal is to annotate a code snippet with a natural language description. Despite their advancement in recent years, the two tasks are mostly explored separately. In this work, we investigate a novel perspective of Code annotation for Code retrieval (hence called `CoaCor'), where a code annotation model is trained to generate a natural language annotation that can represent the semantic meaning of a given code snippet and can be leveraged by a code retrieval model to better distinguish relevant code snippets from others. To this end, we propose an effective framework based on reinforcement learning, which explicitly encourages the code annotation model to generate annotations that can be used for the retrieval task. Through extensive experiments, we show that code annotations generated by our framework are much more detailed and more useful for code retrieval, and they can further improve the performance of existing code retrieval models significantly.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。