CodeDSI:可微分代码搜索
CodeDSI: Differentiable Code Search
摘要:
重新实现以前解决的软件工程问题的解决方案不仅效率低下,而且还会引入不充分和容易出错的代码。许多现有的方法通过使用在代码上训练的自回归文本生成模型在这个问题上取得了令人印象深刻的性能。然而,这些方法并非没有缺陷。从这些模型生成的代码可能存在错误,缺乏文档,并引入可能被开发人员忽视的漏洞。代码生成的另一种选择--神经代码搜索--是机器学习的一个领域,其中模型将自然语言查询作为输入,反过来,从数据库返回相关的代码样本。由于这个预先存在的数据库的性质,代码样本可以在开发人员在生产中使用之前进行记录,测试,许可和检查漏洞。在这项工作中,我们提出了CodeDSI,一个端到端的统一的代码搜索方法。CodeDSI被训练为直接将自然语言查询映射到它们各自的代码样本,这些代码样本可以在以后检索。为了提高代码搜索的性能,我们研究了docid表示策略,标记化对docid结构的影响,以及数据集大小对整体代码搜索性能的影响。我们的研究结果证明了CodeDSI的强大性能,在不同的数据集大小上超过传统的鲁棒基线2 - 6%。
英文摘要:
Reimplementing solutions to previously solved software engineering problems is not only inefficient but also introduces inadequate and error-prone code. Many existing methods achieve impressive performance on this issue by using autoregressive text-generation models trained on code. However, these methods are not without their flaws. The generated code from these models can be buggy, lack documentation, and introduce vulnerabilities that may go unnoticed by developers. An alternative to code generation -- neural code search -- is a field of machine learning where a model takes natural language queries as input and, in turn, relevant code samples from a database are returned. Due to the nature of this pre-existing database, code samples can be documented, tested, licensed, and checked for vulnerabilities before being used by developers in production. In this work, we present CodeDSI, an end-to-end unified approach to code search. CodeDSI is trained to directly map natural language queries to their respective code samples, which can be retrieved later. In an effort to improve the performance of code search, we have investigated docid representation strategies, impact of tokenization on docid structure, and dataset sizes on overall code search performance. Our results demonstrate CodeDSI strong performance, exceeding conventional robust baselines by 2-6% across varying dataset sizes.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。