{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,9,30]],"date-time":"2026-09-30T16:54:44Z","timestamp":1790787284258,"version":"4.1.0"},"reference-count":45,"publisher":"Association for Computing Machinery (ACM)","issue":"FSE","license":[{"start":{"date-parts":[[2026,6,30]],"date-time":"2026-06-30T00:00:00Z","timestamp":1782777600000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/legalcode"}],"funder":[{"DOI":"10.13039\/501100001809","name":"National Natural Science Foundation of China","doi-asserted-by":"crossref","award":["92582107"],"award-info":[{"award-number":["92582107"]}],"id":[{"id":"10.13039\/501100001809","id-type":"DOI","asserted-by":"crossref"}]},{"name":"Zhejiang Provincial Natural Science Foundation of China","award":["LZ25F020003"],"award-info":[{"award-number":["LZ25F020003"]}]}],"content-domain":{"domain":[],"crossmark-restriction":false},"short-container-title":["Proc. ACM Softw. Eng."],"published-print":{"date-parts":[[2026,6,30]]},"abstract":"<jats:p>Line-level code completion aims to complete the current line in real-time as developers type. Low latency is crucial to maintaining a seamless and uninterrupted coding experience, enabling developers to remain in a productive flow. However, existing approaches face a fundamental trade-off: large language models (LLMs) provide high-quality suggestions but require expensive computational resources to ensure acceptable inference latency. In contrast, static-analysis-based methods and small language models respond quickly but often generate suboptimal completions. To fill this gap, our idea is to rely on the small model by default and only escalate the large model when necessary to achieve latency-accuracy trade-offs. Based on this idea, we propose MCCom(Model-Cascading-based code Completion), a framework that cascades a local small model with a high-performance cloud large model for code completion. Realizing effective model cascading requires answering two non-trivial questions, i.e., when to invoke the large model and how to enable effective collaboration between small and large models. For the first question, we leverage a valuable but easily overlooked signal, i.e., user actions, during code completion to accurately identify failed completions. This deferral decision allows us to invoke the large model only when necessary, reducing both latency and cloud-side computation costs. To enable effective collaboration, MCCom employs a two-stage speculative decoding strategy and an iterative retrieval mechanism that collectively accelerate and improve the quality of completions. Due to the lack of high-quality small models for code completion, we also train a lightweight model with only 121M parameters to implement MCCom. The small model achieves an average of 73.8% of the performance of the state-of-the-art 7B model. We evaluate MCCom on the RepoEval benchmark and a new benchmark, StmtEval, collected from real-world projects. Experimental results show that our approach not only reduces inference latency by up to 47.9% and cuts down LLM usage by an average of 46.3%, but also improves the exact match rate of the large model by an average of 8.9%.<\/jats:p>","DOI":"10.1145\/3797088","type":"journal-article","created":{"date-parts":[[2026,6,30]],"date-time":"2026-06-30T17:06:14Z","timestamp":1782839174000},"page":"1335-1356","source":"Crossref","is-referenced-by-count":1,"title":["Balancing Latency and Accuracy of Code Completion via Local-Cloud Model Cascading"],"prefix":"10.1145","volume":"3","author":[{"ORCID":"https:\/\/orcid.org\/0009-0003-6319-2724","authenticated-orcid":false,"given":"Hanzhen","family":"Lu","sequence":"first","affiliation":[{"name":"Zhejiang University, College of Computer Science and Technology and The State Key Laboratory of Blockchain and Data Security, Hangzhou, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0009-0006-4602-4296","authenticated-orcid":false,"given":"Lishui","family":"Fan","sequence":"additional","affiliation":[{"name":"Zhejiang University, College of Computer Science and Technology and The State Key Laboratory of Blockchain and Data Security, Hangzhou, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-0192-9992","authenticated-orcid":false,"given":"Jiachi","family":"Chen","sequence":"additional","affiliation":[{"name":"Sun Yat-sen University, Zhuhai, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-1240-9095","authenticated-orcid":false,"given":"Qiuyuan","family":"Chen","sequence":"additional","affiliation":[{"name":"Tencent Technology, Shenzhen, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0009-0007-4462-3153","authenticated-orcid":false,"given":"Zhao","family":"Wei","sequence":"additional","affiliation":[{"name":"Tencent Technology, Shenzhen, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-1981-1626","authenticated-orcid":false,"given":"Zhongxin","family":"Liu","sequence":"additional","affiliation":[{"name":"Zhejiang University, College of Computer Science and Technology and The State Key Laboratory of Blockchain and Data Security, Hangzhou, China"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"320","published-online":{"date-parts":[[2026,6,30]]},"reference":[{"key":"e_1_2_1_1_1","unstructured":"Amazon CodeWhisperer. https:\/\/aws.amazon.com\/codewhisperer\/"},{"key":"e_1_2_1_2_1","unstructured":"GitHub 2025. GitHub Copilot \u2022 Your AI Pair Programmer. GitHub. https:\/\/github.com\/features\/copilot"},{"key":"e_1_2_1_3_1","unstructured":"Tabnine AI Code Assistant | Private Personalized Protected. Tabnine. https:\/\/www.tabnine.com\/"},{"key":"e_1_2_1_4_1","unstructured":"TongYiLingMa. https:\/\/lingma.aliyun.com\/"},{"key":"e_1_2_1_5_1","unstructured":"Windsurf (Formerly Codeium) -The Most Powerful AI Code Editor. https:\/\/windsurf.com\/"},{"key":"e_1_2_1_6_1","first-page":"124","volume-title":"2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering","volume":"1","author":"Amann Sven","year":"2016","unstructured":"Sven Amann, Sebastian Proksch, Sarah Nadi, and Mira Mezini. 2016. A study of visual studio usage in practice. In 2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering, Vol. 1. IEEE, 124-134."},{"key":"e_1_2_1_7_1","volume-title":"2014 IEEE International Conference on Software Maintenance and Evolution. IEEE, 71-80","author":"Asaduzzaman Muhammad","year":"2014","unstructured":"Muhammad Asaduzzaman, Chanchal K Roy, Kevin A Schneider, and Daqing Hou. 2014. Cscc: Simple, efficient, context sensitive code completion. In 2014 IEEE International Conference on Software Maintenance and Evolution. IEEE, 71-80."},{"key":"e_1_2_1_8_1","volume-title":"Efficient training of language models to fill in the middle. arXiv preprint arXiv:2207.14255","author":"Bavarian Mohammad","year":"2022","unstructured":"Mohammad Bavarian, Heewoo Jun, Nikolas Tezak, John Schulman, Christine McLeavey, Jerry Tworek, and Mark Chen. 2022. Efficient training of language models to fill in the middle. arXiv preprint arXiv:2207.14255 (2022)."},{"key":"e_1_2_1_9_1","doi-asserted-by":"publisher","DOI":"10.1145\/1595696.1595728"},{"key":"e_1_2_1_10_1","volume-title":"2025 International Joint Conference on Neural Networks. IEEE, 1-9.","author":"Chen Boyuan","year":"2025","unstructured":"Boyuan Chen, Mingzhi Zhu, Brendan Dolan-Gavitt, Muhammad Shafique, and Siddharth Garg. 2025. Model cascading for code: A cascaded black-box multi-model framework for cost-efficient code completion with self-testing. In 2025 International Joint Conference on Neural Networks. IEEE, 1-9."},{"key":"e_1_2_1_11_1","volume-title":"FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performance. Transactions on Machine Learning Research","author":"Chen Lingjiao","year":"2024","unstructured":"Lingjiao Chen, Matei Zaharia, and James Zou. 2024. FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performance. Transactions on Machine Learning Research (2024)."},{"key":"e_1_2_1_12_1","volume-title":"Octopus v4: Graph of language models. arXiv preprint arXiv:2404.19296","author":"Chen Wei","year":"2024","unstructured":"Wei Chen and Zhiyuan Li. 2024. Octopus v4: Graph of language models. arXiv preprint arXiv:2404.19296 (2024)."},{"key":"e_1_2_1_13_1","doi-asserted-by":"crossref","first-page":"86226","DOI":"10.52202\/079017-2738","article-title":"Cascade speculative drafting for even faster llm inference","volume":"37","author":"Chen Ziyi","year":"2024","unstructured":"Ziyi Chen, Xiaocong Yang, Jiacheng Lin, Chenkai Sun, Kevin Chang, and Jie Huang. 2024. Cascade speculative drafting for even faster llm inference. Advances in Neural Information Processing Systems 37 (2024), 86226-86242.","journal-title":"Advances in Neural Information Processing Systems"},{"key":"e_1_2_1_14_1","volume-title":"Enhancing project-specific code completion by inferring internal api information","author":"Deng Le","year":"2025","unstructured":"Le Deng, Xiaoxue Ren, Chao Ni, Ming Liang, David Lo, and Zhongxin Liu. 2025. Enhancing project-specific code completion by inferring internal api information. IEEE Transactions on Software Engineering (2025)."},{"key":"e_1_2_1_15_1","volume-title":"Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation. 3433-3445","author":"Ding Yangruibo","year":"2024","unstructured":"Yangruibo Ding, Zijian Wang, Wasi Ahmad, Murali Krishna Ramanathan, Ramesh Nallapati, Parminder Bhatia, Dan Roth, and Bing Xiang. 2024. Cocomic: Code completion by jointly modeling in-file and cross-file context. In Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation. 3433-3445."},{"key":"e_1_2_1_16_1","volume-title":"De-hallucinator: Iterative grounding for llm-based code completion. arXiv preprint arXiv:2401.01701","author":"Eghbali Aryaz","year":"2024","unstructured":"Aryaz Eghbali and Michael Pradel. 2024. De-hallucinator: Iterative grounding for llm-based code completion. arXiv preprint arXiv:2401.01701 (2024)."},{"key":"e_1_2_1_17_1","volume-title":"GraphRouter: A Graph-based Router for LLM Selections. In The Thirteenth International Conference on Learning Representations.","author":"Feng Tao","year":"2025","unstructured":"Tao Feng, Yanzhen Shen, and Jiaxuan You. 2025. GraphRouter: A Graph-based Router for LLM Selections. In The Thirteenth International Conference on Learning Representations."},{"key":"e_1_2_1_18_1","volume-title":"Facts and fallacies of software engineering","author":"Glass Robert L","unstructured":"Robert L Glass. 2002. Facts and fallacies of software engineering. Addison-Wesley Professional."},{"key":"e_1_2_1_19_1","unstructured":"Daya Guo Qihao Zhu Dejian Yang Zhenda Xie Kai Dong Wentao Zhang Guanting Chen Xiao Bi Yu Wu YK Li et al. 2024. DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence. arXiv preprint arXiv:2401.14196 (2024)."},{"key":"e_1_2_1_20_1","doi-asserted-by":"publisher","DOI":"10.1145\/1808920.1808926"},{"key":"e_1_2_1_21_1","volume-title":"Minicpm: Unveiling the potential of small language models with scalable training strategies. arXiv preprint arXiv:2404.06395","author":"Hu Shengding","year":"2024","unstructured":"Shengding Hu, Yuge Tu, Xu Han, Chaoqun He, Ganqu Cui, Xiang Long, Zhi Zheng, Yewei Fang, Yuxiang Huang, Weilin Zhao, et al. 2024. Minicpm: Unveiling the potential of small language models with scalable training strategies. arXiv preprint arXiv:2404.06395 (2024)."},{"key":"e_1_2_1_22_1","volume-title":"Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics. 33167-33193","author":"Huang Siming","year":"2025","unstructured":"Siming Huang, Tianhao Cheng, Jason Klein Liu, Weidi Xu, Jiaran Hao, Liuyihan Song, Yang Xu, Jian Yang, Jiaheng Liu, Chenchen Zhang, et al. 2025. Opencoder: The open cookbook for top-tier code large language models. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics. 33167-33193."},{"key":"e_1_2_1_23_1","unstructured":"Binyuan Hui Jian Yang Zeyu Cui Jiaxi Yang Dayiheng Liu Lei Zhang Tianyu Liu Jiajun Zhang Bowen Yu Keming Lu et al. 2024. Qwen2. 5-coder technical report. arXiv preprint arXiv:2409.12186 (2024)."},{"key":"e_1_2_1_24_1","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE-SEIP66354.2025.00025"},{"key":"e_1_2_1_25_1","first-page":"707","article-title":"Binary codes capable of correcting deletions, insertions, and reversals. In Soviet physics doklady, Vol. 10","author":"Levenshtein Vladimir I","year":"1966","unstructured":"Vladimir I Levenshtein et al. 1966. Binary codes capable of correcting deletions, insertions, and reversals. In Soviet physics doklady, Vol. 10. Soviet Union, 707-710.","journal-title":"Soviet Union"},{"key":"e_1_2_1_26_1","volume-title":"International Conference on Machine Learning. PMLR","author":"Leviathan Yaniv","year":"2023","unstructured":"Yaniv Leviathan, Matan Kalman, and Yossi Matias. 2023. Fast inference from transformers via speculative decoding. In International Conference on Machine Learning. PMLR, 19274-19286."},{"key":"e_1_2_1_27_1","volume-title":"Graphcoder: Enhancing repository-level code completion via code context graph-based retrieval and language model. arXiv preprint arXiv:2406.07003","author":"Liu Wei","year":"2024","unstructured":"Wei Liu, Ailun Yu, Daoguang Zan, Bo Shen, Wei Zhang, Haiyan Zhao, Zhi Jin, and Qianxiang Wang. 2024. Graphcoder: Enhancing repository-level code completion via code context graph-based retrieval and language model. arXiv preprint arXiv:2406.07003 (2024)."},{"key":"e_1_2_1_28_1","volume-title":"Federico Cassano, Joel Lamy-Poirier, Nouamane Tazi, Ao Tang, Dmytro Pykhtar, Jiawei Liu, Yuxiang Wei, et al.","author":"Lozhkov Anton","year":"2024","unstructured":"Anton Lozhkov, Raymond Li, Loubna Ben Allal, Federico Cassano, Joel Lamy-Poirier, Nouamane Tazi, Ao Tang, Dmytro Pykhtar, Jiawei Liu, Yuxiang Wei, et al. 2024. Starcoder 2 and the stack v2: The next generation. arXiv preprint arXiv:2402.19173 (2024)."},{"key":"e_1_2_1_29_1","volume-title":"How are Java software developers using the Eclipse IDE? IEEE software 23, 4","author":"Murphy Gail C","year":"2006","unstructured":"Gail C Murphy, Mik Kersten, and Leah Findlater. 2006. How are Java software developers using the Eclipse IDE? IEEE software 23, 4 (2006), 76-83."},{"key":"e_1_2_1_30_1","volume-title":"Tien N Nguyen, and Nghi DQ Bui.","author":"Phan Huy Nhat","year":"2024","unstructured":"Huy Nhat Phan, Hoang Nhat Phan, Tien N Nguyen, and Nghi DQ Bui. 2024. Repohyper: Better context retrieval is all you need for repository-level code completion. CoRR (2024)."},{"key":"e_1_2_1_31_1","volume-title":"Vendi-rag: Adaptively trading-off diversity and quality significantly improves retrieval augmented generation with llms. arXiv preprint arXiv:2502.11228","author":"Rezaei Mohammad Reza","year":"2025","unstructured":"Mohammad Reza Rezaei and Adji Bousso Dieng. 2025. Vendi-rag: Adaptively trading-off diversity and quality significantly improves retrieval augmented generation with llms. arXiv preprint arXiv:2502.11228 (2025)."},{"key":"e_1_2_1_32_1","volume-title":"Yossi Adi, Jingyu Liu, Romain Sauvestre, Tal Remez, et al.","author":"Roziere Baptiste","year":"2023","unstructured":"Baptiste Roziere, Jonas Gehring, Fabian Gloeckle, Sten Sootla, Itai Gat, Xiaoqing Ellen Tan, Yossi Adi, Jingyu Liu, Romain Sauvestre, Tal Remez, et al. 2023. Code llama: Open foundation models for code. arXiv preprint arXiv:2308.12950 (2023)."},{"key":"e_1_2_1_33_1","volume-title":"Proceedings of the Eighteenth ACM International Conference on Web Search and Data Mining. 801-810","author":"Sagtani Hitesh","year":"2025","unstructured":"Hitesh Sagtani, Rishabh Mehrotra, and Beyang Liu. 2025. Improving fim code completions via context & curriculum based learning. In Proceedings of the Eighteenth ACM International Conference on Web Search and Data Mining. 801-810."},{"key":"e_1_2_1_34_1","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE-SEIP66354.2025.00055"},{"key":"e_1_2_1_35_1","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE-NIER66352.2025.00020"},{"key":"e_1_2_1_36_1","volume-title":"Large language model routing with benchmark datasets. arXiv preprint arXiv:2309.15789","author":"Shnitzer Tal","year":"2023","unstructured":"Tal Shnitzer, Anthony Ou, M\u00edrian Silva, Kate Soule, Yuekai Sun, Justin Solomon, Neil Thompson, and Mikhail Yurochkin. 2023. Large language model routing with benchmark datasets. arXiv preprint arXiv:2309.15789 (2023)."},{"key":"e_1_2_1_37_1","unstructured":"sombanerjee. 2025. GitHub Copilot Chat Explained: The Life of a Prompt. All things Azure. https:\/\/devblogs.microsoft. com\/all-things-azure\/github-copilot-chat-explained-the-life-of-a-prompt\/"},{"key":"e_1_2_1_38_1","volume-title":"GPU Retail Sales June '25 Amazon US. https:\/\/x.com\/TechEpiphanyYT\/status\/ 1941064015016341736?s=20","year":"2025","unstructured":"TechEpiphany. 2025. GPU Retail Sales June '25 Amazon US. https:\/\/x.com\/TechEpiphanyYT\/status\/ 1941064015016341736?s=20."},{"key":"e_1_2_1_39_1","volume-title":"Practitioners' expectations on code completion. arXiv preprint arXiv:2301.03846","author":"Wang Chaozheng","year":"2023","unstructured":"Chaozheng Wang, Junhao Hu, Cuiyun Gao, Yu Jin, Tao Xie, Hailiang Huang, Zhenyu Lei, and Yuetang Deng. 2023. Practitioners' expectations on code completion. arXiv preprint arXiv:2301.03846 (2023)."},{"key":"e_1_2_1_40_1","volume-title":"RLCoder: Reinforcement Learning for Repository-Level Code Completion. In 2025 IEEE\/ACM 47th International Conference on Software Engineering. IEEE Computer Society, 165-177","author":"Wang Yanlin","year":"2024","unstructured":"Yanlin Wang, Yanli Wang, Daya Guo, Jiachi Chen, Ruikai Zhang, Yuchi Ma, and Zibin Zheng. 2024. RLCoder: Reinforcement Learning for Repository-Level Code Completion. In 2025 IEEE\/ACM 47th International Conference on Software Engineering. IEEE Computer Society, 165-177."},{"key":"e_1_2_1_41_1","volume-title":"Proceedings of the 41st International Conference on Machine Learning. 53270-53290","author":"Wu Di","year":"2024","unstructured":"Di Wu, Wasi Uddin Ahmad, Dejiao Zhang, Murali Krishna Ramanathan, and Xiaofei Ma. 2024. REPOFORMER: selective retrieval for repository-level code completion. In Proceedings of the 41st International Conference on Machine Learning. 53270-53290."},{"key":"e_1_2_1_42_1","volume-title":"Enhancing Domain-Specific Code Completion via Collaborative Inference with Large and Small Language Models. ACM Transactions on Software Engineering and Methodology","author":"Yu Jingrong","year":"2025","unstructured":"Jingrong Yu, Zhipeng Gao, Lingfeng Bao, and Zhongxin Liu. 2025. Enhancing Domain-Specific Code Completion via Collaborative Inference with Large and Small Language Models. ACM Transactions on Software Engineering and Methodology (2025)."},{"key":"e_1_2_1_43_1","doi-asserted-by":"publisher","DOI":"10.18653\/v1\/2023.emnlp-main.151"},{"key":"e_1_2_1_44_1","volume-title":"Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing. 23289-23299","author":"Zhang Sheng","year":"2025","unstructured":"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. 23289-23299."},{"key":"e_1_2_1_45_1","volume-title":"Ouroboros: Speculative decoding with large model enhanced drafting. arXiv preprint arXiv:2402.13720","author":"Zhao Weilin","year":"2024","unstructured":"Weilin Zhao, Yuxiang Huang, Xu Han, Chaojun Xiao, Zhiyuan Liu, and Maosong Sun. 2024. Ouroboros: Speculative decoding with large model enhanced drafting. arXiv preprint arXiv:2402.13720 (2024)."}],"container-title":["Proceedings of the ACM on Software Engineering"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/3797088","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2026,6,30]],"date-time":"2026-06-30T18:00:51Z","timestamp":1782842451000},"score":1,"resource":{"primary":{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3797088"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2026,6,30]]},"references-count":45,"journal-issue":{"issue":"FSE","published-print":{"date-parts":[[2026,6,30]]}},"alternative-id":["10.1145\/3797088"],"URL":"https:\/\/doi.org\/10.1145\/3797088","relation":{},"ISSN":["2994-970X"],"issn-type":[{"value":"2994-970X","type":"electronic"}],"subject":[],"published":{"date-parts":[[2026,6,30]]}}}