论文标题
深图匹配和寻找语义代码检索
Deep Graph Matching and Searching for Semantic Code Retrieval
论文作者
论文摘要
代码检索是要从大量的源代码存储库中找到代码片段,这些代码代码存储库与自然语言描述的查询高度匹配。最近的工作主要使用自然语言处理技术来处理查询文本(即人类自然语言)和代码片段(即机器编程语言),但是忽略了查询文本和源代码的深层结构化特征,它们都包含丰富的语义信息。在本文中,我们建议基于图神经网络的端到端深度匹配和搜索(DGMS)模型,以实现语义代码检索的任务。为此,我们首先用统一的图形结构数据表示自然语言查询文本和编程语言代码片段,然后使用所提出的图形匹配和搜索模型来检索最佳的匹配代码片段。特别是,DGM不仅捕获了单个查询文本或代码片段的更多结构信息,而且还通过基于跨注意的语义匹配操作来了解它们之间的细粒度相似性。我们使用两种代表性编程语言(即Java和Python)评估了两个公共代码检索数据集上提出的DGMS模型。实验结果表明,在两个数据集上,DGM都大大优于最先进的基线模型。此外,我们广泛的消融研究系统地研究并说明了DGM的每个部分的影响。
Code retrieval is to find the code snippet from a large corpus of source code repositories that highly matches the query of natural language description. Recent work mainly uses natural language processing techniques to process both query texts (i.e., human natural language) and code snippets (i.e., machine programming language), however neglecting the deep structured features of query texts and source codes, both of which contain rich semantic information. In this paper, we propose an end-to-end deep graph matching and searching (DGMS) model based on graph neural networks for the task of semantic code retrieval. To this end, we first represent both natural language query texts and programming language code snippets with the unified graph-structured data, and then use the proposed graph matching and searching model to retrieve the best matching code snippet. In particular, DGMS not only captures more structural information for individual query texts or code snippets but also learns the fine-grained similarity between them by cross-attention based semantic matching operations. We evaluate the proposed DGMS model on two public code retrieval datasets with two representative programming languages (i.e., Java and Python). Experiment results demonstrate that DGMS significantly outperforms state-of-the-art baseline models by a large margin on both datasets. Moreover, our extensive ablation studies systematically investigate and illustrate the impact of each part of DGMS.