Task Abstention for Large Language Models in Code Generation
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) have revolutionized automated code generation. One serious concern, however, is the so-called ``hallucination'', i.e., LLMs may generate seemingly plausible but functionally incorrect code. In this paper, we study the task abstention problem, i.e., determining whether a given LLM should abstain from performing a specific code generation task to avoid likely hallucination. Our approach features a calibrated abstention rule, grounded in the principles of multiple hypothesis testing. The rule assesses generation consistency through code execution outcomes, allowing it to handle syntactic diversity of semantically equivalent code without reliance on oracle test cases or external databases. We prove that our approach provides a rigorous, distribution-free theoretical guarantee on its abstention decisions. We evaluate our method on benchmark datasets using several open-source code LLMs. Results show that our method allows generative models to more accurately and efficiently identify and abstain from tasks that induce hallucination compared to existing techniques, providing a reliable mechanism for safer and more robust code generation.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 50 of its 59 references that are in the map. First posted on arXiv 16 May 2026.
Builds on
50 of 59 references.
References · 50
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,601
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Sparks of Artificial General Intelligence: Early experiments with GPT-4cited by 2,579
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2022Language Models (Mostly) Know What They Knowcited by 1,783
- 2023A Survey on Hallucination in Large Language Models: Principles, Taxonomy, Challenges, and Open Questionscited by 1,582
- 2022Competition-Level Code Generation with AlphaCodecited by 1,427
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
- 2024Qwen2.5-Coder Technical Reportcited by 1,151
- 2023Can LLMs Express Their Uncertainty? An Empirical Evaluation of Confidence Elicitation in LLMscited by 946
- 2023Semantic Uncertainty: Linguistic Invariances for Uncertainty Estimation in Natural Language Generationcited by 795
38 more
- 2023Just Ask for Calibration: Strategies for Eliciting Calibrated Confidence Scores from Language Models Fine-Tuned with Human Feedbackcited by 788
- 2023SelfCheckGPT: Zero-Resource Black-Box Hallucination Detection for Generative Large Language Modelscited by 787
- 2022Teaching Models to Express Their Uncertainty in Wordscited by 731
- 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
- 2019Conformal Prediction Under Covariate Shiftcited by 511
- 2023Large Language Models Are Not Robust Multiple Choice Selectorscited by 454
- 2021Adaptive Conformal Inference Under Distribution Shiftcited by 360
- 2022Conformal prediction beyond exchangeabilitycited by 348
- 2022Conformal Risk Controlcited by 290
- 2021Learn then Test: Calibrating Predictive Algorithms to Achieve Risk Controlcited by 256
- 2023A Survey of Confidence Estimation and Calibration in Large Language Modelscited by 253
- 2023Large Language Models for Software Engineering: Survey and Open Problemscited by 178
- 2024Don't Hallucinate, Abstain: Identifying LLM Knowledge Gaps via Multi-LLM Collaborationcited by 176
- 2023Conformal Language Modelingcited by 163
- 2023Shifting Attention to Relevance: Towards the Predictive Uncertainty Quantification of Free-Form Large Language Modelscited by 147
- 2024To Believe or Not to Believe Your LLMcited by 120
- 2024Know Your Limits: A Survey of Abstention in Large Language Modelscited by 116
- 2023R-Tuning: Instructing Large Language Models to Say `I Don't Know'cited by 106
- 2022DisentQA: Disentangling Parametric and Contextual Knowledge with Counterfactual Question Answeringcited by 93
- 2024LLM Hallucinations in Practical Code Generation: Phenomena, Mechanism, and Mitigationcited by 92
- 2023Refining ChatGPT-Generated Code: Characterizing and Mitigating Code Quality Issuescited by 78
- 2023Alignment for Honestycited by 72
- 2022Automated Repair of Programs from Large Language Modelscited by 71
- 2024SynCode: LLM Generation with Grammar Augmentationcited by 66
- 2023The Art of Defending: A Systematic Evaluation and Analysis of LLM Defense Strategies on Safety and Over-Defensivenesscited by 63
- 2024EffiBench: Benchmarking the Efficiency of Automatically Generated Codecited by 62
- 2024Distinguishing the Knowable from the Unknowable with Language Modelscited by 45
- 2023Look Before You Leap: An Exploratory Study of Uncertainty Measurement for Large Language Modelscited by 40
- 2023Learn to Refuse: Making Large Language Models More Controllable and Reliable through Knowledge Scope Limitation and Refusal Mechanismcited by 33
- 2024CodeHalu: Investigating Code Hallucinations in LLMs via Execution-based Verificationcited by 32
- 2024Towards Understanding the Characteristics of Code Generation Errors Made by Large Language Modelscited by 28
- 2024Cycles of Thought: Measuring LLM Confidence through Stable Explanationscited by 27
- 2023RELIC: Investigating Large Language Model Responses using Self-Consistencycited by 23
- 2024CodeMirage: Hallucinations in Code Generated by Large Language Modelscited by 23
- 2023Jailbreaker in Jail: Moving Target Defense for Large Language Modelscited by 14
- 2024De-Hallucinator: Mitigating LLM Hallucinations in Code Generation Tasks via Iterative Groundingcited by 14
- 2024Epistemology of Language Models: Do Language Models Have Holistic Knowledge?cited by 9
- 2025Hallucination by Code Generation LLMs: Taxonomy, Benchmarks, Mitigation, and Challengescited by 9
Built on by
Not cited yet.