mlsanityData to 7 Oct 2026

Code Copycat Conundrum: Demystifying Repetition in LLM-based Code Generation

arXiv 2504.12608 ↗First posted 17 Apr 2025cs.SE cs.AIcited by 4

Not on the map. Why?

Abstract (arXiv)

Despite recent advances in Large Language Models (LLMs) for code generation, the quality of LLM-generated code still faces significant challenges. One significant issue is code repetition, which refers to the model's tendency to generate structurally redundant code, resulting in inefficiencies and reduced readability. To address this, we conduct the first empirical study to investigate the prevalence and nature of repetition across 19 state-of-the-art code LLMs using three widely-used benchmarks. Our study includes both quantitative and qualitative analyses, revealing that repetition is pervasive and manifests at various granularities and extents, including character, statement, and block levels. We further summarize a taxonomy of 20 repetition patterns. Building on our findings, we propose DeRep, a rule-based technique designed to detect and mitigate repetition in generated code. We evaluate DeRep using both open-source benchmarks and in an industrial setting. Our results demonstrate that DeRep significantly outperforms baselines in reducing repetition (with an average improvements of 91.3%, 93.5%, and 79.9% in rep-3, rep-line, and sim-line metrics) and enhancing code quality (with a Pass@1 increase of 208.3% over greedy search). Furthermore, integrating DeRep improves the performance of existing repetition mitigation methods, with Pass@1 improvements ranging from 53.7% to 215.7%.

Key facts. Cited by 4 papers in the map (data through 7 Oct 2026). Builds on 28 of its 35 references that are in the map. First posted on arXiv 17 Apr 2025.

Builds on

28 of 35 references.

References · 28

  1. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
  2. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  3. 2021Program Synthesis with Large Language Modelscited by 3,509
  4. 2019The Curious Case of Neural Text Degenerationcited by 2,881
  5. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  6. 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
  7. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
  8. 2023StarCoder: may the source be with you!cited by 790
  9. 2019CTRL: A Conditional Transformer Language Model for Controllable Generationcited by 754
  10. 2024BigCodeBench: Benchmarking Code Generation with Diverse Function Calls and Complex Instructionscited by 527
  11. 2024StarCoder 2 and The Stack v2: The Next Generationcited by 484
  12. 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
16 more
  1. 2017Beam Search Strategies for Neural Machine Translationcited by 232
  2. 2022A Contrastive Framework for Neural Text Generationcited by 224
  3. 2023CrossCodeEval: A Diverse and Multilingual Benchmark for Cross-File Code Completioncited by 181
  4. 2023SantaCoder: don't reach for the stars!cited by 169
  5. 2022Multi-lingual Evaluation of Code Generation Modelscited by 158
  6. 2022Large Language Models are Few-shot Testers: Exploring LLM-based General Bug Reproductioncited by 110
  7. 2024Beyond Functional Correctness: Exploring Hallucinations in LLM-Generated Codecited by 106
  8. 2022Learning to Break the Loop: Analyzing and Mitigating Repetitions for Neural Text Generationcited by 90
  9. 2022Automated Repair of Programs from Large Language Modelscited by 71
  10. 2024EvoCodeBench: An Evolving Code Generation Benchmark Aligned with Real-World Code Repositoriescited by 71
  11. 2024Bugs in Large Language Models Generated Code: An Empirical Studycited by 59
  12. 2023Explainable Automated Debugging via Large Language Model-driven Scientific Debuggingcited by 40
  13. 2023Repetition In Repetition Out: Towards Understanding Neural Text Degeneration from the Data Perspectivecited by 39
  14. 2024TESTEVAL: Benchmarking Large Language Models for Test Case Generationcited by 38
  15. 2023Can Large Language Models Write Good Property-Based Tests?cited by 30
  16. 2024Beyond Functional Correctness: Investigating Coding Style Inconsistencies in Large Language Modelscited by 15

Built on by

Cited by year

Citing papers per year: 2025: 4.

4 papers.