CoChat

When to Stop? Towards Efficient Code Generation in LLMs with Excess Token Prevention

Open access
Guo, Lianghong, Wang, Yanlin, Shi, Ensheng, Zhong, Wanjun, Zhang, Hongyu, Chen, Jiachi, Zhang, Ruikai, Ma, Yuchi, Zheng, Zibin · 2024 · Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis
Cited by 20

The DOI matches its Crossref record; 10 of the 10 references it cites were found in a registry or an index.

Abstract

Code generation aims to automatically generate code snippets that meet given natural language requirements and plays an important role in software development. Although Code LLMs have shown excellent performance in this domain, their long generation time poses a signification limitation in practice use. In this paper, we first conduct an in-depth preliminary study with different Code LLMs on code generation task and identify a significant efficiency issue, i.e., continual generation of excess tokens. It harms the developer productivity and leads to huge computational wastes. To address it, we introduce CodeFast, an inference acceleration approach for Code LLMs on code generation. The key idea of CodeFast is to terminate the inference process in time when unnecessary excess tokens are detected. First, we propose an automatic data construction framework to obtain training data. Then, we train a unified lightweight model GenGuard applicable to multiple programming languages to predict whether to terminate inference at the current step. Finally, we enhance Code LLM with GenGuard to accelerate its inference in code generation task. We conduct extensive experiments with CodeFast on five representative Code LLMs across four widely used code generation datasets. Experimental results show that (1) CodeFast can significantly improve the inference speed of various Code LLMs in code generation, ranging form 34% to 452%, without compromising the quality of generated code. (2) CodeFast is stable across different parameter settings and can generalize to untrained datasets. Our code and data are available at https://github.com/DeepSoftwareAnalytics/CodeFast.

Overview

The claims and statistics of this paper haven’t been checked yet.

Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.

A few free checks a day · papers already verified open instantly · results are public

Integrity signals

Registry

Crossref · 10.1145/3650212.3680343

Cites

10 of 10 references verified0 citation errors · 0 not checkable

Statistics

Verification

Claims the paper makes

The claims and statistics of this paper haven’t been checked yet.

Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.

A few free checks a day · papers already verified open instantly · results are public

Self-check

Percentages, sums and reported differences re-computed from the paper’s own numbers.

The self-check needs the paper’s full text.

Citations

Cites

Show all 10 references

Cited by

See all 20

Metadata

Authors
Guo, L., Wang, Y., Shi, E., Zhong, W., Zhang, H., Chen, J., Zhang, R., Ma, Y., & Zheng, Z.
Venue
Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis
Publisher
ACM
Published
2024-09-11
Pages
1073-1085
OpenAlex
W4402457243
Cited by
20
References
10
FWCI
7.86
Type
conference paper
Language
en
Open access
green

About these checks

Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.

Statistics and arithmetic are recomputed, not judged.

Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.

What counts as a claim ›How we measure confidence ›How we check this ›

Are you an author, or do you see a problem with this page? Request a review

How to cite

Cite CoChat for the checks on this page, and the paper for its own findings.

This page
CoChat. (2026). Citation check: When to Stop? Towards Efficient Code Generation in LLMs with Excess Token Prevention. https://app.cochat.ai/papers/10.1145/3650212.3680343
The paper
Guo, L., Wang, Y., Shi, E., Zhong, W., Zhang, H., Chen, J., Zhang, R., Ma, Y., & Zheng, Z. (2024). When to Stop? Towards Efficient Code Generation in LLMs with Excess Token Prevention. Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis. https://doi.org/10.1145/3650212.3680343

Data sources

Bibliographic data: Semantic Scholar, OpenAlex, Crossref.

Contains information from the Semantic Scholar Academic Graph Datasets, made available under the ODC Attribution License (ODC-BY 1.0).

Semantic Scholar’s data is described in: Kinney, R., et al. (2023). The Semantic Scholar Open Data Platform. arXiv:2301.10140.