When Neural Code Completion Models Size up the Situation: Attaining Cheaper and Faster Completion through Dynamic Model Inference
Not on the map. Why?
Abstract (arXiv)
Leveraging recent advancements in large language models, modern neural code completion models have demonstrated the capability to generate highly accurate code suggestions. However, their massive size poses challenges in terms of computational costs and environmental impact, hindering their widespread adoption in practical scenarios. Dynamic inference emerges as a promising solution, as it allocates minimal computation during inference while maintaining the model's performance. In this research, we explore dynamic inference within the context of code completion. Initially, we conducted an empirical investigation on GPT-2, focusing on the inference capabilities of intermediate layers for code completion. We found that 54.4% of tokens can be accurately generated using just the first layer, signifying significant computational savings potential. Moreover, despite using all layers, the model still fails to predict 14.5% of tokens correctly, and the subsequent completions continued from them are rarely considered helpful, with only a 4.2% Acceptance Rate. These findings motivate our exploration of dynamic inference in code completion and inspire us to enhance it with a decision-making mechanism that stops the generation of incorrect code. We thus propose a novel dynamic inference method specifically tailored for code completion models. This method aims not only to produce correct predictions with largely reduced computation but also to prevent incorrect predictions proactively. Our extensive evaluation shows that it can averagely skip 1.7 layers out of 16 layers in the models, leading to an 11.2% speedup with only a marginal 1.1% reduction in ROUGE-L.
Key facts. Cited by 10 papers in the map (data through 7 Oct 2026). Builds on 18 of its 37 references that are in the map. First posted on arXiv 18 Jan 2024.
Builds on
18 of 37 references.
References · 18
- 2017Attention Is All You Needcited by 59,932
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2022Competition-Level Code Generation with AlphaCodecited by 1,427
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
- 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 638
- 2017BranchyNet: Fast Inference via Early Exiting from Deep Neural Networkscited by 591
- 2020DeeBERT: Dynamic Early Exiting for Accelerating BERT Inferencecited by 322
- 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 294
- 2020BERT Loses Patience: Fast and Robust Inference with Early Exitcited by 267
- 2020DynaBERT: Dynamic BERT with Adaptive Width and Depthcited by 246
6 more
- 2022Productivity Assessment of Neural Code Completioncited by 97
- 2022Out of the BLEU: how should we assess quality of the Code Generation models?cited by 65
- 2020CascadeBERT: Accelerating Inference of Pre-trained Language Models via Calibrated Complete Models Cascadecited by 47
- 2022On the Importance of Building High-quality Training Datasets for Neural Code Searchcited by 30
- 2023When to Show a Suggestion? Integrating Human Feedback in AI-Assisted Programmingcited by 25
- 2022Don't Complete It! Preventing Unhelpful Code Completion for Productive and Sustainable Neural Code Completion Systemscited by 12
Built on by
Citing papers per year: 2024: 3; 2025: 6; 2026: 1.
10 papers.
- 2024API-guided Dataset Synthesis to Finetune Large Code Modelscited by 11
- 2025The Hidden Cost of Readability: How Code Formatting Silently Consumes Your LLM Budgetcited by 11
- 2025Differentiation-Based Extraction of Proprietary Data from Fine-Tuned LLMscited by 6
- 2025A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChatcited by 5
- 2025"My productivity is boosted, but ..." Demystifying Users' Perception on AI Coding Assistantscited by 4
- 2024On the Compression of Language Models for Code: An Empirical Study on CodeBERTcited by 3
- 2025GREEN-CODE: Learning to Optimize Energy Efficiency in LLM-based Code Generationcited by 3
- 2025Optimizing LLM Code Suggestions: Feedback-Driven Timing with Lightweight State Boundscited by 2
- 2026Can LLM Aid in Solving Constraints with Inductive Definitions?cited by 1
- 2024Insights into resource utilization of code small language models serving with runtime engines and execution providerscited by 0
- 2026Can LLM Aid in Solving Constraints with Inductive Definitions?4 Mar 2026
- 2025Optimizing LLM Code Suggestions: Feedback-Driven Timing with Lightweight State Bounds24 Nov 2025
- 2025The Hidden Cost of Readability: How Code Formatting Silently Consumes Your LLM Budget19 Aug 2025
- 2025"My productivity is boosted, but ..." Demystifying Users' Perception on AI Coding Assistants17 Aug 2025
- 2025A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChat24 Jul 2025
- 2025Differentiation-Based Extraction of Proprietary Data from Fine-Tuned LLMs20 Jun 2025
- 2025GREEN-CODE: Learning to Optimize Energy Efficiency in LLM-based Code Generation19 Jan 2025
- 2024Insights into resource utilization of code small language models serving with runtime engines and execution providers19 Dec 2024
- 2024On the Compression of Language Models for Code: An Empirical Study on CodeBERT18 Dec 2024
- 2024API-guided Dataset Synthesis to Finetune Large Code Models15 Aug 2024