PulseExploreJournal ClubDebatesTrendingResearchersJournals
Instagram
HomeExploreJournal ClubTrending
Synapse
⌘+K
Synapse
July 2, 2026Proceedings of the ACM on software engineering.0 citationsOpen Access

Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond

View Full Paper
MLMinh Le-AnhHNHuyen NguyenATAn Khanh Tran

Key Points

  • The aim is to improve code generation performance within repositories by rethinking how code is treated.
  • Introduced a structure-aware indexing strategy representing code as hierarchical trees.
  • Developed a lightweight dependency-aware retriever to identify relevant dependencies.
  • Combined dependency-aware retrieval with traditional similarity-based methods.
  • Hydra achieved a greater than 5% improvement in Pass@1 compared to the strongest baseline.
  • Smaller models performed comparably to larger models using traditional retrieval methods.
  • State-of-the-art performance established on DevEval and RepoExec benchmarks.

Abstract

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.

Ask AI
Helpful
Bookmark
Share
View Full Paper

Cite This Study

Le-Anh et al. (2026) studied this question.

synapsesocial.com/papers/6a4600489ed13430313107a9https://doi.org/10.1145/3797144
Ask AI
Helpful
Bookmark
Share
View Full Paper

Also Consider

Synapse has enriched 5 closely related papers on similar clinical questions. Consider them for comparative context:

  1. 1Evaluating Retrieval-Augmented Generation Strategies for Repository-Level Code Understanding2026
  2. 2Enhancing Repository-Level Code Generation with Integrated Contextual Information2024 · 3 citations
  3. 3Repoformer: Selective Retrieval for Repository-Level Code Completion2024 · 3 citations
  4. 4Class-Level Code Generation from Natural Language Using Iterative, Tool-Enhanced Reasoning over Repository2024 · 2 citations
  5. 5One Size Does Not Fit All: Revisiting Code Context Engineering for Repository-Level Code Generation2026