EMNLP Findings2025
SACL: Understanding and Combating Textual Bias in Code Retrieval with Semantic-Augmented Reranking and Localization
Abstract
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). sum_to_num is a function that sums numbers from 1 to num. Query (Instruction)def sum_to_num(num: int):"""Calculate the sum of all integers from 0 to num, inclusive."""return sum(range(num+1)) Orig Functiondef sum_to_num(num: int): """Calculate the sum of all integers from 0 to num, inclusive."""return sum(range(num+1))
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
Lineage
- Precise Zero-Shot Dense Retrieval without Relevance Labels cites Dense Passage Retrieval for Open-Domain Question Answering
- ReACC: A Retrieval-Augmented Code Completion Framework cites Dense Passage Retrieval for Open-Domain Question Answering
- ReACC: A Retrieval-Augmented Code Completion Framework cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
Builds on11
- CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan et al.EMNLP Findings 2020 · 2,828 citations
- SWE-bench: Can Language Models Resolve Real-world Github Issues?Carlos E. Jimenez, John Yang, Alexander Wettig, Shunyu Yao et al.ICLR 2024 · 2,082 citations
- Precise Zero-Shot Dense Retrieval without Relevance LabelsLuyu Gao, Xueguang Ma, Jimmy Lin, Jamie CallanACL 2023 · 211 citations
- ReACC: A Retrieval-Augmented Code Completion FrameworkShuai Lu, Nan Duan, Hojae Han, Daya Guo et al.ACL 2022 · 208 citations
- Dense Passage Retrieval for Open-Domain Question AnsweringVladimir Karpukhin, Barlas Oguz, Sewon Min, Patrick Lewis et al.EMNLP 2020 · 142 citations
Related papers
- SRACG: A Code Generation Framework with Selective Retrieval AugmentationMengzhen Wang, Shukai Ma, Songwen Gong, Jiexin Wang et al.AAAI 2026
- RESCUE: Retrieval Augmented Secure Code GenerationJiahao Shi, Tianyi ZhangICLR 2026 · 15 citations
- cAST: Enhancing Code Retrieval-Augmented Generation with Structural Chunking via Abstract Syntax TreeYilin Zhang, Xinran Zhao, Zora Zhiruo Wang, Chenyang Yang et al.EMNLP Findings 2025 · 11 citations
- Retrieval Augmented Code Generation and SummarizationMd. Rizwan Parvez, Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray et al.EMNLP Findings 2021 · 141 citations
- Preference-Guided Refactored Tuning for Retrieval Augmented Code GenerationXinyu Gao, Yun Xiong, Deze Wang, Zhenhan Guan et al.ASE 2024 · 1 citation
