Enhancing LLM-Based Code Generation with Complexity Metrics: A Feedback-Driven Approach
Melika Sepidband, Hamed Taherkhani, Song Wang, Hadi Hemmati

TL;DR
This paper investigates how code complexity metrics relate to LLM code generation success and introduces a feedback-driven method that uses these metrics to improve code correctness across multiple benchmarks and models.
Contribution
It identifies key complexity metrics predictive of code correctness and proposes a novel iterative feedback approach leveraging these metrics to enhance LLM code generation performance.
Findings
Complexity metrics correlate with LLM code success.
Feedback based on complexity metrics improves Pass@1 by up to 35.71%.
Method benefits smaller LLMs and integrates with code generation agents.
Abstract
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…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsNatural Language Processing Techniques · Software Engineering Research · Mathematics, Computing, and Information Processing
MethodsRefunds@Expedia|||How do I get a full refund from Expedia? · Linear Layer · Position-Wise Feed-Forward Layer · Absolute Position Encodings · Label Smoothing · Cosine Annealing · Multi-Head Attention · Byte Pair Encoding · Attention Is All You Need · {Dispute@FaQ-s}How to file a dispute with Expedia?
