A Deep Dive Into Large Language Model Code Generation Mistakes: What and Why?
Not on the map. Why?
Abstract (arXiv)
Recent advancements in Large Language Models (LLMs) have led to their widespread application in automated code generation. However, these models can still generate defective code that deviates from the specification. Previous research has mainly focused on the mistakes in LLM-generated standalone functions, overlooking real-world software development situations where the successful generation of the code requires software contexts such as external dependencies. In this paper, we considered both of these code generation situations and identified a range of textitnon-syntactic mistakes arising from LLMs' misunderstandings of coding question specifications. Seven categories of non-syntactic mistakes were identified through extensive manual analyses, four of which were missed by previous works. To better understand these mistakes, we proposed six reasons behind these mistakes from various perspectives. Moreover, we explored the effectiveness of LLMs in detecting mistakes and their reasons. Our evaluation demonstrated that GPT-4 with the ReAct prompting technique can achieve an F1 score of up to 0.65 when identifying reasons for LLM's mistakes, such as misleading function signatures. We believe that these findings offer valuable insights into enhancing the quality of LLM-generated code.
Key facts. Cited by 10 papers in the map (data through 14 Oct 2026). Builds on 47 of its 97 references that are in the map. First posted on arXiv 3 Nov 2024.
Builds on
47 of 97 references.
References · 47
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2023GPT-4 Technical Reportcited by 18,396
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
- 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,170
- 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,695
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,708
- 2022Large Language Models are Zero-Shot Reasonerscited by 4,374
- 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,442
- 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,373
- 2023A Survey on Evaluation of Large Language Modelscited by 1,242
35 more
- 2024Qwen2.5-Coder Technical Reportcited by 1,203
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2023ChatGPT Outperforms Crowd-Workers for Text-Annotation Taskscited by 870
- 2023Language Agent Tree Search Unifies Reasoning Acting and Planning in Language Modelscited by 574
- 2024StarCoder 2 and The Stack v2: The Next Generationcited by 502
- 2023A Survey of Hallucination in Large Foundation Modelscited by 368
- 2022A Systematic Evaluation of Large Language Models of Codecited by 363
- 2024A Survey on Hallucination in Large Vision-Language Modelscited by 357
- 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 300
- 2023Self-collaboration Code Generation via ChatGPTcited by 258
- 2022Multi-lingual Evaluation of Code Generation Modelscited by 159
- 2023Towards Making the Most of ChatGPT for Machine Translationcited by 138
- 2024Beyond Functional Correctness: Exploring Hallucinations in LLM-Generated Codecited by 107
- 2021Jigsaw: Large Language Models meet Program Synthesiscited by 103
- 2024LLM Hallucinations in Practical Code Generation: Phenomena, Mechanism, and Mitigationcited by 93
- 2023GPT-4 Doesn't Know It's Wrong: An Analysis of Iterative Prompting for Reasoning Problemscited by 89
- 2023Large Language Models are Few-Shot Summarizers: Multi-Intent Comment Generation via In-Context Learningcited by 72
- 2024Premise Order Matters in Reasoning with Large Language Modelscited by 72
- 2022Automated Repair of Programs from Large Language Modelscited by 71
- 2024Bugs in Large Language Models Generated Code: An Empirical Studycited by 60
- 2024CoIR: A Comprehensive Benchmark for Code Information Retrieval Modelscited by 60
- 2022Problems with Cosine as a Measure of Embedding Similarity for High Frequency Wordscited by 49
- 2023What Makes Good In-context Demonstrations for Code Intelligence Tasks with LLMs?cited by 47
- 2023Large Language Models and Simple, Stupid Bugscited by 45
- 2024Using AI-Based Coding Assistants in Practice: State of Affairs, Perceptions, and Ways Forwardcited by 45
- 2023Exploring the Potential of ChatGPT in Automated Code Refinement: An Empirical Studycited by 44
- 2023Prompting Is All You Need: Automated Android Bug Replay with Large Language Modelscited by 40
- 2023ClarifyGPT: Empowering LLM-based Code Generation with Intention Clarificationcited by 38
- 2024Insights into LLM Long-Context Failures: When Transformers Know but Don't Tellcited by 36
- 2024LLMs in Web Development: Evaluating LLM-Generated PHP Code Unveiling Vulnerabilities and Limitationscited by 22
- 2023Critique Ability of Large Language Modelscited by 20
- 2023Exploring Code Analysis: Zero-Shot Insights on Syntax and Semantics with LLMscited by 19
- 2023Do Large Language Models Pay Similar Attention Like Human Programmers When Generating Code?cited by 14
- 2022How Important are Good Method Names in Neural Code Generation? A Model Robustness Perspectivecited by 11
- 2014Identifying Duplicate and Contradictory Information in Wikipediacited by 2
Built on by
Citing papers per year: 2025: 6; 2026: 4.
10 papers.
- 2025ToolDreamer: Instilling LLM Reasoning Into Tool Retrieverscited by 7
- 2025Program Synthesis via Test-Time Transductioncited by 4
- 2025Past, Present, and Future of Bug Tracking in the Generative AI Eracited by 4
- 2025SecureFixAgent: A Hybrid LLM Agent for Automated Python Static Vulnerability Repaircited by 3
- 2025Large Language Models for IT Automation Tasks: Are We There Yet?cited by 1
- 2026Team, Then Trim: An Assembly-Line LLM Framework for High-Quality Tabular Data Generationcited by 1
- 2026Rethinking Code Review in the Age of AI: A Vision for Agentic Code Reviewcited by 1
- 2025StaAgent: An Agentic Framework for Testing Static Analyzerscited by 0
- 2026Is Vibe Coding the Future? An Empirical Assessment of LLM Generated Codes for Construction Safetycited by 0
- 2026Why, Where, How: Taxonomy-guided Error Grounding for Code Repair in NL2SQLcited by 0
- 2026Why, Where, How: Taxonomy-guided Error Grounding for Code Repair in NL2SQL4 Oct 2026
- 2026Rethinking Code Review in the Age of AI: A Vision for Agentic Code Review17 May 2026
- 2026Is Vibe Coding the Future? An Empirical Assessment of LLM Generated Codes for Construction Safety14 Apr 2026
- 2026Team, Then Trim: An Assembly-Line LLM Framework for High-Quality Tabular Data Generation4 Feb 2026
- 2025ToolDreamer: Instilling LLM Reasoning Into Tool Retrievers22 Oct 2025
- 2025Past, Present, and Future of Bug Tracking in the Generative AI Era9 Oct 2025
- 2025Program Synthesis via Test-Time Transduction22 Sep 2025
- 2025SecureFixAgent: A Hybrid LLM Agent for Automated Python Static Vulnerability Repair18 Sep 2025
- 2025StaAgent: An Agentic Framework for Testing Static Analyzers20 Jul 2025
- 2025Large Language Models for IT Automation Tasks: Are We There Yet?26 May 2025