Elamur Research⌕
☰
home / papers / 2026 / Late Code Chunking: A Code Chunking Strategy for Repository-Level Code Completion

Late Code Chunking: A Code Chunking Strategy for Repository-Level Code Completion

Paper · 2026 · Seungmin Oh and Eunseok Lee

Summary

Repository-level code completion depends on retrieving relevant code from other files in a project. When source code is split into retrievable chunks, those fragments often lose meaning. A variable may appear without its initialization, or a function may be called without its definition. This makes it hard for LLMs to use the retrieved code. The authors propose Late Code Chunking (LC 2), which keeps two views of each chunk:

  • a token-based Code Retrieval Context, used only for similarity search;
  • a richer Code Comprehension Context, built after retrieval and passed to the model.

The richer view is made by adding the code that precedes the chunk and the signatures and docstrings of functions it calls. The method also uses Asymmetric Query–Chunk Sizing: a short query (the final tokens of the unfinished code) is matched against larger chunks, which reduces noise in the query. Tested on RepoEval and CrossCodeEval with six LLMs and four retrievers, LC 2 beat all baseline chunking strategies in every setting. This shows that restoring lost context after retrieval is a cheap, model-agnostic way to improve retrieval-augmented completion.

Key points

  • Main result: On CrossCodeEval (Python), using DeepSeekCoder-1.3B and UniXcoder, EM rose from 22.01 with Fixed-Token, the strongest baseline, to 26.35. This is a relative gain of 19.7% and is statistically significant.
  • Configuration:
    • 512-token retrieval chunks with a 64-token query.
    • Expansion of up to 512 extra preceding tokens.
    • Up to 3 called functions added as signature plus docstring.
    • Top-5 retrieval, with an 8,192-token total input.
  • Baselines: In-File, Fixed-Window (10 lines), Split-Aggregate (from RLCoder), Function-Level and Fixed-Token (512 tokens).
  • Generalization across models:
    • With Codestral, EM rose from 13.89 (In-File) to 37.61.
    • DeepSeekCoder-7B gained +23.50 EM.
    • Among retrievers, CodeRankLLM scored highest (EM 29.47), and BM25 (26.20) came close to the dense retrievers.
  • Limitation: Function augmentation sometimes hurt results, for example on C#, when the added signatures were uninformative. Code is released at github.com/bonohubby/late-code-chunking.

Our summary of the paper, in our own words — not its text. The work belongs to its authors; read it at the links above.

 Institutions

 Fields, topics and concepts

Cite

Cite as Seungmin Oh and Eunseok Lee. 2026. Late Code Chunking: A Code Chunking Strategy for Repository-Level Code Completion. Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers).

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.18653/v1/2026.acl-short.64

@inproceedings{oh2026late,
  title = {{Late Code Chunking: A Code Chunking Strategy for Repository-Level Code Completion}},
  author = {Seungmin Oh and Eunseok Lee},
  booktitle = {Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers)},
  year = {2026},
  doi = {10.18653/v1/2026.acl-short.64},
  url = {https://doi.org/10.18653/v1/2026.acl-short.64}
}

References

24 references, 6 of them with a card of ours. ↗ leads to the work, «find» searches for one we have no id for yet.

  1. Wei Cheng, Yuhan Wu, and Wei Hu. 2024. Dataflow-guided retrieval augmentation for repository-level code completion. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 7957–7977, Bangkok, Thailand. find
  2. Matteo Ciniselli, Nathan Cooper, Luca Pascarella, Denys Poshyvanyk, Massimiliano Di Penta, and Gabriele Bavota. 2021. An empirical study on the usage of bert models for code completion. Preprint, arXiv:2103.07115. — [arXiv:2103.07115](https://arxiv.org/abs/2103.07115) find
  3. Yangruibo Ding, Zijian Wang, Wasi Uddin Ahmad, Hantian Ding, Ming Tan, Nihal Jain, Murali Krishna Ramanathan, Ramesh Nallapati, Parminder Bhatia, Dan Roth, and Bing Xiang. 2023. Crosscodeeval: A diverse and multilingual benchmark for cross-file code completion. Preprint, arXiv:2310.11248. — [arXiv:2310.11248](https://arxiv.org/abs/2310.11248) find
  4. Luyu Gao, Zhuyun Dai, and Jamie Callan. 2021. COIL: Revisit exact lexical match in information retrieval with contextualized inverted list. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 3030–30…
  5. Daya Guo, Shuai Lu, Nan Duan, Yanlin Wang, Ming Zhou, and Jian Yin. 2022. UniXcoder: Unified cross-modal pre-training for code representation. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 7212–7225, Dublin, Ireland.
  6. Daya Guo, Qihao Zhu, Dejian Yang, Zhenda Xie, Kai Dong, Wentao Zhang, Guanting Chen, Xiao Bi, Y. Wu, Y. K. Li, Fuli Luo, Yingfei Xiong, and Wenfeng Liang. 2024. Deepseek-coder: When the large language model meets programming – the rise of code intelligence. Preprint, arXiv:2401.14196. find
  7. Michael Günther, Isabelle Mohr, Daniel James Williams, Bo Wang, and Han Xiao. 2025. Late chunking: Contextual chunk embeddings using long-context embedding models. Preprint, arXiv:2409.04701. — [arXiv:2409.04701](https://arxiv.org/abs/2409.04701) find
  8. Maliheh Izadi, Roberta Gismondi, and Georgios Gousios. 2022. Codefill: multi-token code completion by jointly learning from structure and naming sequences. In Proceedings of the 44th International Conference on Software Engineering, ICSE ’22, page 401–412, New York, NY, USA. Association for Computin… find
  9. Vladimir I. Levenshtein. 1965. Binary codes capable of correcting deletions, insertions, and reversals. Soviet physics. Doklady, 10:707–710. find
  10. Jiaheng Liu, Ken Deng, Congnan Liu, Jian Yang, Shukai Liu, He Zhu, Peng Zhao, Linzheng Chai, Yanan Wu, JinKe JinKe, Ge Zhang, Zekun Moore Wang, Guoan Zhang, Yingshui Tan, Bangyu Xiang, Zhaoxiang Zhang, Wenbo Su, and Bo Zheng. 2025. M2RC-EVAL: Massively multilingual repository-level code completion e…
  11. Nelson F. Liu, Kevin Lin, John Hewitt, Ashwin Paranjape, Michele Bevilacqua, Fabio Petroni, and Percy Liang. 2024a. Lost in the middle: How language models use long contexts. Transactions of the Association for Computational Linguistics, 12:157–173.
  12. Wei Liu, Ailun Yu, Daoguang Zan, Bo Shen, Wei Zhang, Haiyan Zhao, Zhi Jin, and Qianxiang Wang. 2024b. Graphcoder: Enhancing repository-level code completion via code context graph-based retrieval and language model. Preprint, arXiv:2406.07003. — [arXiv:2406.07003](https://arxiv.org/abs/2406.07003) find
  13. Anton Lozhkov, Raymond Li, Loubna Ben Allal, Federico Cassano, Joel Lamy-Poirier, Nouamane Tazi, Ao Tang, Dmytro Pykhtar, Jiawei Liu, Yuxiang Wei, Tianyang Liu, Max Tian, Denis Kocetkov, Arthur Zucker, Younes Belkada, Zijian Wang, Qian Liu, Dmitry Abulkhanov, Indraneil Paul, and 47 others. 2024. Sta… find
  14. Shuai Lu, Daya Guo, Shuo Ren, Junjie Huang, Alexey Svyatkovskiy, Ambrosio Blanco, Colin Clement, Dawn Drain, Daxin Jiang, Duyu Tang, Ge Li, Lidong Zhou, Linjun Shou, Long Zhou, Michele Tufano, MING GONG, Ming Zhou, Nan Duan, Neel Sundaresan, and 3 others. 2021. CodeXGLUE: A machine learning benchmar… find
  15. AI Mistral. 2024. Codestral, 2024. URL: https://mistral.ai/news/codestral. ↗
  16. Stephen Robertson, Hugo Zaragoza, and 1 others. 2009. The probabilistic relevance framework: Bm25 and beyond. Foundations and Trends® in Information Retrieval, 3(4):333–389. find
  17. Hongjin Su, Shuyang Jiang, Yuhang Lai, Haoyuan Wu, Boao Shi, Che Liu, Qian Liu, and Tao Yu. 2024. EvoR: Evolving retrieval for code generation. In Findings of the Association for Computational Linguistics: EMNLP 2024, pages 2538–2554, Miami, Florida, USA. find
  18. Tarun Suresh, Revanth Gangi Reddy, Yifei Xu, Zach Nussbaum, Andriy Mulyar, Brandon Duderstadt, and Heng Ji. 2025. CoRNStack: High-quality contrastive data for better code retrieval and reranking. In The Thirteenth International Conference on Learning Representations. find
  19. Jiaming Tang, Yilong Zhao, Kan Zhu, Guangxuan Xiao, Baris Kasikci, and Song Han. 2024. QUEST: Query-aware sparsity for efficient long-context LLM inference. In Forty-first International Conference on Machine Learning.
  20. CodeGemma Team, Heri Zhao, Jeffrey Hui, Joshua Howland, Nam Nguyen, Siqi Zuo, Andrea Hu, Christopher A. Choquette-Choo, Jingyue Shen, Joe Kelley, Kshitij Bansal, Luke Vilnis, Mateo Wirth, Paul Michel, Peter Choy, Pratik Joshi, Ravin Kumar, Sarmad Hashmi, Shubham Agrawal, and 8 others. 2024. Codegemm…
  21. Yanlin Wang, Yanli Wang, Daya Guo, Jiachi Chen, Ruikai Zhang, Yuchi Ma, and Zibin Zheng. 2024. Rlcoder: Reinforcement learning for repository-level code completion. Preprint, arXiv:2407.19487. — [arXiv:2407.19487](https://arxiv.org/abs/2407.19487) find
  22. Di Wu, Wasi Uddin Ahmad, Dejiao Zhang, Murali Krishna Ramanathan, and Xiaofei Ma. 2024. Repoformer: Selective retrieval for repository-level code completion. Preprint, arXiv:2403.10059. — [arXiv:2403.10059](https://arxiv.org/abs/2403.10059) find
  23. Fengji Zhang, Bei Chen, Yue Zhang, Jacky Keung, Jin Liu, Daoguang Zan, Yi Mao, Jian-Guang Lou, and Weizhu Chen. 2023. RepoCoder: Repository-level code completion through iterative retrieval and generation. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pag… find
  24. Sheng Zhang, Yifan Ding, Shuquan Lian, Shun Song, and Hui Li. 2025. CodeRAG: Finding relevant and necessary knowledge for retrieval-augmented repository-level code completion. In Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing, pages 23278–23288, Suzhou, China. find

Updated

↑ back to top

This page in Markdown → https://md.research.elamur.ai/free/en/papers/oh-2026-late-code-chunking-code-chunking/