CRaDLe:基于语义依赖学习的深度代码检索
CRaDLe: Deep Code Retrieval Based on Semantic Dependency Learning
摘要:
代码检索是程序员重用开源存储库中现有代码片段的常见做法。给定用户查询(即,自然语言描述),代码检索旨在从一组代码片段中搜索最相关的代码片段。有效代码检索的主要挑战在于缓解自然语言描述和代码片段之间的语义鸿沟。随着可用开源代码数量的不断增加,最近的研究采用神经网络来学习两个源代码之间的语义匹配关系。语句级依赖信息突出了程序语句在执行过程中的依赖关系,反映了代码中一条语句的结构重要性,有利于准确捕捉代码语义,但从未被用于代码检索任务。在本文中,我们提出了CRaDLe,一种新的方法,代码检索基于语句级语义依赖学习。具体来说,CRaDLe通过在语句级别融合依赖性和语义信息来提取代码表示,然后为每个代码和描述对学习统一的向量表示,用于对匹配关系进行建模。在真实数据集上的综合实验和分析表明,该方法可以准确地检索给定查询的代码片段,并显着优于最先进的方法的任务。
英文摘要:
Code retrieval is a common practice for programmers to reuse existing code snippets in open-source repositories. Given a user query (i.e., a natural language description), code retrieval aims at searching for the most relevant ones from a set of code snippets. The main challenge of effective code retrieval lies in mitigating the semantic gap between natural language descriptions and code snippets. With the ever-increasing amount of available open-source code, recent studies resort to neural networks to learn the semantic matching relationships between the two sources. The statement-level dependency information, which highlights the dependency relations among the program statements during the execution, reflects the structural importance of one statement in the code, which is favorable for accurately capturing the code semantics but has never been explored for the code retrieval task. In this paper, we propose CRaDLe, a novel approach for Code Retrieval based on statement-level semantic Dependency Learning. Specifically, CRaDLe distills code representations through fusing both the dependency and semantic information at the statement level and then learns a unified vector representation for each code and description pair for modeling the matching relationship. Comprehensive experiments and analysis on real-world datasets show that the proposed approach can accurately retrieve code snippets for a given query and significantly outperform the state-of-the-art approaches to the task.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。