Beyond "What to Retrieve": Uncertainty in Retrieval-Augmented Code Generation
On the map: Retrieval-augmented generation → RAG for code
Abstract (arXiv)
Repository-level code generation relies on heterogeneous evidence whose relevance, compatibility, and completeness are inherently uncertain. Similar-code examples, repository context, and project-specific APIs may provide complementary information, but can also introduce noisy, redundant, or conflicting signals. Existing retrieval-augmented approaches primarily optimize retrieval relevance without explicitly modeling how uncertainty in retrieved evidence affects downstream generation. We introduce OpenCoder, an uncertainty-aware framework that estimates source-specific uncertainty, uses it to filter and rank heterogeneous evidence, and guides generation, verification, and repair. A factorial analysis over API knowledge, repository context, and similar-code evidence reveals no universal additive source ranking; instead, significant cross-source interactions depend on the accompanying evidence and LLM backend. On an expanded 32-task RepoExec-inline evaluation, OpenCoder improves GPT selected-output correctness over Baseline RAG from 56.25% to 78.13%. However, it matches a verification-and-repair control, and the corresponding Gemini improvement is not statistically supported, indicating backend-dependent benefits. Target-aware API refinement also substantially improves API-set retrieval. These findings support treating uncertainty as an actionable control signal for repository-level retrieval, verification, and repair.
Key facts. Cited by 1 paper in the map (data through 7 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 20 of its 30 references that are in the map. First posted on arXiv 27 Jul 2026.
Builds on
20 of 30 references.
Closest ancestors · 4
Same direction, newest first
- 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond26 Mar
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completion15 Mar
- 2022ReACC: A Retrieval-Augmented Code Completion Framework15 Mar
- 2021Retrieval Augmented Code Generation and Summarization26 Aug
Other references · 16
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2017On Calibration of Modern Neural Networkscited by 4,860
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2023Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflectioncited by 1,800
- 2023Teaching Large Language Models to Self-Debugcited by 963
- 2022CodeT: Code Generation with Generated Testscited by 369
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 355
- 2023LEVER: Learning to Verify Language-to-Code Generation with Executioncited by 228
- 2022DocPrompting: Generating Code by Retrieving the Docscited by 151
- 2023Can ChatGPT replace StackOverflow? A Study on Robustness and Reliability of Large Language Model Code Generationcited by 72
4 more
- 2024On the Impacts of Contexts on Repository-Level Code Generationcited by 21
- 2024Retrieval-Augmented Generation with Estimation of Source Reliabilitycited by 19
- 2024ExecRepoBench: Multi-level Executable Code Completion Evaluationcited by 19
- 2025Incoherence as Oracle-less Measure of Error in LLM-Based Code Generationcited by 6
Built on by
Citing papers per year: 2026: 1.
1 paper.
Similar, not cited
Close in wording, no citation either way
- 2026Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generation
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches
- 2026Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
- 2024On The Importance of Reasoning for Context Retrieval in Repository-Level Code Editing
- 2025SaraCoder: Orchestrating Semantic and Structural Cues for Resource-Optimized Repository-Level Code Completion
- 2026In Line with Context: Repository-Level Code Generation via Context Inlining
- 2025FastCoder: Accelerating Repository-level Code Generation via Efficient Retrieval and Verification