Rethinking Repetition Problems of LLMs in Code Generation
On the map: LLM reasoning → Reasoning for agents, planning and code
Abstract (arXiv)
With the advent of neural language models, the performance of code generation has been significantly boosted. However, the problem of repetitions during the generation process continues to linger. Previous work has primarily focused on content repetition, which is merely a fraction of the broader repetition problem in code generation. A more prevalent and challenging problem is structural repetition. In structural repetition, the repeated code appears in various patterns but possesses a fixed structure, which can be inherently reflected in grammar. In this paper, we formally define structural repetition and propose an efficient decoding approach called RPG, which stands for Repetition Penalization based on Grammar, to alleviate the repetition problems in code generation for LLMs. Specifically, RPG first leverages grammar rules to identify repetition problems during code generation, and then strategically decays the likelihood of critical tokens that contribute to repetitions, thereby mitigating them in code generation. To facilitate this study, we construct a new dataset CodeRepetEval to comprehensively evaluate approaches for mitigating the repetition problems in code generation. Extensive experimental results demonstrate that RPG substantially outperforms the best-performing baselines on CodeRepetEval dataset as well as HumanEval and MBPP benchmarks, effectively reducing repetitions and enhancing the quality of generated code.
Key facts. Cited by 6 papers in the map (data through 14 Oct 2026). Placed in Reasoning for agents, planning and code, one of 17 directions in LLM reasoning. Builds on 1 of its 47 references that are in the map. First posted on arXiv 15 May 2025.
Builds on
1 of 47 references.
References · 1
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
Built on by
Citing papers per year: 2025: 2; 2026: 4.
6 papers.
- 2025Saber: An Efficient Sampling with Adaptive Acceleration and Backtracking Enhanced Remasking for Diffusion Language Modelcited by 13
- 2026Lookahead-then-Verify: Reliable Constrained Decoding for Diffusion LLMs under Context-Free Grammarscited by 7
- 2025CodeReasoner: Enhancing the Code Reasoning Ability with Reinforcement Learningcited by 4
- 2026SepSeq: A Training-Free Framework for Long Numerical Sequence Processing in LLMscited by 2
- 2026Beyond Temperature: Hyperfitting as a Late-Stage Geometric Expansioncited by 1
- 2026Escaping Mode Collapse in LLM Generation via Geometric Regulationcited by 0
- 2026Beyond Temperature: Hyperfitting as a Late-Stage Geometric Expansion21 May 2026
- 2026Escaping Mode Collapse in LLM Generation via Geometric Regulation1 May 2026
- 2026SepSeq: A Training-Free Framework for Long Numerical Sequence Processing in LLMs9 Apr 2026
- 2026Lookahead-then-Verify: Reliable Constrained Decoding for Diffusion LLMs under Context-Free Grammars31 Jan 2026
- 2025Saber: An Efficient Sampling with Adaptive Acceleration and Backtracking Enhanced Remasking for Diffusion Language Model20 Oct 2025
- 2025CodeReasoner: Enhancing the Code Reasoning Ability with Reinforcement Learning23 Jul 2025
Similar, not cited
Close in wording, no citation either way
- 2025Solving LLM Repetition Problem in Production: A Comprehensive Study of Multiple Solutions
- 2024Understanding Defects in Generated Codes by Language Models
- 2025Understanding the Repeat Curse in Large Language Models from a Feature Perspective
- 2025Memorize or Generalize? Evaluating LLM Code Generation with Code Rewriting
- 2024CodeLutra: Boosting LLM Code Generation via Preference-Guided Refinement
- 2025Refining Critical Thinking in LLM Code Generation: A Faulty Premise-based Evaluation Framework
- 2026Are you Synthesizing or Recalling? Evaluating LLMs on Algorithmic Code Retrieval
- 2025BigO(Bench): Can LLMs Generate Code with Controlled Time and Space Complexity?