← Latest papers
🤖 machine learning

Delulu: A Verified Multi-Lingual Benchmark for Code Hallucination Detection in Fill-in-the-Middle Tasks

This paper introduces Delulu, a rigorously verified multi-lingual benchmark comprising 1,951 adversarially curated samples that exposes the persistent vulnerability of state-of-the-art code generation models to producing plausible yet incorrect hallucinations in Fill-in-the-Middle tasks.

Original authors: Mahdi Erfanian, Nelson Daniel Troncoso, Aashna Garg, Amabel Gale, Xiaoyu Liu, Pareesa Ameneh Golnari, Shengyu Fu

Published 2026-05-11
📖 5 min read🧠 Deep dive

Original authors: Mahdi Erfanian, Nelson Daniel Troncoso, Aashna Garg, Amabel Gale, Xiaoyu Liu, Pareesa Ameneh Golnari, Shengyu Fu

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are hiring a very smart, but slightly overconfident, junior programmer to help you write code. This programmer is great at guessing what comes next in a sentence, but sometimes, when they don't know the answer, they just make something up that sounds perfect.

This paper introduces a new "exam" called DELULU designed to catch these made-up answers, known as hallucinations, specifically when the programmer is filling in the middle of a code snippet (a task called "Fill-in-the-Middle").

Here is the breakdown of the paper using simple analogies:

1. The Problem: The "Confident Liar"

In the world of coding AI, models are often tested on whether they can write a whole function from scratch. But in the real world, AI assistants (like GitHub Copilot) mostly work by looking at the code before and after a gap and filling in the middle.

The problem is that these AIs are like confident liars. They might invent a library that doesn't exist, call a function that isn't real, or use a variable name that hasn't been defined.

  • The Trap: The code looks perfect to a human eye (it's grammatically correct). It reads like a normal sentence. But when you try to run it, it crashes because the AI made up a fact.
  • The Goal: The authors wanted to know: Can current AI models reliably avoid making these lies? And if they do lie, can other AI models spot the lie?

2. The Solution: The "DELULU" Exam

The authors built a benchmark (a test set) called DELULU. The name is a play on internet slang for "delusional," because these AI hallucinations are often very convincing.

Think of DELULU as a giant, automated trap set for AI models.

  • The Setup: They took real code from the internet and created 1,951 "traps."
  • The Traps: For every correct piece of code (the "Golden" answer), they used a super-smart AI to create a "Hallucinated" version. This fake version changed just one tiny thing to make it wrong, but kept it looking plausible.
    • Example: Changing a real import from pandas import read_csv to a fake one from pandas import read_csvs.
  • The 4 Types of Lies: The exam focuses on four specific ways AI gets it wrong:
    1. Method: Inventing a function name (e.g., df.remove_nulls() when that function doesn't exist).
    2. Parameter: Adding a setting that doesn't exist (e.g., print(text, color="blue") when the function doesn't accept colors).
    3. Undefined Variable: Using a name that was never created.
    4. Import: Trying to load a software package that doesn't exist.

3. How They Built the Exam (The "Adversarial Pipeline")

They didn't just guess the questions; they built a rigorous factory to ensure the questions were hard and the answers were real.

  1. Generation: An AI created the fake, lying code.
  2. The "Judge" Panel: Four different super-AIs acted as teachers to grade the fake code. If a teacher couldn't tell the lie from the truth, the question was kept. If the teacher spotted it easily, the question was thrown out.
  3. The "Reality Check" (Docker): This is the most important part. They didn't just trust the teachers. They put every single code snippet into a virtual sandbox (a Docker container) and tried to run it.
    • If the "Golden" code ran successfully, it stayed.
    • If the "Hallucinated" code crashed with the exact error the exam was looking for (like "File not found" or "Variable not defined"), it stayed.
    • If the fake code didn't actually crash, it was thrown out.
  4. Human Review: Finally, human experts looked at the remaining questions to make sure they weren't too easy or biased.

4. The Results: The AI is Still Struggling

The authors tested 11 different AI models (ranging from small to very large) on this exam.

  • The Score: Even the best AI model only got about 84.5% of the answers right. That means it still fell for the trap on roughly 1 out of every 6 questions.
  • The Hardest Trap: The "Import" lies (making up fake software packages) were the hardest for the AIs to avoid. It's like asking them to memorize a phone book of every software library in existence; they keep guessing names that sound real but aren't.
  • The Detection Problem: They also asked: "Can an AI act as a code reviewer and spot these lies?" Even the smartest AI reviewers only caught the lies about 92% of the time. This means there is still a gap where a lie can slip through the cracks.

5. Why This Matters

The paper concludes that this is a fundamental problem, not just a bug in one specific AI model.

  • It's not just about size: Making the AI bigger helps, but it doesn't solve the problem completely.
  • It's not just about training: Different families of AI models all struggled with the same types of lies.
  • The Takeaway: We cannot rely on AI to write code without checking it, because even the best AIs are still "delusional" enough to invent facts that crash your program.

In short: DELULU is a rigorous, multi-language test that proves current AI code assistants are still prone to making up facts that look real but break when you try to run them. The paper provides the tools (the test and the "sandbox" containers) for developers to measure and improve this specific weakness.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →