Task Abstention for Large Language Models in Code Generation

Yanke Zhou, Yuhao Tan, Senrong Xu, Zenan Li, Yuan Yao +2 more
5/16/2026
cs.SEcs.AI

No confident code implementation found for this paper.

Abstract

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{zhou2026task,
  title  = {Task Abstention for Large Language Models in Code Generation},
  author = {Yanke Zhou and Yuhao Tan and Senrong Xu and Zenan Li and Yuan Yao and Taolue Chen and Xiaoxing Ma},
  year   = {2026},
  eprint = {2605.17029},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2605.17029v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2605.17029.svg)](https://codeofpaper.com/paper/2605.17029)

Discussion