Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond
Not on the map. Why?
Abstract (arXiv)
Large language models for code (CodeLLMs) have demonstrated remarkable success in standalone code completion and generation, sometimes even surpassing human performance, yet their effectiveness diminishes in repository-level settings where cross-file dependencies and structural context are essential. Existing Retrieval-Augmented Generation (RAG) approaches often borrow strategies from NLP, relying on chunking-based indexing and similarity-based retrieval. Chunking results in the loss of coherence between code units and overlooks structural relationships, while similarity-driven methods frequently miss functionally relevant dependencies such as helper functions, classes, or global variables. To address these limitations, we present Hydra, a repository-level code generation framework that treats code as structured code rather than natural language. Our approach introduces (i) a structure-aware indexing strategy that represents repositories as hierarchical trees of functions, classes, and variables, preserving code structure and dependencies, (ii) a lightweight dependency-aware retriever (DAR) that explicitly identifies and retrieves the true dependencies required by a target function, and (iii) a hybrid retrieval mechanism that combines DAR with similarity-based retrieval to provide both essential building blocks and practical usage examples. Extensive experiments on the challenging DevEval and RepoExec benchmarks, both requiring function implementation from real-world repositories with complex large repository context, show that Hydra achieves state-of-the-art performance across open- and closed-source CodeLLMs. Notably, our method establishes a new state of the art in repository-level code generation, surpassing strongest baseline by over 5% in Pass@1 and even enabling smaller models to match or exceed the performance of much larger ones that rely on existing retrievers.
Key facts. Cited by 3 papers in the map (data through 7 Oct 2026). First posted on arXiv 12 Feb 2026.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2026: 3.
3 papers.
- 2026From paper to benchmark: agentic, framework-based reproduction of under-specified methods in machine health intelligencecited by 1
- 2026ProjAgent: Procedural Similarity Retrieval for Repository-Level Code Generationcited by 0
- 2026FeatLens: Feature-Guided Dynamic Code Graph Construction and Retrieval for Repository-Level Code Generationcited by 0
- 2026FeatLens: Feature-Guided Dynamic Code Graph Construction and Retrieval for Repository-Level Code Generation22 Sep 2026
- 2026ProjAgent: Procedural Similarity Retrieval for Repository-Level Code Generation9 Jul 2026
- 2026From paper to benchmark: agentic, framework-based reproduction of under-specified methods in machine health intelligence27 May 2026
Similar, not cited
Close in wording, no citation either way
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches
- 2025cAST: Enhancing Code Retrieval-Augmented Generation with Structural Chunking via Abstract Syntax Tree
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completion
- 2026Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generation
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
- 2025SaraCoder: Orchestrating Semantic and Structural Cues for Resource-Optimized Repository-Level Code Completion
- 2025Completion by Comprehension: Guiding Code Generation with Multi-Granularity Understanding
- 2026Better Call Grep: Evaluating and Improving Grep-Like Lexical Retrieval for Repository-Level Code Completion