Pith. sign in

REVIEW 10 cited by

CodeMirage: Hallucinations in Code Generated by Large Language Models

Not yet reviewed by Pith; the record is open.

This paper has not been read by Pith yet. Machine review is queued; the pith claim, tier, and objections will appear here once it completes.

SPECIMEN: schema-true, not a live event

T0 review · schema-true

One-sentence machine reading of the paper's core claim.

pith:XXXXXXXX · record.json · timestamp

arxiv 2408.08333 v2 pith:WUKZ2IMV submitted 2024-08-14 cs.SE cs.AIcs.CL

CodeMirage: Hallucinations in Code Generated by Large Language Models

classification cs.SE cs.AIcs.CL
keywords codehallucinationsgenerationllmsgeneratedhallucinationdatasetmodels
verification ladder T0 review T1 audit T2 compute T3 formal T4 reserved
0 comments
Share X Bluesky LinkedIn Reddit HN
read the original abstract

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.

discussion (0)

Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.

Forward citations

Cited by 10 Pith papers

Reviewed papers in the Pith corpus that reference this work. Sorted by Pith novelty score.

  1. When LLMs Invent Rust Crates: An Empirical Study of Hallucination Patterns and Mitigation

    cs.SE 2026-06 unverdicted novelty 7.0

    First empirical study shows crate hallucination in Rust LLMs has consistent rates across models insensitive to parameters and tests prompt-based mitigation.

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

    cs.SE 2025-09 unverdicted novelty 7.0

    A study of seven LLMs finds that realistic prompt variations such as one-character misspellings trigger library hallucinations in up to 26% of cases, fabricated names in up to 99%, and time-based prompts in up to 85%,...

  3. Code-MUE: Measuring Code LLMs' Uncertainty through Execution-based Semantic Interaction Graphs

    cs.SE 2026-07 conditional novelty 6.0

    Code-MUE estimates code-LLM uncertainty by executing sampled programs on synthetic inputs and computing the Von Neumann entropy of a behavioral-agreement graph, reporting Spearman correlations as strong as -0.98 with ...

  4. FASE: Fast Adaptive Semantic Entropy for Code Quality

    cs.SE 2026-06 unverdicted novelty 6.0

    FASE approximates functional correctness via MST on structural and semantic dissimilarity graphs, reporting 25% better Spearman correlation and 19% better ROCAUC than LLM-based semantic entropy at 0.3% runtime cost on...

  5. Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Code

    cs.SE 2026-05 accept novelty 6.0

    A review of 114 studies creates taxonomies for code and data quality issues, formalizes 18 propagation mechanisms from training data defects to LLM-generated code defects, and synthesizes detection and mitigation techniques.

  6. ALL-FEM: Agentic Large Language models Fine-tuned for Finite Element Methods

    cs.CE 2026-01 unverdicted novelty 6.0

    ALL-FEM fine-tunes LLMs on a corpus of verified FEniCS scripts and uses multi-agent workflows to automate finite element code generation, achieving 71.79% success on 39 benchmarks across elasticity, flow, and coupled ...

  7. Code-MUE: Measuring Code LLMs' Uncertainty through Execution-based Semantic Interaction Graphs

    cs.SE 2026-07 conditional novelty 5.5

    Code-MUE measures Code LLM uncertainty via execution-based Semantic Interaction Graphs and Von Neumann entropy, correlating strongly with functional correctness on eight models.

  8. MAFIG: Multi-agent Driven Formal Instruction Generation Framework

    cs.AI 2026-04 unverdicted novelty 5.0

    MAFIG uses a Perception Agent and Emergency Decision Agent plus span-focused local distillation to let lightweight models rapidly generate formal instructions that fix local scheduling failures, achieving over 94% suc...

  9. Securing LLM-Generated Embedded Firmware through AI Agent-Driven Validation and Patching

    cs.CR 2025-09 reject novelty 5.0

    An iterative fuzz-test, static-analysis, and LLM-patch loop with three AI agents is claimed to raise firmware vulnerability remediation from 67.3% to 92.4% in QEMU-run FreeRTOS tasks.

  10. Vibe coding for clinicians: democratising bespoke software development for digital health innovation

    cs.HC 2026-04 unverdicted novelty 3.0

    Vibe coding enables clinicians to prototype digital health tools by prompting LLMs in natural language, democratizing bespoke software development.