mlsanityData to 7 Oct 2026

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

arXiv 2407.20042 ↗First posted 29 Jul 2024cs.SEcited by 21

Not on the map. Why?

Abstract (arXiv)

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 tasks 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 tasks. 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

Key facts. Cited by 21 papers in the map (data through 7 Oct 2026). First posted on arXiv 29 Jul 2024.

Builds on

No reference list yet.

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 3; 2025: 11; 2026: 7.

21 papers.

Sort:

By area:

  1. 2024LLM Hallucinations in Practical Code Generation: Phenomena, Mechanism, and Mitigationcited by 92
  2. 2024Agents in Software Engineering: Survey, Landscape, and Visioncited by 60
  3. 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyondcited by 22
  4. 2025An Empirical Study of Agent Developer Practices in AI Agent Frameworkscited by 14
  5. 2025Towards an Understanding of Context Utilization in Code Intelligencecited by 10
  6. 2025Marking Code Without Breaking It: Code Watermarking for Detecting LLM-Generated Codecited by 7
  7. 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completioncited by 7
  8. 2025EfficientUICoder: A Bidirectional Token Compression Framework for Efficient MLLM-Based UI Code Generationcited by 4
  9. 2024Evaluating Quantized Large Language Models for Code Generation on Low-Resource Language Benchmarkscited by 3
  10. 2025Integrating Expert Knowledge into Logical Programs via LLMscited by 3
  11. 2025Breaking the Loop: Detecting and Mitigating Denial-of-Service Vulnerabilities in Large Language Modelscited by 3
  12. 2025Green Prompting: Characterizing Prompt-driven Energy Costs of LLM Inferencecited by 3
9 more
  1. 2026ShortCoder: Knowledge-Augmented Syntax Optimization for Token-Efficient Code Generationcited by 3
  2. 2026DRAINCODE: Stealthy Energy Consumption Attacks on Retrieval-Augmented Code Generation via Context Poisoningcited by 3
  3. 2025Optimizing Token Consumption in LLMs: A Nano Surge Approach for Code Reasoning Efficiencycited by 2
  4. 2026PhoenixRepair: Rethinking Repair Strategy Exploration in Software Agentscited by 2
  5. 2026SolAgent: A Specialized Multi-Agent Framework for Solidity Code Generationcited by 1
  6. 2025Benchmarking Web API Integration Code Generationcited by 0
  7. 2025RRT*former: Environment-Aware Sampling-Based Motion Planning using Transformercited by 0
  8. 2026HiKV: Hierarchical Importance-Aware KV Cache with Hardware Acceleration for LLM Decodingcited by 0
  9. 2026Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generationcited by 0