CoCoMIC: Code Completion by Jointly Modeling In-file and Cross-file Context
By Yangruibo Ding, Zijian Wang, Wasi Uddin Ahmad, Murali Krishna Ramanathan, Ramesh Nallapati, Parminder Bhatia, Dan Roth, Bing Xiang. 2022
111 citations recorded by the source corpus.
While pre-trained language models (LM) for code have achieved great success in code completion, they generate code conditioned only on the contents within the file, i.e., in-file context, but ignore the rich semantics in other files within the same project, i.e., project-level cross-file context, a critical source of information that is especially useful in modern modular software development. Such overlooking constrains code LMs’ capacity in code completion, leading to unexpected behaviors such as generating hallucinated class member functions or function calls with unexpected arguments. In this work, we propose CoCoMIC, a novel framework that jointly learns the in-file and cross-file context on top of code LMs. To empower CoCoMIC, we develop CCFinder, a static-analysis-based tool that locates and retrieves the most relevant project-level cross-file context for code completion. CoCoMIC successfully improves the existing code LM with a 33.94% relative increase in exact match and 28.69% in identifier matching for code completion when the cross-file context is provided. Finally, we perform a series of ablation studies and share valuable insights for future research on integrating cross-file context into code LMs.
Subfields: Computer Networks and Communications, Information Systems, Code Generation & Program Synthesis
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Computer Networks and Communications
- Armando Solar-Lezama
- Koushik Sen
- Anima Anandkumar
- Ion Stoica
- Julian McAuley
- Jian-Guang Lou
- Scott Shenker
- Mosharaf Chowdhury
In Information Systems
- Armando Solar-Lezama
- Bei Chen
- Koushik Sen
- Naman Jain
- Tianjun Zhang
- Anima Anandkumar
- Weizhu Chen
- Tianyang Liu
In Code Generation & Program Synthesis
- Armando Solar-Lezama
- Koushik Sen
- Tianyang Liu
- Kaiyu Yang
- Julian McAuley
- Jian-Guang Lou
- Canwen Xu
- Rishabh Singh
Citations in the corpus
- LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Code (2024, methodology): “…engineering tasks, such as JuICe (Agashe et al., 2019), APIBench (Patil et al., 2023), RepoBench (Liu et al., 2023c), ODEX (Wang et al., 2022b), SWE-Bench (Jimenez et al., 2023), GoogleCodeRepo (Shrivastava et al., 2023), RepoEval (Zhang et al., 2023a), and Cocomic-Data (Ding et al., 2022).”
- RepoBench: Benchmarking Repository-Level Code Auto-Completion Systems (2023, methodology): “Different from the CoCoMIC data, our benchmark extends beyond code completion and includes evaluation of retrieval and pipeline construction, thus can better capture the complexity of such cross-file code completion systems.”
- Retrieval-Augmented Generation for AI-Generated Content: A Survey (2024, unknown): “It filters out lower-quality data to maintain a high standard of information mapping, offering a variety of retrieval system options like TF-IDF, DPR, RAG, and BLINK + flair to support evidence-based predictions or citations according to task requirements.”
- A Survey on Large Language Models for Code Generation (2024, unknown): “As an evaluation framework, this benchmark comprises 2,294 tasks from Github issues and their re-lated pull requests across 12 well-known Python repositories.”
- RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generation (2023, methodology): “Meanwhile, studies (Hellendoorn and Devanbu, 2017; Svyatkovskiy et al., 2020; Ding et al., 2022) tuning language models on labeled data excel in their respective evaluation scenarios but face challenges generalizing to unseen repositories without retraining.”
- LeanDojo: Theorem Proving with Retrieval-Augmented Language Models (2023, methodology): “In addition, there have been many retrieval-augmented methods for code generation [82– 88].”
- CoRet: Improved Retriever for Code Editing (2025, unknown): “The repository-level retrieval benchmarks such as Re-poEval (Zhang et al., 2023a), Repobench (Liu et al., 2024), CodeRAG-Bench (Wang et al., 2024), EvoCodeBench (Li et al., 2024a) are typically used for code completion tasks where they do not have natural language queries or the retrieval is only…”