[论文解读] CodeSearchNet Challenge: Evaluating the State of Semantic Code Search
该论文介绍 CodeSearchNet 语料库和 CodeSearchNet 挑战,包含 99 个自然语言查询和专家相关性注释,用以评估在六种编程语言上的语义代码检索,并呈现基线神经与信息检索模型及随附的排行榜。
Semantic code search is the task of retrieving relevant code given a natural language query. While related to other information retrieval tasks, it requires bridging the gap between the language used in code (often abbreviated and highly technical) and natural language more suitable to describe vague concepts and ideas. To enable evaluation of progress on code search, we are releasing the CodeSearchNet Corpus and are presenting the CodeSearchNet Challenge, which consists of 99 natural language queries with about 4k expert relevance annotations of likely results from CodeSearchNet Corpus. The corpus contains about 6 million functions from open-source code spanning six programming languages (Go, Java, JavaScript, PHP, Python, and Ruby). The CodeSearchNet Corpus also contains automatically generated query-like natural language for 2 million functions, obtained from mechanically scraping and preprocessing associated function documentation. In this article, we describe the methodology used to obtain the corpus and expert labels, as well as a number of simple baseline solutions for the task. We hope that CodeSearchNet Challenge encourages researchers and practitioners to study this interesting task further and will host a competition and leaderboard to track the progress on the challenge. We are also keen on extending CodeSearchNet Challenge to more queries and programming languages in the future.
研究动机与目标
- 提供一个大规模、现实世界的语义代码检索数据集,通过将代码与文档配对。
- 定义一个标准化评估任务(CodeSearchNet Challenge),附带专家相关性标签。
- 提供基线模型和评估协议,以跟踪代码检索研究的进展。
- 突出挑战与洞见,为未来在神经网络与信息检索方法的改进提供指导。
提出的方法
- 通过抓取开源仓库并将函数与处理后的文档配对,组装 CodeSearchNet 语料库。
- 通过筛选规则对数据进行预处理,生成现实的训练对并删除无信息量或重复的项。
- 定义 CodeSearchNet Challenge,包含 99 个自然语言查询以及跨六种语言的专家标注相关结果。
- 使用神经编码器(NBoW、1D-CNN、双向循环神经网络、自注意力)开发基线代码检索模型,并采用联合嵌入目标将代码与查询映射到共享向量空间。
- 使用 Annoy 对所有函数建立索引,以实现快速近似最近邻搜索,并与 ElasticSearch 基线进行比较。
- 使用训练任务上的平均倒数排名(MRR)和更广泛语料库上的归一化折扣累计增益(NDCG)进行评估(Within 与 All)。
实验结果
研究问题
- RQ1一个代码检索语料库可以有多大且有多嘈杂,同时仍能有效训练神经模型?
- RQ2在 CodeSearchNet 设置下,哪些基线方法(神经与传统信息检索)在语义代码检索中表现最佳?
- RQ3联合代码-查询嵌入在跨多语言的自然语言查询中,如何对相关代码片段进行排序?
- RQ4当前代码检索方法与数据集的实际挑战与局限是什么?
- RQ5像 MRR 与 NDCG 这样的评估指标如何反映在带注释与完整语料库上的性能?
主要发现
- CodeSearchNet 语料库包含大约 650 万个函数,覆盖六种语言,大约 230 万个函数-文档对。
- 基线神经模型表现各异,其中自注意力和简单的词袋方法在不同任务和设定中显示出较强的结果。
- ElasticSearch 仍是基于关键字的代码检索的有竞争力的基线,凸显了超越词汇匹配利用语义的挑战。
- NDCG 在带注释子集(Within)与完整语料库(All)上的结果不同,强调注释的局限性和数据集噪声。
- 对相关性的跨评注者一致性适中,表明由于代码检索任务中的歧义和上下文,判断具有主观性。
- 定性观察指出诸如代码质量、查询歧义、项目特定代码,以及匹配查询与代码时上下文和方向正确性的重要性等问题。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。