mlsanityData to 14 Oct 2026

Rethinking Repetition Problems of LLMs in Code Generation

arXiv 2505.10402 ↗First posted 15 May 2025cs.CL cs.AI cs.LGcited by 6

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

  1. 2021Evaluating Large Language Models Trained on Codecited by 8,320

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 2; 2026: 4.

6 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2025Solving LLM Repetition Problem in Production: A Comprehensive Study of Multiple Solutions
  2. 2024Understanding Defects in Generated Codes by Language Models
  3. 2025Understanding the Repeat Curse in Large Language Models from a Feature Perspective
  4. 2025Memorize or Generalize? Evaluating LLM Code Generation with Code Rewriting
  5. 2024CodeLutra: Boosting LLM Code Generation via Preference-Guided Refinement
  6. 2025Refining Critical Thinking in LLM Code Generation: A Faulty Premise-based Evaluation Framework
  7. 2026Are you Synthesizing or Recalling? Evaluating LLMs on Algorithmic Code Retrieval
  8. 2025BigO(Bench): Can LLMs Generate Code with Controlled Time and Space Complexity?