paperbot · PL 论文追踪

全部论文 待读 收藏

P2 When Neural Code Completion Models Size up the Situation: Attaining Cheaper and Faster Completion through Dynamic Model Inference

当神经代码补全模型审时度势:通过动态模型推理实现更廉价、更快速的补全
ICSE Proceedings of the IEEE/ACM 46th International Conference on Software Engineering2024匹配度 2/10 · 该论文研究代码补全模型的动态推理与加速,属于提升 LLM 推理效率的工作,而用户核心关注的是静态分析在 ML/Agent 系统中的应用、LLM 辅助静态分析/形式化验证,以及浮点或贝叶斯程序分析与 LLM 的交叉。它既不涉及静态分析,也不涉及 Agentic 程序或浮点/贝叶斯程序分析,因此匹配度较低。引用 14 inbox
Zhensu Sun, Xiaoning Du, Fu Song, Shangwen Wang, Li Li
crossref: 2026-09-12

AI 速览

一句话:提出面向代码补全的动态推理方法,平均跳过1.7层,实现11.2%加速且ROUGE-L仅降1.1%。

本文研究代码补全中的动态推理。作者首先在 GPT-2 上实证分析中间层的推理能力,发现仅第一层即可正确生成 54.4% 的 token,而使用全部层仍有 14.5% 的 token 预测错误,且后续补全接受率仅 4.2%。受此启发,作者提出面向代码补全模型的动态推理方法,并引入决策机制提前终止错误代码生成,以减少计算并主动避免错误预测。评估表明,该方法在 16 层模型中平均跳过 1.7 层,取得 11.2% 的加速,ROUGE-L 仅下降 1.1%。

问题
神经代码补全模型规模庞大、推理计算开销高,难以在实际场景中广泛部署;如何在不显著损失补全质量的前提下降低计算量是关键问题。
方法
作者先实证分析 GPT-2 中间层的代码补全能力,进而提出面向代码补全的动态推理方法,并设计决策机制以提前停止错误代码的生成。
评估
在 16 层模型上进行广泛评估,平均跳过 1.7 层,获得 11.2% 加速,ROUGE-L 仅下降 1.1%。
原文摘要(Abstract)

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.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot11375,
  title = {When Neural Code Completion Models Size up the Situation: Attaining Cheaper and Faster Completion through Dynamic Model Inference},
  author = {Zhensu Sun and Xiaoning Du and Fu Song and Shangwen Wang and Li Li},
  booktitle = {ICSE},
  year = {2024},
  doi = {10.1145/3597503.3639120}
}