Task Abstention for Large Language Models in Code Generation

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Zhou, Yanke, Tan, Yuhao, Xu, Senrong, Li, Zenan, Yao, Yuan, Chen, Taolue, Ma, Xiaoxing
Natura: Preprint
Pubblicazione: 2026
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866917503361351680
author Zhou, Yanke
Tan, Yuhao
Xu, Senrong
Li, Zenan
Yao, Yuan
Chen, Taolue
Ma, Xiaoxing
author_facet Zhou, Yanke
Tan, Yuhao
Xu, Senrong
Li, Zenan
Yao, Yuan
Chen, Taolue
Ma, Xiaoxing
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2605_17029
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Task Abstention for Large Language Models in Code Generation
Zhou, Yanke
Tan, Yuhao
Xu, Senrong
Li, Zenan
Yao, Yuan
Chen, Taolue
Ma, Xiaoxing
Software Engineering
Artificial Intelligence
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.
title Task Abstention for Large Language Models in Code Generation
topic Software Engineering
Artificial Intelligence
url https://arxiv.org/abs/2605.17029