Code retrieval is essential in modern software development, as it boosts code reuse and accelerates debugging. However, current benchmarks primarily emphasize functional relevance while neglecting critical dimensions of software quality. Motivated by this gap, we introduce CoQuIR, the first large-scale, multilingual benchmark specifically designed to evaluate quality-aware code retrieval across four key dimensions: correctness, efficiency, security, and maintainability. CoQuIR provides fine-grained quality annotations for 42,725 queries and 134,907 code snippets in 11 programming languages, and is accompanied by two quality-centric evaluation metrics: Pairwise Preference Accuracy and Margin-based Ranking Score. Using CoQuIR, we benchmark 23 retrieval models, covering both open-source and proprietary systems, and find that even top-performing models frequently fail to distinguish buggy or insecure code from their more robust counterparts. Furthermore, we conduct preliminary investigations into training methods that explicitly encourage retrievers to recognize code quality. Using synthetic datasets, we demonstrate promising improvements in quality-aware metrics across various models, without sacrificing semantic relevance. Downstream code generation experiments further validate the effectiveness of our approach. Overall, our work highlights the importance of integrating quality signals into code retrieval systems, laying the groundwork for more trustworthy and robust software development tools.


翻译:代码检索在现代软件开发中至关重要,它能提升代码复用性并加速调试过程。然而,现有基准主要强调功能相关性,忽视了软件质量的关键维度。针对这一空白,我们提出CoQuIR——首个大规模、多语言基准,专门评估四个关键维度上的质量感知代码检索:正确性、效率、安全性与可维护性。CoQuIR为42,725个查询和134,907个代码片段(涵盖11种编程语言)提供了细粒度质量标注,并配套两种质量中心评估指标:成对偏好准确率(Pairwise Preference Accuracy)和边际排序得分(Margin-based Ranking Score)。利用CoQuIR,我们对23个检索模型(涵盖开源与专有系统)进行基准测试,发现即使顶级模型也常无法区分存在缺陷或不安全的代码及其稳健版本。此外,我们初步探索了明确引导检索器识别代码质量的训练方法。通过合成数据集,我们展示了在不牺牲语义相关性的前提下,各类模型在质量感知指标上的显著提升。下游代码生成实验进一步验证了方法的有效性。总体而言,本工作凸显了将质量信号融入代码检索系统的重要性,为构建更可信、更稳健的软件开发工具奠定基础。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
《深度学习代码智能》综述、基准和工具集
专知会员服务
56+阅读 · 2024年1月2日
《人工智能芯片基准测试评估方法》行业标准
专知会员服务
87+阅读 · 2022年2月20日
专知会员服务
10+阅读 · 2021年1月31日
【Facebook】人工智能基准(Benchmarking)测试再思考,55页ppt
专知会员服务
31+阅读 · 2020年12月20日
《代码整洁之道》:5大基本要点
专知会员服务
50+阅读 · 2020年3月3日
一行命令搞定图像质量评价
计算机视觉life
12+阅读 · 2019年12月31日
基于 SonarQube 的增量代码扫描
DevOps时代
12+阅读 · 2019年7月18日
技术动态 | TechKG:一个面向中文学术领域的大型知识图谱
开放知识图谱
25+阅读 · 2018年12月20日
基于图片内容的深度学习图片检索(一)
七月在线实验室
20+阅读 · 2017年10月1日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
6+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
7+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
4+阅读 · 6月17日
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员