The Counterfeit Conundrum: Can Code Language Models Grasp the Nuances of Their Incorrect Generations?
Not on the map. Why?
Abstract (arXiv)
While language models are increasingly more proficient at code generation, they still frequently generate incorrect programs. Many of these programs are obviously wrong, but others are more subtle and pass weaker correctness checks such as being able to compile. In this work, we focus on these counterfeit samples: programs sampled from a language model that 1) have a high enough log-probability to be generated at a moderate temperature and 2) pass weak correctness checks. Overall, we discover that most models have a very shallow understanding of counterfeits through three clear failure modes. First, models mistakenly classify them as correct. Second, models are worse at reasoning about the execution behaviour of counterfeits and often predict their execution results as if they were correct. Third, when asking models to fix counterfeits, the likelihood of a model successfully repairing a counterfeit is often even lower than that of sampling a correct program from scratch. Counterfeits also have very unexpected properties: first, counterfeit programs for problems that are easier for a model to solve are not necessarily easier to detect and only slightly easier to execute and repair. Second, counterfeits from a given model are just as confusing to the model itself as they are to other models. Finally, both strong and weak models are able to generate counterfeit samples that equally challenge all models. In light of our findings, we recommend that care and caution be taken when relying on models to understand their own samples, especially when no external feedback is incorporated.
Key facts. Cited by 20 papers in the map (data through 7 Oct 2026). Builds on 45 of its 67 references that are in the map. First posted on arXiv 29 Feb 2024.
Builds on
45 of 67 references.
References · 45
- 2021Training Verifiers to Solve Math Word Problemscited by 9,743
- 2024DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Modelscited by 8,851
- 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,393
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,601
- 2023Let's Verify Step by Stepcited by 3,598
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,317
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2022Competition-Level Code Generation with AlphaCodecited by 1,427
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
33 more
- 2023Large Language Models Cannot Self-Correct Reasoning Yetcited by 965
- 2023Teaching Large Language Models to Self-Debugcited by 963
- 2023Math-Shepherd: Verify and Reinforce LLMs Step-by-step without Human Annotationscited by 895
- 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 871
- 2023StarCoder: may the source be with you!cited by 790
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
- 2022CodeT: Code Generation with Generated Testscited by 369
- 2023State of What Art? A Call for Multi-Prompt LLM Evaluationcited by 299
- 2024CRUXEval: A Benchmark for Code Reasoning, Understanding and Executioncited by 294
- 2023Reasoning or Reciting? Exploring the Capabilities and Limitations of Language Models Through Counterfactual Taskscited by 243
- 2023Universal Self-Consistency for Large Language Model Generationcited by 198
- 2023Is Self-Repair a Silver Bullet for Code Generation?cited by 191
- 2023Solving Challenging Math Word Problems Using GPT-4 Code Interpreter with Code-based Self-Verificationcited by 166
- 2023Self-Edit: Fault-Aware Code Editor for Code Generationcited by 110
- 2023Can Large Language Models Really Improve by Self-critiquing Their Own Plans?cited by 107
- 2024Code Generation with AlphaCodium: From Prompt Engineering to Flow Engineeringcited by 100
- 2023The Generative AI Paradox: "What It Can Create, It May Not Understand"cited by 97
- 2022Execution-Based Evaluation for Open-Domain Code Generationcited by 89
- 2023GPT-4 Doesn't Know It's Wrong: An Analysis of Iterative Prompting for Reasoning Problemscited by 88
- 2023LLMs cannot find reasoning errors, but can correct them given the error locationcited by 85
- 2022Coder Reviewer Reranking for Code Generationcited by 83
- 2023Enhancing Large Language Models in Coding Through Multi-Perspective Self-Consistencycited by 46
- 2024When is Tree Search Useful for LLM Planning? It Depends on the Discriminatorcited by 46
- 2023ALGO: Synthesizing Algorithmic Programs with LLM-Generated Oracle Verifierscited by 41
- 2023Beyond Accuracy: Evaluating Self-Consistency of Code Large Language Models with IdentityChaincited by 31
- 2023The Larger They Are, the Harder They Fail: Language Models do not Recognize Identifier Swaps in Pythoncited by 29
- 2023Large Language Models of Code Fail at Completing Code with Potential Bugscited by 28
- 2019ATOM: Commit Message Generation Based on Abstract Syntax Tree and Hybrid Rankingcited by 25
- 2021CoDesc: A Large Code-Description Parallel Datasetcited by 23
- 2024NoFunEval: Funny How Code LMs Falter on Requirements Beyond Functional Correctnesscited by 23
- 2023A large language model-assisted education tool to provide feedback on open-ended responsescited by 21
- 2023Towards LLM-based Autograding for Short Textual Answerscited by 20
- 2024The Generative AI Paradox on Evaluation: What It Can Solve, It May Not Evaluatecited by 16
Built on by
Citing papers per year: 2024: 9; 2025: 8; 2026: 3.
20 papers.
Sort:
By area:
- 2025R2E-Gym: Procedural Environments and Hybrid Verifiers for Scaling Open-Weights SWE Agentscited by 140
- 2024Vulnerability Detection with Code Language Models: How Far Are We?cited by 133
- 2024Small Language Models Need Strong Verifiers to Self-Correct Reasoningcited by 85
- 2024Formal Mathematical Reasoning: A New Frontier in AIcited by 80
- 2024CodeJudge-Eval: Can Large Language Models be Good Judges in Code Understanding?cited by 29
- 2024What Makes Large Language Models Reason in (Multi-Turn) Code Generation?cited by 29
- 2025SWE-Synth: Synthesizing Verifiable Bug-Fix Data to Enable Large Language Models in Resolving Real-World Bugscited by 22
- 2024Learning Code Preference via Synthetic Evolutioncited by 19
- 2024MdEval: Massively Multilingual Code Debuggingcited by 16
- 2024LLM-Powered Test Case Generation for Detecting Bugs in Plausible Programscited by 14
- 2025ReliableEval: A Recipe for Stochastic LLM Evaluation via Method of Momentscited by 10
- 2025Are Large Language Models Robust in Understanding Code Against Semantics-Preserving Mutations?cited by 7
8 more
- 2024Specify What? Enhancing Neural Specification Synthesis by Symbolic Methodscited by 6
- 2025IFEvalCode: Controlled Code Generationcited by 5
- 2025XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistantscited by 4
- 2025PromptSuite: A Task-Agnostic Framework for Multi-Prompt Generationcited by 3
- 2026Self-Execution Simulation Improves Coding Modelscited by 2
- 2025Success is in the Details: Evaluate and Enhance Details Sensitivity of Code LLMs through Counterfactualscited by 1
- 2026Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Codecited by 1
- 2026On the Robustness of LLMs' Internal Representation of Code Correctnesscited by 1
- 2026On the Robustness of LLMs' Internal Representation of Code Correctness8 Aug 2026
- 2026Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Code6 May 2026
- 2026Self-Execution Simulation Improves Coding Models11 Mar 2026
- 2025IFEvalCode: Controlled Code Generation30 Jul 2025
- 2025PromptSuite: A Task-Agnostic Framework for Multi-Prompt Generation20 Jul 2025
- 2025ReliableEval: A Recipe for Stochastic LLM Evaluation via Method of Moments28 May 2025
- 2025Success is in the Details: Evaluate and Enhance Details Sensitivity of Code LLMs through Counterfactuals20 May 2025
- 2025Are Large Language Models Robust in Understanding Code Against Semantics-Preserving Mutations?15 May 2025
- 2025SWE-Synth: Synthesizing Verifiable Bug-Fix Data to Enable Large Language Models in Resolving Real-World Bugs20 Apr 2025
- 2025R2E-Gym: Procedural Environments and Hybrid Verifiers for Scaling Open-Weights SWE Agents9 Apr 2025
- 2025XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistants18 Mar 2025
- 2024Formal Mathematical Reasoning: A New Frontier in AI20 Dec 2024
8 more
- 2024MdEval: Massively Multilingual Code Debugging4 Nov 2024
- 2024What Makes Large Language Models Reason in (Multi-Turn) Code Generation?10 Oct 2024
- 2024Learning Code Preference via Synthetic Evolution4 Oct 2024
- 2024CodeJudge-Eval: Can Large Language Models be Good Judges in Code Understanding?20 Aug 2024
- 2024Specify What? Enhancing Neural Specification Synthesis by Symbolic Methods21 Jun 2024
- 2024Small Language Models Need Strong Verifiers to Self-Correct Reasoning26 Apr 2024
- 2024LLM-Powered Test Case Generation for Detecting Bugs in Plausible Programs16 Apr 2024
- 2024Vulnerability Detection with Code Language Models: How Far Are We?27 Mar 2024
- 2025R2E-Gym: Procedural Environments and Hybrid Verifiers for Scaling Open-Weights SWE Agentscited by 140
- 2024Small Language Models Need Strong Verifiers to Self-Correct Reasoningcited by 85
- 2024Formal Mathematical Reasoning: A New Frontier in AIcited by 80
- 2024What Makes Large Language Models Reason in (Multi-Turn) Code Generation?cited by 29
- 2025R2E-Gym: Procedural Environments and Hybrid Verifiers for Scaling Open-Weights SWE Agents9 Apr 2025
- 2024Formal Mathematical Reasoning: A New Frontier in AI20 Dec 2024
- 2024What Makes Large Language Models Reason in (Multi-Turn) Code Generation?10 Oct 2024
- 2024Small Language Models Need Strong Verifiers to Self-Correct Reasoning26 Apr 2024
- 2024Vulnerability Detection with Code Language Models: How Far Are We?cited by 133
- 2024CodeJudge-Eval: Can Large Language Models be Good Judges in Code Understanding?cited by 29
- 2025SWE-Synth: Synthesizing Verifiable Bug-Fix Data to Enable Large Language Models in Resolving Real-World Bugscited by 22
- 2024Learning Code Preference via Synthetic Evolutioncited by 19
- 2024MdEval: Massively Multilingual Code Debuggingcited by 16
- 2024LLM-Powered Test Case Generation for Detecting Bugs in Plausible Programscited by 14
- 2025ReliableEval: A Recipe for Stochastic LLM Evaluation via Method of Momentscited by 10
- 2025Are Large Language Models Robust in Understanding Code Against Semantics-Preserving Mutations?cited by 7
- 2024Specify What? Enhancing Neural Specification Synthesis by Symbolic Methodscited by 6
- 2025IFEvalCode: Controlled Code Generationcited by 5
- 2025XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistantscited by 4
- 2025PromptSuite: A Task-Agnostic Framework for Multi-Prompt Generationcited by 3
12 most cited of 16 All 16 (JSON)
- 2026On the Robustness of LLMs' Internal Representation of Code Correctness8 Aug 2026
- 2026Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Code6 May 2026
- 2026Self-Execution Simulation Improves Coding Models11 Mar 2026
- 2025IFEvalCode: Controlled Code Generation30 Jul 2025
- 2025PromptSuite: A Task-Agnostic Framework for Multi-Prompt Generation20 Jul 2025
- 2025ReliableEval: A Recipe for Stochastic LLM Evaluation via Method of Moments28 May 2025
- 2025Success is in the Details: Evaluate and Enhance Details Sensitivity of Code LLMs through Counterfactuals20 May 2025
- 2025Are Large Language Models Robust in Understanding Code Against Semantics-Preserving Mutations?15 May 2025
- 2025SWE-Synth: Synthesizing Verifiable Bug-Fix Data to Enable Large Language Models in Resolving Real-World Bugs20 Apr 2025
- 2025XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistants18 Mar 2025
- 2024MdEval: Massively Multilingual Code Debugging4 Nov 2024
- 2024Learning Code Preference via Synthetic Evolution4 Oct 2024
12 newest of 16 All 16 (JSON)