Collu-Bench: A Benchmark for Predicting Language Model Hallucinations in Code
Preprint
Abstract
Despite their success, large language models (LLMs) face the critical challenge of hallucinations, generating plausible but incorrect content. While much research has focused on hallucinations in multiple modalities including images and natural language text, less attention has been given to hallucinations in source code, which leads to incorrect and vulnerable code that causes significant financial loss. To pave the way for research in LLMs' hallucinations in code, we introduce Collu-Bench, a benchmark for predicting code hallucinations of LLMs across code generation (CG) and automated program repair (APR) tasks. Collu-Bench includes 13,234 code hallucination instances collected from five datasets and 11 diverse LLMs, ranging from open-source models to commercial ones. To better understand and predict code hallucinations, Collu-Bench provides detailed features such as the per-step log probabilities of LLMs' output, token types, and the execution feedback of LLMs' generated code for in-depth analysis. In addition, we conduct experiments to predict hallucination on Collu-Bench, using both traditional machine learning techniques and neural networks, which achieves 22.03 -- 33.15% accuracy. Our experiments draw insightful findings of code hallucination patterns, reveal the challenge of accurately localizing LLMs' hallucinations, and highlight the need for more sophisticated techniques.Keywords
All Related Versions
This publication has 20 references indexed in Scilit:
- AutoCodeRover: Autonomous Program Improvement2024
- Pre-Trained Language Models for Text Generation: A SurveyACM Computing Surveys, 2024
- Natural Language to Code: How Far Are We?2023
- Impact of Code Language Models on Automated Program Repair2023
- Automated Program Repair in the Era of Large Pre-trained Language Models2023
- SkCoder: A Sketch-based Approach for Automatic Code Generation2023
- Survey of Hallucination in Natural Language GenerationACM Computing Surveys, 2023
- Competition-level code generation with AlphaCodeScience, 2022
- Defects4J: a database of existing faults to enable controlled testing studies for Java programs2014
- Gradient-based learning applied to document recognitionProceedings of the IEEE, 1998