{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,10,2]],"date-time":"2026-10-02T10:29:11Z","timestamp":1790936951385,"version":"4.1.0"},"reference-count":59,"publisher":"Association for Computing Machinery (ACM)","issue":"7","funder":[{"DOI":"10.13039\/501100001809","name":"National Natural Science Foundation of China","doi-asserted-by":"crossref","award":["62202420"],"award-info":[{"award-number":["62202420"]}],"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"]}]},{"DOI":"10.13039\/501100001809","name":"National Natural Science Foundation of China","doi-asserted-by":"crossref","award":["62372398"],"award-info":[{"award-number":["62372398"]}],"id":[{"id":"10.13039\/501100001809","id-type":"DOI","asserted-by":"crossref"}]}],"content-domain":{"domain":["dl.acm.org"],"crossmark-restriction":true},"short-container-title":["ACM Trans. Softw. Eng. Methodol."],"published-print":{"date-parts":[[2026,7,31]]},"abstract":"<jats:p>Large language model-based code completion has demonstrated excellent performance, but still encounters challenges in capturing domain-specific knowledge for more precise completion within specific domains, i.e., domain-specific code completion. Prior work has studied fine-tuning techniques or retrieval-augmented techniques for this task. Nevertheless, it requires a lot of computational resources to fine-tune large language models (LLMs), and the cost can increase quadratically with the model size. Retrieval-augmented techniques face difficulties in accurately and adaptively retrieving relevant information. Moreover, considering that code completion tools work in real time, how to utilize large language models more efficiently poses challenges.<\/jats:p>\n                  <jats:p>To tackle these challenges, in this article, we first conduct preliminary experiments and observe that the code completion results of a small model fine-tuned within a specific domain complement those of a large model. Building on this insight, we propose a collaborative framework to effectively combine large and small models for better domain-specific code completion. Specifically, we fine-tune a small code model instead of a large model with the PEFT method, reducing the overhead of fine-tuning. We utilize a well-designed classifier to facilitate the adaptive combination of distinct completion results. The classifier relies on features in various dimensions, such as the similarity between the completed code and the context, and is used to adaptively determine how to combine the tokens predicted by the large and small models for better code completion. Evaluation results show that our approach achieves an average improvement in the exact match of 7.42% and 4.67% over the state-of-the-art baselines in the intra-project and intra-domain code completion scenarios, respectively. Furthermore, compared to the state-of-the-art domain-specific code completion approach FT2Ra, the inference speed of our approach is 1.40 times faster, and the average space requirement drops from 25.98G to 13.69G. These advantages make our approach much more accessible and efficient.<\/jats:p>","DOI":"10.1145\/3770748","type":"journal-article","created":{"date-parts":[[2025,10,3]],"date-time":"2025-10-03T16:44:32Z","timestamp":1759509872000},"page":"1-26","update-policy":"https:\/\/doi.org\/10.1145\/crossmark-policy","source":"Crossref","is-referenced-by-count":1,"title":["Enhancing Domain-Specific Code Completion via Collaborative Inference with Large and Small Language Models"],"prefix":"10.1145","volume":"35","author":[{"ORCID":"https:\/\/orcid.org\/0009-0004-2653-1739","authenticated-orcid":false,"given":"Jingrong","family":"Yu","sequence":"first","affiliation":[{"name":"The State Key Laboratory of Blockchain and Data Security, Zhejiang University, Hangzhou, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0003-3030-9917","authenticated-orcid":false,"given":"Zhipeng","family":"Gao","sequence":"additional","affiliation":[{"name":"Zhejiang University, Hangzhou, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0003-1846-0921","authenticated-orcid":false,"given":"Lingfeng","family":"Bao","sequence":"additional","affiliation":[{"name":"The State Key Laboratory of Blockchain and Data Security, Zhejiang University, Hangzhou, 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":"The State Key Laboratory of Blockchain and Data Security, Zhejiang University, Hangzhou, China"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"320","published-online":{"date-parts":[[2026,6,17]]},"reference":[{"key":"e_1_3_2_2_2","unstructured":"Deepseek. [n.\u2009d.]. Deepseek-coder-1.3b-Base-GPTQ. Retrieved from https:\/\/huggingface.co\/TheBloke\/deepseek-coder-1.3b-base-GPTQ\/tree\/main"},{"key":"e_1_3_2_3_2","unstructured":"GitHub. [n.\u2009d.]. GitHub REST API. Retrieved from https:\/\/docs.github.com\/en\/rest?apiVersion=2022-11-28"},{"key":"e_1_3_2_4_2","doi-asserted-by":"publisher","DOI":"10.1109\/MSR.2013.6624029"},{"key":"e_1_3_2_5_2","doi-asserted-by":"publisher","DOI":"10.69478\/JITC2024v6n2a11"},{"key":"e_1_3_2_6_2","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE48619.2023.00198"},{"key":"e_1_3_2_7_2","unstructured":"Boyuan Chen Mingzhi Zhu Brendan Dolan-Gavitt Muhammad Shafique and Siddharth Garg. 2024. Model cascading for code: Reducing inference costs with model cascading for LLM based code generation. arXiv:2405.15842. Retrieved from http:\/\/arxiv.org\/abs\/2405.15842"},{"key":"e_1_3_2_8_2","unstructured":"Charlie Chen Sebastian Borgeaud Geoffrey Irving Jean-Baptiste Lespiau Laurent Sifre and John Jumper. 2023. Accelerating large language model decoding with speculative sampling. arXiv:2302.01318. Retrieved from http:\/\/arxiv.org\/abs\/2302.01318"},{"key":"e_1_3_2_9_2","unstructured":"Meng Chen Hongyu Zhang Chengcheng Wan Zhao Wei Yong Xu Juhong Wang and Xiaodong Gu. 2024. On the effectiveness of large language models in domain-specific code generation. arXiv:2312.01639. Retrieved from https:\/\/arxiv.org\/abs\/2312.01639"},{"key":"e_1_3_2_10_2","doi-asserted-by":"crossref","unstructured":"Colin B. Clement Shuai Lu Xiaoyu Liu Michele Tufano Dawn Drain Nan Duan Neel Sundaresan and Alexey Svyatkovskiy. 2021. Long-range modeling of source code files with eWASH: Extended window access by syntax hierarchy. arXiv:2109.08780. Retrieved from http:\/\/arxiv.org\/abs\/2109.08780","DOI":"10.18653\/v1\/2021.emnlp-main.387"},{"key":"e_1_3_2_11_2","doi-asserted-by":"publisher","DOI":"10.1109\/TSE.2025.3592823"},{"key":"e_1_3_2_12_2","unstructured":"Yangruibo Ding Zijian Wang Wasi Uddin Ahmad Murali Krishna Ramanathan Ramesh Nallapati Parminder Bhatia Dan Roth and Bing Xiang. 2023. CoCoMIC: Code completion by jointly modeling in-file and cross-file context. arXiv:2212.10007. Retrieved from https:\/\/arxiv.org\/abs\/2212.10007"},{"key":"e_1_3_2_13_2","unstructured":"Aryaz Eghbali and Michael Pradel. 2024. De-hallucinator: Mitigating LLM hallucinations in code generation tasks via iterative grounding. arXiv:2401.01701. Retrieved from https:\/\/arxiv.org\/abs\/2401.01701"},{"key":"e_1_3_2_14_2","unstructured":"Tao Ge Heming Xia Xin Sun Si-Qing Chen and Furu Wei. 2022. Lossless acceleration for seq2seq generation with aggressive decoding. arXiv:2205.10350. Retrieved from http:\/\/arxiv.org\/abs\/2205.10350"},{"key":"e_1_3_2_15_2","unstructured":"Daya Guo Alexey Svyatkovskiy Jian Yin Nan Duan Marc Brockschmidt and Miltiadis Allamanis. 2022. Learning to complete code with sketches. arXiv:2106.10158. Retrieved from http:\/\/arxiv.org\/abs\/2106.10158"},{"key":"e_1_3_2_16_2","unstructured":"Daya Guo Qihao Zhu Dejian Yang Zhenda Xie Kai Dong Wentao Zhang Guanting Chen Xiao Bi Y. Wu Y. K. Li et al. 2024. DeepSeek-coder: When the large language model meets programming\u2014The rise of code intelligence. arXiv:2401.14196. Retrieved from https:\/\/arxiv.org\/abs\/2401.14196"},{"key":"e_1_3_2_17_2","doi-asserted-by":"publisher","unstructured":"Qi Guo Xiaohong Li Xiaofei Xie Shangqing Liu Ze Tang Ruitao Feng Junjie Wang Jidong Ge and Lei Bu. 2024. FT2Ra: A fine-tuning-inspired approach to retrieval-augmented code completion. arXiv:2404.01554. Retrieved from 10.1145\/3650212.3652130","DOI":"10.1145\/3650212.3652130"},{"key":"e_1_3_2_18_2","unstructured":"Kelvin Guu Kenton Lee Zora Tung Panupong Pasupat and Ming-Wei Chang. 2020. REALM: Retrieval-augmented language model pre-training. arXiv:2002.08909. Retrieved from https:\/\/arxiv.org\/abs\/2002.08909"},{"key":"e_1_3_2_19_2","unstructured":"Zhenyu He Zexuan Zhong Tianle Cai Jason D. Lee and Di He. 2023. REST: Retrieval-based speculative decoding. arXiv:2311.08252. Retrieved from http:\/\/arxiv.org\/abs\/2311.08252"},{"key":"e_1_3_2_20_2","unstructured":"Edward J. Hu Yelong Shen Phillip Wallis Zeyuan Allen-Zhu Yuanzhi Li Shean Wang Lu Wang and Weizhu Chen. 2021. LoRA: Low-rank adaptation of large language models. arXiv:2106.09685. Retrieved from http:\/\/arxiv.org\/abs\/2106.09685"},{"key":"e_1_3_2_21_2","doi-asserted-by":"publisher","DOI":"10.1145\/3510003.3510172"},{"key":"e_1_3_2_22_2","doi-asserted-by":"publisher","DOI":"10.1111\/j.1469-8137.1912.tb05611.x"},{"key":"e_1_3_2_23_2","unstructured":"Juyong Jiang Fan Wang Jiasi Shen Sungju Kim and Sunghun Kim. 2024. A survey on large language models for code generation. arXiv:2406.00515. Retrieved from http:\/\/arxiv.org\/abs\/2406.00515"},{"key":"e_1_3_2_24_2","unstructured":"Urvashi Khandelwal Omer Levy Dan Jurafsky Luke Zettlemoyer and Mike Lewis. 2020. Generalization through memorization: Nearest neighbor language models. arXiv:1911.00172. Retrieved from https:\/\/arxiv.org\/abs\/1911.00172"},{"key":"e_1_3_2_25_2","unstructured":"Sehoon Kim Karttikeya Mangalam Suhong Moon Jitendra Malik Michael W. Mahoney Amir Gholami and Kurt Keutzer. 2023. 2023. Speculative decoding with big little decoder. arXiv:2302.07863. Retrieved from http:\/\/arxiv.org\/abs\/2302.07863"},{"key":"e_1_3_2_26_2","unstructured":"Yaniv Leviathan Matan Kalman and Yossi Matias. 2023. Fast inference from transformers via speculative decoding. arXiv:2211.17192. Retrieved from http:\/\/arxiv.org\/abs\/2211.17192"},{"key":"e_1_3_2_27_2","unstructured":"Raymond Li Loubna Ben Allal Yangtian Zi Niklas Muennighoff Denis Kocetkov Chenghao Mou Marc Marone Christopher Akiki Jia Li Jenny Chim et al. 2023. StarCoder: May the source be with you!. arXiv: 2305.06161v2. Retrieved from https:\/\/arxiv.org\/abs\/2305.06161v2"},{"key":"e_1_3_2_28_2","unstructured":"Chengbo Liu and Yong Zhu. 2024. SDSAT: Accelerating LLM inference through speculative decoding with semantic adaptive tokens. arXiv:2403.18647. Retrieved from http:\/\/arxiv.org\/abs\/2403.18647"},{"key":"e_1_3_2_29_2","doi-asserted-by":"publisher","DOI":"10.1109\/ASE56229.2023.00125"},{"key":"e_1_3_2_30_2","doi-asserted-by":"publisher","DOI":"10.1109\/ASE56229.2023.00159"},{"key":"e_1_3_2_31_2","unstructured":"Tianyang Liu Canwen Xu and Julian McAuley. 2023. RepoBench: Benchmarking repository-level code auto-completion systems. arXiv:2306.03091. Retrieved from http:\/\/arxiv.org\/abs\/2306.03091"},{"key":"e_1_3_2_32_2","doi-asserted-by":"crossref","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:2406.07003. Retrieved from http:\/\/arxiv.org\/abs\/2406.07003","DOI":"10.1145\/3691620.3695054"},{"key":"e_1_3_2_33_2","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:2402.19173. Retrieved from http:\/\/arxiv.org\/abs\/2402.19173"},{"key":"e_1_3_2_34_2","unstructured":"Shuai Lu Nan Duan Hojae Han Daya Guo Seung Won Hwang and Alexey Svyatkovskiy. 2022. ReACC: A retrieval-augmented code completion framework. arXiv:2203.07722. Retrieved from https:\/\/arxiv.org\/abs\/2203.07722"},{"key":"e_1_3_2_35_2","unstructured":"Shuai Lu Daya Guo Shuo Ren Junjie Huang Alexey Svyatkovskiy Ambrosio Blanco Colin Clement Dawn Drain Daxin Jiang et al. 2021. CodeXGLUE: A machine learning benchmark dataset for code understanding and generation. arXiv:2102.04664. Retrieved from http:\/\/arxiv.org\/abs\/2102.04664"},{"key":"e_1_3_2_36_2","unstructured":"Sourab Mangrulkar Sylvain Gugger Lysandre Debut Younes Belkada Sayak Paul and Benjamin Bossan. 2022. PEFT: State-of-the-art Parameter-Efficient Fine-Tuning methods. Retrieved from https:\/\/github.com\/huggingface\/peft"},{"key":"e_1_3_2_37_2","doi-asserted-by":"publisher","DOI":"10.1145\/3551349.3559544"},{"key":"e_1_3_2_38_2","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE48619.2023.00180"},{"key":"e_1_3_2_39_2","doi-asserted-by":"publisher","DOI":"10.1561\/1500000019"},{"key":"e_1_3_2_40_2","unstructured":"Baptiste Rozi\u00e8re Jonas Gehring Fabian Gloeckle Sten Sootla Itai Gat Xiaoqing Ellen Tan Yossi Adi Jingyu Liu Romain Sauvestre Tal Remez et al. 2024. Code Llama: Open foundation models for code. arXiv:2308.12950. Retrieved from https:\/\/arxiv.org\/abs\/2308.12950"},{"key":"e_1_3_2_41_2","doi-asserted-by":"crossref","unstructured":"Sijie Shen Xiang Zhu Yihong Dong Qizhi Guo Yankun Zhen and Ge Li. 2022. Incorporating domain knowledge through task augmentation for front-end JavaScript code generation. arXiv:2208.10091. Retrieved from https:\/\/arxiv.org\/abs\/2208.10091","DOI":"10.1145\/3540250.3558965"},{"key":"e_1_3_2_42_2","unstructured":"Ensheng Shi Yanlin Wang Hongyu Zhang Lun Du Shi Han Dongmei Zhang and Hongbin Sun. 2023. Towards efficient fine-tuning of pre-trained code models: An experimental study and beyond. arXiv:2304.05216. Retrieved from http:\/\/arxiv.org\/abs\/2304.05216"},{"key":"e_1_3_2_43_2","unstructured":"Disha Shrivastava Denis Kocetkov Harm de Vries Dzmitry Bahdanau and Torsten Scholak. 2023. RepoFusion: Training code models to understand your repository. arXiv:2306.10998. Retrieved from https:\/\/arxiv.org\/abs\/2306.10998"},{"key":"e_1_3_2_44_2","unstructured":"Disha Shrivastava Hugo Larochelle and Daniel Tarlow. 2023. Repository-level prompt generation for large language models of code. arXiv:2206.12839. Retrieved from http:\/\/arxiv.org\/abs\/2206.12839"},{"key":"e_1_3_2_45_2","doi-asserted-by":"crossref","unstructured":"Alexey Svyatkovskiy Shao Kun Deng Shengyu Fu and Neel Sundaresan. 2020. IntelliCode compose: Code generation using transformer. arXiv:2005.08025. Retrieved from http:\/\/arxiv.org\/abs\/2005.08025","DOI":"10.1145\/3368089.3417058"},{"key":"e_1_3_2_46_2","doi-asserted-by":"crossref","unstructured":"Ze Tang Jidong Ge Shangqing Liu Tingwei Zhu Tongtong Xu Liguo Huang and Bin Luo. 2023. Domain adaptive code completion via language models and decoupled domain databases. arXiv:2308.09313. Retrieved from https:\/\/arxiv.org\/abs\/2308.09313","DOI":"10.1109\/ASE56229.2023.00076"},{"key":"e_1_3_2_47_2","doi-asserted-by":"publisher","DOI":"10.1007\/s10515-023-00376-y"},{"key":"e_1_3_2_48_2","unstructured":"Heming Xia Tao Ge Peiyi Wang Si-Qing Chen Furu Wei and Zhifang Sui. 2023. 2023. Speculative decoding: Exploiting speculative execution for accelerating seq2seq generation. arXiv:2203.16487. Retrieved from http:\/\/arxiv.org\/abs\/2203.16487"},{"key":"e_1_3_2_49_2","unstructured":"Heming Xia Zhe Yang Qingxiu Dong Peiyi Wang Yongqi Li Tao Ge Tianyu Liu Wenjie Li and Zhifang Sui. 2024. June. 2024. Unlocking efficiency in large language model inference: a comprehensive survey of speculative decoding. arXiv:2401.07851. Retrieved from http:\/\/arxiv.org\/abs\/2401.07851"},{"key":"e_1_3_2_50_2","unstructured":"Sen Yang Shujian Huang Xinyu Dai and Jiajun Chen. 2024. Multi-candidate speculative decoding. arXiv:2401.06706. Retrieved from https:\/\/arxiv.org\/abs\/2401.06706"},{"key":"e_1_3_2_51_2","doi-asserted-by":"publisher","DOI":"10.1145\/3533767.3534390"},{"key":"e_1_3_2_52_2","doi-asserted-by":"crossref","unstructured":"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. arXiv:2303.12570. Retrieved from http:\/\/arxiv.org\/abs\/2303.12570","DOI":"10.18653\/v1\/2023.emnlp-main.151"},{"key":"e_1_3_2_53_2","unstructured":"Jun Zhang Jue Wang Huan Li Lidan Shou Ke Chen Gang Chen and Sharad Mehrotra. 2023. Draft & verify: Lossless large language model acceleration via self-speculative decoding. arXiv:2309.08168. Retrieved from http:\/\/arxiv.org\/abs\/2309.08168"},{"key":"e_1_3_2_54_2","unstructured":"Kaiyan Zhang Jianyu Wang Ning Ding Biqing Qi Ermo Hua Xingtai Lv and Bowen Zhou. 2024. Fast and slow generating: an empirical study on large and small language models collaborative decoding. arXiv:2406.12295. Retrieved from http:\/\/arxiv.org\/abs\/2406.12295"},{"issue":"1","key":"e_1_3_2_55_2","first-page":"295","article-title":"LLM-Cloud complete: Leveraging cloud computing for efficient large language model-based code completion","volume":"5","author":"Zhang Mingxuan","year":"2024","unstructured":"Mingxuan Zhang, Bo Yuan, Hanzhe Li, and Kangming Xu. 2024. LLM-Cloud complete: Leveraging cloud computing for efficient large language model-based code completion. Journal of Artificial Intelligence General Science 5, 1 (2024), 295\u2013326.","journal-title":"Journal of Artificial Intelligence General Science"},{"key":"e_1_3_2_56_2","unstructured":"Wenrui Zhang Tiehang Fu Ting Yuan Ge Zhang Dong Chen and Jie Wang. 2024. A lightweight framework for adaptive retrieval in code completion with critique model. arXiv:2406.10263. Retrieved from http:\/\/arxiv.org\/abs\/2406.10263"},{"key":"e_1_3_2_57_2","doi-asserted-by":"crossref","unstructured":"Qinkai Zheng Xiao Xia Xu Zou Yuxiao Dong Shan Wang Yufei Xue Zihan Wang Lei Shen Andi Wang Yang Li et al. 2023. CodeGeeX: A pre-trained model for code generation with multilingual evaluations on HumanEval-X. arXiv:2303.17568. Retrieved from https:\/\/arxiv.org\/abs\/2303.17568","DOI":"10.1145\/3580305.3599790"},{"key":"e_1_3_2_58_2","doi-asserted-by":"publisher","DOI":"10.1016\/j.ipm.2018.11.008"},{"key":"e_1_3_2_59_2","doi-asserted-by":"publisher","DOI":"10.1145\/3643916.3644421"},{"key":"e_1_3_2_60_2","doi-asserted-by":"publisher","DOI":"10.1145\/3540250.3558959"}],"container-title":["ACM Transactions on Software Engineering and Methodology"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/3770748","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2026,6,17]],"date-time":"2026-06-17T14:52:04Z","timestamp":1781707924000},"score":1,"resource":{"primary":{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3770748"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2026,6,17]]},"references-count":59,"journal-issue":{"issue":"7","published-print":{"date-parts":[[2026,7,31]]}},"alternative-id":["10.1145\/3770748"],"URL":"https:\/\/doi.org\/10.1145\/3770748","relation":{},"ISSN":["1049-331X","1557-7392"],"issn-type":[{"value":"1049-331X","type":"print"},{"value":"1557-7392","type":"electronic"}],"subject":[],"published":{"date-parts":[[2026,6,17]]},"assertion":[{"value":"2024-12-02","order":0,"name":"received","label":"Received","group":{"name":"publication_history","label":"Publication History"}},{"value":"2025-09-24","order":2,"name":"accepted","label":"Accepted","group":{"name":"publication_history","label":"Publication History"}},{"value":"2026-06-17","order":3,"name":"published","label":"Published","group":{"name":"publication_history","label":"Publication History"}}]}}