解决代码检索中的文本偏见问题,提升生成质量。
SACL: Understanding and Combating Textual Bias in Code Retrieval with Semantic-Augmented Reranking and Localization
- 通过语义增强重排序与定位,缓解对表面文本的依赖。
- 在三个数据集上召回率最高提升12.8%,代码生成准确率提升4.88%。
- 适合关注代码生成鲁棒性与检索公平性的研究者。
检索增强型代码生成(RACG)是通过检索相关信息来提升代码生成性能的关键技术。本文系统性地掩码特定特征以保留代码功能,深入分析代码检索机制。发现:(1)当前检索器虽基于代码训练,却严重依赖表面文本特征(如文档字符串、标识符名称);(2)对文档充分的代码存在显著偏好,即使文档内容无关。基于此,我们提出SACL框架,通过引入语义信息增强代码或结构知识,减少偏见。大量实验表明,SACL显著提升代码检索性能(如HumanEval / MBPP / SWE-Bench-Lite上Recall@1分别提升12.8% / 9.4% / 7.0%),并进一步改善代码生成效果(HumanEval上Pass@1提升4.88%)。
原文摘要 · Abstract (English)
Retrieval-Augmented Code Generation (RACG) is a critical technique for enhancing code generation by retrieving relevant information. In this work, we conduct an in-depth analysis of code retrieval by systematically masking specific features while preserving code functionality. Our discoveries include: (1) although trained on code, current retrievers heavily rely on surface-level textual features (e.g., docstrings, identifier names), and (2) they exhibit a strong bias towards well-documented code, even if the documentation is irrelevant. Based on our discoveries, we propose SACL, a framework that enriches textual information and reduces bias by augmenting code or structural knowledge with semantic information. Extensive experiments show that SACL substantially improves code retrieval (e.g., by 12.8% / 9.4% / 7.0% Recall@1 on HumanEval / MBPP / SWE-Bench-Lite), which also leads to better code generation performance (e.g., by 4.88% Pass@1 on HumanEval).
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。