mlsanityData to 14 Oct 2026

Enhancing LLM-Based Code Generation with Complexity Metrics: A Feedback-Driven Approach

arXiv 2505.23953 ↗First posted 29 May 2025cs.SE cs.AIcited by 10

Not on the map. Why?

Abstract (arXiv)

Automatic code generation has gained significant momentum with the advent of Large Language Models (LLMs) such as GPT-4. Although many studies focus on improving the effectiveness of LLMs for code generation, very limited work tries to understand the generated code's characteristics and leverage that to improve failed cases. In this paper, as the most straightforward characteristic of code, we investigate the relationship between code complexity and the success of LLM generated code. Using a large set of standard complexity metrics, we first conduct an empirical analysis to explore their correlation with LLM's performance on code generation (i.e., Pass@1). Using logistic regression models, we identify which complexity metrics are most predictive of code correctness. Building on these findings, we propose an iterative feedback method, where LLMs are prompted to generate correct code based on complexity metrics from previous failed outputs. We validate our approach across multiple benchmarks (i.e., HumanEval, MBPP, LeetCode, and BigCodeBench) and various LLMs (i.e., GPT-4o, GPT-3.5 Turbo, Llama 3.1, and GPT-o3 mini), comparing the results with two baseline methods: (a) zero-shot generation, and (b) iterative execution-based feedback without our code complexity insights. Experiment results show that our approach makes notable improvements, particularly with a smaller LLM (GPT3.5 Turbo), where, e.g., Pass@1 increased by 35.71% compared to the baseline's improvement of 12.5% on the HumanEval dataset. The study expands experiments to BigCodeBench and integrates the method with the Reflexion code generation agent, leading to Pass@1 improvements of 20% (GPT-4o) and 23.07% (GPT-o3 mini). The results highlight that complexity-aware feedback enhances both direct LLM prompting and agent-based workflows.

Key facts. Cited by 10 papers in the map (data through 14 Oct 2026). Builds on 16 of its 35 references that are in the map. First posted on arXiv 29 May 2025.

Builds on

16 of 35 references.

References · 16

  1. 2023GPT-4 Technical Reportcited by 18,396
  2. 2024The Llama 3 Herd of Modelscited by 14,715
  3. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 13,028
  4. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
  5. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  6. 2017A Unified Approach to Interpreting Model Predictionscited by 6,555
  7. 2023Reflexion: Language Agents with Verbal Reinforcement Learningcited by 4,276
  8. 2021Program Synthesis with Large Language Modelscited by 3,637
  9. 2023Code Llama: Open Foundation Models for Codecited by 2,139
  10. 2024BigCodeBench: Benchmarking Code Generation with Diverse Function Calls and Complex Instructionscited by 546
  11. 2024Debug like a Human: A Large Language Model Debugger via Verifying Runtime Execution Step-by-stepcited by 127
  12. 2022Parsel: Algorithmic Reasoning with Language Models by Composing Decompositionscited by 64
4 more
  1. 2023ANPL: Towards Natural Programming with Interactive Decompositioncited by 13
  2. 2024No Man is an Island: Towards Fully Automatic Programming by Code Search, Code Generation and Program Repaircited by 4
  3. 2021A Pragmatic Approach for Hyper-Parameter Tuning in Search-based Test Case Generationcited by 2
  4. 2022An Empirical Study on Bug Severity Estimation using Source Code Metrics and Static Analysiscited by 2

Built on by

Cited by year (2026 to 14 Oct)

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

10 papers.