Research

Paper

AI LLM March 06, 2026

Balancing Latency and Accuracy of Code Completion via Local-Cloud Model Cascading

Authors

Hanzhen Lu, Lishui Fan, Jiachi Chen, Qiuyuan Chen, Zhao Wei, Zhongxin Liu

Abstract

Line-level code completion requires a critical balance between high accuracy and low latency. Existing methods suffer from a trade-off: large language models (LLMs) provide high-quality suggestions but incur high latency, while small language models (SLMs) are fast but often suboptimal. We propose MCCom (Model-Cascading-based code Completion), a framework that cascades a local SLM with a cloud-based LLM. To achieve effective cascading, MCCom leverages user actions as a novel signal to trigger the LLM only when the SLM fails, significantly reducing cloud computation costs. Furthermore, we introduce a two-stage speculative decoding strategy and an iterative retrieval mechanism to enhance collaboration between the models. We also train a 121M-parameter lightweight model, which achieves 73.8% of the performance of a 7B state-of-the-art model. Evaluated on RepoEval and a new real-world benchmark StmtEval, MCCom reduces inference latency by up to 47.9% and LLM usage by 46.3%, while improving the LLM's exact match rate by 8.9% through effective collaboration.

Metadata

arXiv ID: 2603.05974
Provider: ARXIV
Primary Category: cs.SE
Published: 2026-03-06
Fetched: 2026-03-09 06:05

Related papers

Raw Data (Debug)
{
  "raw_xml": "<entry>\n    <id>http://arxiv.org/abs/2603.05974v1</id>\n    <title>Balancing Latency and Accuracy of Code Completion via Local-Cloud Model Cascading</title>\n    <updated>2026-03-06T07:15:36Z</updated>\n    <link href='https://arxiv.org/abs/2603.05974v1' rel='alternate' type='text/html'/>\n    <link href='https://arxiv.org/pdf/2603.05974v1' rel='related' title='pdf' type='application/pdf'/>\n    <summary>Line-level code completion requires a critical balance between high accuracy and low latency. Existing methods suffer from a trade-off: large language models (LLMs) provide high-quality suggestions but incur high latency, while small language models (SLMs) are fast but often suboptimal. We propose MCCom (Model-Cascading-based code Completion), a framework that cascades a local SLM with a cloud-based LLM. To achieve effective cascading, MCCom leverages user actions as a novel signal to trigger the LLM only when the SLM fails, significantly reducing cloud computation costs. Furthermore, we introduce a two-stage speculative decoding strategy and an iterative retrieval mechanism to enhance collaboration between the models. We also train a 121M-parameter lightweight model, which achieves 73.8% of the performance of a 7B state-of-the-art model. Evaluated on RepoEval and a new real-world benchmark StmtEval, MCCom reduces inference latency by up to 47.9% and LLM usage by 46.3%, while improving the LLM's exact match rate by 8.9% through effective collaboration.</summary>\n    <category scheme='http://arxiv.org/schemas/atom' term='cs.SE'/>\n    <published>2026-03-06T07:15:36Z</published>\n    <arxiv:comment>Accepted by FSE'26</arxiv:comment>\n    <arxiv:primary_category term='cs.SE'/>\n    <author>\n      <name>Hanzhen Lu</name>\n    </author>\n    <author>\n      <name>Lishui Fan</name>\n    </author>\n    <author>\n      <name>Jiachi Chen</name>\n    </author>\n    <author>\n      <name>Qiuyuan Chen</name>\n    </author>\n    <author>\n      <name>Zhao Wei</name>\n    </author>\n    <author>\n      <name>Zhongxin Liu</name>\n    </author>\n  </entry>"
}