Lune

EMNLP Findings2025

SACL: Understanding and Combating Textual Bias in Code Retrieval with Semantic-Augmented Reranking and Localization

Dhruv Gupta, Gayathri Ganesh Lakshmy, Yiqing Xie

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.

Questions to start from

Lune can draw on

the full paper · related work

Get the answer

Free to start. No credit card required.

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 onCited byLeft to right by year; the more cited, the higher.

Builds on11

  1. 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
  2. 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
  3. Precise Zero-Shot Dense Retrieval without Relevance LabelsLuyu Gao, Xueguang Ma, Jimmy Lin, Jamie CallanACL 2023 · 211 citations
  4. ReACC: A Retrieval-Augmented Code Completion FrameworkShuai Lu, Nan Duan, Hojae Han, Daya Guo et al.ACL 2022 · 208 citations
  5. Dense Passage Retrieval for Open-Domain Question AnsweringVladimir Karpukhin, Barlas Oguz, Sewon Min, Patrick Lewis et al.EMNLP 2020 · 142 citations

Related papers

  1. SRACG: A Code Generation Framework with Selective Retrieval AugmentationMengzhen Wang, Shukai Ma, Songwen Gong, Jiexin Wang et al.AAAI 2026
  2. RESCUE: Retrieval Augmented Secure Code GenerationJiahao Shi, Tianyi ZhangICLR 2026 · 15 citations
  3. 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
  4. Retrieval Augmented Code Generation and SummarizationMd. Rizwan Parvez, Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray et al.EMNLP Findings 2021 · 141 citations
  5. Preference-Guided Refactored Tuning for Retrieval Augmented Code GenerationXinyu Gao, Yun Xiong, Deze Wang, Zhenhan Guan et al.ASE 2024 · 1 citation
Dusk over the sea between two cliffs drawn in fine vertical lines