EUVIMEDEUVIMED entdecken
Open Access · CC BY 4.0

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

Minh Le-Anh, Huyen Nguyen, An Khanh Tran, Nam Le Hai, Linh Ngo Van, Nghi D.Q. Bui, Bach Le

Proceedings of the ACM on Software Engineering · 30.06.2026 · 3 (FSE) · 366-389

DOI: 10.1145/3797144 ↗

Kurz gefasst

Fachartikel in der Zeitschrift Proceedings of the ACM on Software Engineering, online erschienen am 30.06.2026. Verfasst von Minh Le-Anh und 6 weiteren Autor:innen. Die Arbeit nennt 58 Literaturangaben. Der Volltext ist frei zugänglich (Open Access, CC BY 4.0). Gefördert von: PhD Scholarship Programme of Vingroup Innovation Foundation (VINIF), VinUniversity.

AbstractBibliografische AngabenZitierenVerwandte Studien

Abstract (Originalsprache)

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.

Förderung

  • PhD Scholarship Programme of Vingroup Innovation Foundation (VINIF), VinUniversity

Zitieren

APA

Le-Anh, M., Nguyen, H., Tran, A. K., Hai, N. L., Van, L. N., Bui, N. D., & Le, B. (2026). Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond. Proceedings of the ACM on Software Engineering, 3(FSE), 366-389. https://doi.org/10.1145/3797144

Vancouver

Le-Anh M, Nguyen H, Tran AK, Hai NL, Van LN, Bui ND, et al. Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond. Proceedings of the ACM on Software Engineering. 2026;3(FSE):366-389. doi:10.1145/3797144

BibTeX
@article{LeAnh2026,
  author = {Le-Anh, Minh and Nguyen, Huyen and Tran, An Khanh and Hai, Nam Le and Van, Linh Ngo and Bui, Nghi D.Q. and Le, Bach},
  title = {Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond},
  journal = {Proceedings of the ACM on Software Engineering},
  year = {2026},
  volume = {3},
  number = {FSE},
  pages = {366--389},
  doi = {10.1145/3797144}
}
Kostenlos starten →