arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2105.09630cs.SE
收藏

利用强化学习丰富代码搜索的查询语义

Enriching Query Semantics for Code Search with Reinforcement Learning

Chaozheng Wang, Zhenghao Nong, Cuiyun Gao, Zongjie Li, Jichuan Zeng, Zhenchang Xing, Yang Liu

摘要:

代码搜索是开发人员在软件实现过程中的常见做法。精确代码搜索的挑战主要在于源代码和自然语言之间的知识差距(即,查询)。由于有限的代码-查询对和大量的代码-描述对,基于深度学习技术的先前研究集中于学习源代码和任务的对应描述文本之间的语义匹配关系,并假设描述和用户查询之间的语义差距是边际的。在这项工作中,我们发现在代码描述对上训练的代码搜索模型可能在用户查询上表现不佳,这表明查询和代码描述之间的语义距离。为了减轻语义距离,更有效的代码搜索,我们提出了QueCos,查询丰富的代码搜索模型。QueCos通过强化学习(RL)学习生成语义丰富的查询以捕获给定查询的关键语义。使用RL,代码搜索性能被认为是产生准确的语义丰富查询的奖励。丰富的查询最终用于代码搜索。在基准数据集上的实验表明,QueCos可以显着优于最先进的代码搜索模型。

英文摘要:

Code search is a common practice for developers during software implementation. The challenges of accurate code search mainly lie in the knowledge gap between source code and natural language (i.e., queries). Due to the limited code-query pairs and large code-description pairs available, the prior studies based on deep learning techniques focus on learning the semantic matching relation between source code and corresponding description texts for the task, and hypothesize that the semantic gap between descriptions and user queries is marginal. In this work, we found that the code search models trained on code-description pairs may not perform well on user queries, which indicates the semantic distance between queries and code descriptions. To mitigate the semantic distance for more effective code search, we propose QueCos, a Query-enriched Code search model. QueCos learns to generate semantic enriched queries to capture the key semantics of given queries with reinforcement learning (RL). With RL, the code search performance is considered as a reward for producing accurate semantic enriched queries. The enriched queries are finally employed for code search. Experiments on the benchmark datasets show that QueCos can significantly outperform the state-of-the-art code search models.

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

↑