paper-with-me

홈 › Papers

CodeMirage: Hallucinations in Code Generated by Large Language Models

2024-08-14 · Vibhor Agarwal, Yulong Pei, Salwa Alamir, Xiaomo Liu

Large Language Models (LLMs) have shown promising potentials in program generation and no-code automation. However, LLMs are prone to generate hallucinations, i.e., they generate text which sounds plausible but is incorrect. Although there has been a recent surge in research on LLM hallucinations for text generation, similar hallucination phenomenon can happen in code generation. Sometimes the generated code can have syntactical or logical errors as well as more advanced issues like security vulnerabilities, memory leaks, etc. Given the wide adaptation of LLMs to enhance efficiency in code generation and development in general, it becomes imperative to investigate hallucinations in code generation. To the best of our knowledge, this is the first attempt at studying hallucinations in the code generated by LLMs. We start by introducing the code hallucination definition and a comprehensive taxonomy of code hallucination types. We propose the first benchmark CodeMirage dataset for code hallucinations. The benchmark contains 1,137 GPT-3.5 generated hallucinated code snippets for Python programming problems from two base datasets - HumanEval and MBPP. We then propose the methodology for code hallucination detection and experiment with open source LLMs such as CodeLLaMA as well as OpenAI's GPT-3.5 and GPT-4 models using one-shot prompt. We find that GPT-4 performs the best on HumanEval dataset and gives comparable results to the fine-tuned CodeBERT baseline on MBPP dataset. Towards the end, we discuss various mitigation strategies for code hallucinations and conclude our work.

📄 PDF Abstract BibTeX arXiv:2408.08333

Code (0)

등록된 구현이 없습니다.

Tasks

Code GenerationHallucinationHumanEvalmbppText Generation

Methods 이 논문이 사용한 방법론

Refunds@Expedia|||How do I get a full refund from Expedia? “How do I get a full refund from Expedia? How do I get a full refund from Expedia? – Call ☎️ +1-(888) 829 (0881) or +1-805-330-4056 or +1-805-330-4056 for Quick Help &…
Cosine Annealing Cosine Annealing is a type of learning rate schedule that has the effect of starting with a large learning rate that is relatively rapidly decreased to a minimum value before…
Weight Decay 설명 없음
Position-Wise Feed-Forward Layer 설명 없음
Adam 설명 없음
BPE Byte Pair Encoding, or BPE, is a subword segmentation algorithm that encodes rare and unknown words as sequences of subword units. The intuition is that various word…
Absolute Position Encodings Absolute Position Encodings are a type of position embeddings for [Transformer-based models] where positional encodings are…
CodeBERT 설명 없음

Similar Papers 제목 키워드 기반

CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMs

2025-05-27 · Hanxi Guo, Siyuan Cheng, Kaiyuan Zhang, Guangyu Shen 외

Large language models (LLMs) have become integral to modern software development, producing vast amounts of AI-generated source code. While these models boost programming productivity, their misuse introduces critical ri…

Hallucinations in Code Change to Natural Language Generation: Prevalence and Evaluation of Detection Metrics

2025-08-12 · Chunhua Liu, Hong Yi Lin, Patanamon Thongtanunam arxiv

Language models have shown strong capabilities across a wide range of tasks in software engineering, such as code generation, yet they suffer from hallucinations. While hallucinations have been studied independently in n…

Code Generation

Exploring and Evaluating Hallucinations in LLM-Powered Code Generation

2024-04-01 · Fang Liu, Yang Liu, Lin Shi, Houkun Huang 외

The rise of Large Language Models (LLMs) has significantly advanced many applications on software engineering tasks, particularly in code generation. Despite the promising performance, LLMs are prone to generate hallucin…

Code GenerationHallucinationHallucination EvaluationHumanEval+1

Library Hallucinations in LLM-Generated Code: A Risk Analysis Grounded in Developer Queries

2025-09-26 · Lukas Twist, Jie M. Zhang, Mark Harman, Helen Yannakoudakis arxiv

Large language models (LLMs) now play a central role in code generation, yet they continue to hallucinate, frequently inventing non-existent libraries. Such library hallucinations are not just benign errors: they can mis…

Code Generation

Collu-Bench: A Benchmark for Predicting Language Model Hallucinations in Code

2024-10-13 · Nan Jiang, Qi Li, Lin Tan, Tianyi Zhang

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 incl…

Code GenerationHallucinationLanguage ModelingLanguage Modelling+1