TL;DR
DELULU is a new multi-lingual benchmark designed to catch code hallucinations in Fill-in-the-Middle (FIM) tasks—where AI assistants generate code between an existing prefix and suffix. By evaluating models across 7 languages and 4 distinct error types using an adversarial pipeline and execution-based Docker verification, the authors reveal that avoiding and detecting these plausible-sounding runtime errors remains an unsolved challenge for even the most advanced Large Language Models (LLMs).
What Problem Does This Paper Address?
AI code assistants like GitHub Copilot and Cursor heavily rely on the Fill-in-the-Middle (FIM) paradigm to autocomplete code within a file. However, FIM models frequently suffer from "hallucinations"—generating code completions that look perfectly natural and syntactically valid to a human reviewer but reference non-existent libraries, fake API methods, or undefined variables. These errors slip past superficial code reviews and only manifest as disruptive crashes at runtime.
Existing code benchmarks fall short because they are largely Python-only, lack execution-based verification for the infilling task itself, or fail to categorize different types of hallucinations. The authors introduce DELULU to fill this gap, providing a rigorous framework to test whether models can reliably generate hallucination-free code and whether frontier LLMs can successfully act as automated code reviewers to detect them.
Methods
The authors developed a rigorous five-stage adversarial curation pipeline to build a benchmark of truly challenging, non-trivial code samples:
- Hallucination Generation: Real-world code snippets are mined from public GitHub repositories, and a frontier model (Claude Sonnet) generates a highly plausible but hallucinated counterpart by changing exactly one element.
- Multi-Model Judging: A panel of four diverse LLM judges (including GPT-5.2 and GLM-4.7) evaluates the pairs.
- Adversarial Sampling: The pipeline clusters judge failures using embeddings to identify where the models are easily fooled, then mines the codebase for more examples matching those exact blind spots.
- Difficulty Selection: Easy samples are filtered out, keeping only those that successfully trick the judge models.
- Docker Execution Verification: To eliminate label noise, every sample is executed inside a per-language Docker container. The "golden" completion must compile and run perfectly, while the hallucinated variant must trigger the exact expected runtime error class.
Finally, human experts review every single sample to eliminate any remaining bias or formatting artifacts.
Datasets
The paper introduces the DELULU benchmark, which consists of 1,951 execution-verified FIM samples.
Unlike previous single-language or generation-from-specification suites, DELULU spans:
- 7 Programming Languages: TypeScript, Python, Go, Rust, C#, Java, and C++.
- 4 Hallucination Categories: Method (invented methods), Parameter (invalid keyword arguments), Undefined Variable (out-of-scope references), and Import (non-existent modules).
Compared to existing FIM benchmarks, DELULU features significantly higher structural and control-flow complexity, boasting a much higher average cyclomatic complexity.
Key Insights and Ideas
- Ecosystem Knowledge vs. Local Context: Across all scales and model families, Import hallucinations proved to be the hardest to avoid and detect. While tracking undefined variables can be solved via local scope reasoning, verifying an import requires deep, memorized knowledge of an entire package ecosystem.
- The Illusion of Instruction Tuning: Instruction tuning significantly improves a model's ability to know when to stop writing (boundary detection), which prevents messy over-generation. However, it does not fix the underlying knowledge gaps that cause a model to hallucinate fake APIs in the first place.
- Task-Intrinsic Difficulty: The difficulty of DELULU is family-invariant. Whether testing Qwen, CodeLlama, DeepSeek, or StarCoder, every model family consistently generated hallucination-aligned completions on a non-trivial share of samples.
Key Results
- Generation Performance: The strongest model evaluated, Qwen2.5-Coder-32B-Instruct, achieved a maximum of only 84.5% pass@1, still failing on roughly one out of every seven unique FIM contexts. Smaller models (under 1.5B parameters) struggled completely, showing a clear capability threshold for semantic understanding.
- Detection Performance: When reframed as an LLM-judge code review task, even the most capable frontier model (Claude-4.5-Opus) failed to achieve perfection, topping out at 92.1% both-correct accuracy and missing roughly 6% of hallucinated completions. Smaller production models like GPT-4o-mini performed barely better than a coin flip at 52.3%.
Limitations and Future Work
The authors openly acknowledge several boundaries to their current work:
- Standalone-File Constraint: To keep Docker containers lightweight and self-contained, the benchmark only includes files whose dependency graphs can be resolved within a single file, omitting complex multi-file or repository-level context.
- Scoped Taxonomy: The benchmark focuses purely on knowledge-level hallucinations that throw clear runtime errors, intentionally excluding silent logic flaws, type mismatches, or deprecated API usages.
- Temporal Validity: The dataset represents an ecosystem snapshot from October 2025. As package ecosystems evolve, some hallucinated imports might eventually become valid packages. The authors plan to address this with periodic refreshes and an expanded release.
Summary updated