SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2605.07024 · 2026

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

Mahdi Erfanian, Aashna Garg, Nelson Daniel, Troncoso Microsoft, Microsoft Pareesa, Ameneh Golnari, Microsoft Shengyu, Fu Microsoft, Amabel Gale, Microsoft Liu

arXiv · PDF · Open in the Atlas

Code that ran

6 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 4 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 2 failures of our instrument; 0 no recorded run), measured 2026-11-23; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2605.07024.json · badge: /api/ran/2605.07024.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
microsoft/delulu canonical (classifier label)
classifier basis: census
6 ran · 0 no recorded run
FunctionStatusWhere it lives
build_user_prompt Ran
ran; our contract draft was wrong, not the code
microsoft/delulu/evaluations/run_delulu_judges.py
code served (permissive licence) · get_code("bd072bee6c3e3420")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

ARGS = {
    "prefix": "def hello_world():\n    print('Hello')",
    "completion": "    return 42",
    "suffix": "\nhello_world()"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
edit_similarity Ran
ran, honoured the contract we drafted
microsoft/delulu/evaluations/run_completion_metrics.py
code served (permissive licence) · get_code("709e9faa24260785")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

ARGS = {
    'a': 'hello',
    'b': 'hallo'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
is_hallucinated_aligned Ran
ran, honoured the contract we drafted
microsoft/delulu/evaluations/run_completion_metrics.py
code served (permissive licence) · get_code("ef6311939e338ba3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Construct arguments for is_hallucinated_aligned function

ARGS = {
    "completion": "hello world",
    "golden": "hello world",
    "hallucinated": "hallo wurld"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
judge_one Ran
ran; our contract draft was wrong, not the code
microsoft/delulu/evaluations/run_delulu_judges.py
code served (permissive licence) · get_code("e523bbf359d5d3cd")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from unittest.mock import Mock

torch.manual_seed(0)

# Build env dict with required keys for different API types
env = {
    'azure_endpoint': 'https://example.openai.azure.com',
    'azure_key': 'test-key-12345',
    'responses_api_version': '2024-02-15-preview',
    'anthropic_key': 'sk-ant-test-key',
    'gemini_key': 'test-gemini-key'
}

# Build a mock client for the 'chat' API
client = Mock()
mock_response = Mock()
mock_choice = Mock()
mock_message = Mock()
mock_message.content = 'Detailed Reasoning: The code is syntactically valid and logically consistent.\nFinal Average Score for Completion: 1'
mock_choice.message = mock_message
mock_response.choices = [mock_choice]
client.chat.completions.create.return_value = mock_response

# Build model_cfg dict with required keys
model_cfg = {
    'deployment': 'gpt-4',
    'api': 'chat',
    'temperature': 0.5
}

# Build test code strings
prefix = 'def add(a, b):\n    return a'
completion = ' + b'
suffix = '\n\nprint(add(1, 2))'

ARGS = {
    'env': env,
    'client': client,
    'model_cfg': model_cfg,
    'prefix': prefix,
    'completion': completion,
    'suffix': suffix
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
requests, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
levenshtein Ran
ran, honoured the contract we drafted
microsoft/delulu/evaluations/run_completion_metrics.py
code served (permissive licence) · get_code("886224736275f977")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

ARGS = {
    "s1": "kitten",
    "s2": "sitting"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_score Ran
ran, honoured the contract we drafted
microsoft/delulu/evaluations/run_delulu_judges.py
code served (permissive licence) · get_code("85a1174c53ba7c3a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def parse_score(text: str) -> int:
    """Strict score parser.

    The judge prompt mandates a final line of the form
    `Final Average Score for Completion: <0 or 1>`; anything else counts as a
    parse failure (return -1) so the caller can flag it instead of silently
    accepting a stray digit from the chain-of-thought as the label.
    """
    m = re.search('Final\\s+Average\\s+Score\\s+for\\s+Completion\\s*:\\s*([01])\\b', text, flags=re.IGNORECASE)
    if m:
        return int(m.group(1))
    return -1


# Test cases for different scenarios
valid_text_0 = "Some reasoning here.\nFinal Average Score for Completion: 0"
valid_text_1 = "Some reasoning here.\nFinal Average Score for Completion: 1"
valid_text_case_insensitive = "Some reasoning here.\nfinal average score for completion: 1"
valid_text_extra_spaces = "Some reasoning here.\nFinal  Average   Score   for   Completion  :  0"
invalid_text_no_match = "Some reasoning here.\nThe score is 1 but not in the right format"
invalid_text_wrong_number = "Some reasoning here.\nFinal Average Score for Completion: 2"

ARGS = {
    "text": valid_text_0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Large Language Models for code generation frequently produce hallucinations in Fill-in-the-Middle (FIM) tasks-plausible but incorrect completions such as invented API methods, invalid parameters, undefined variables, or non-existent imports. These failures pass superficial review yet introduce runtime errors. We introduce DELULU, a verified multi-lingual benchmark of 1,951 FIM samples across 7 languages and 4 hallucination types. Samples are curated through an adversarial pipeline: a frontier LLM generates plausible hallucinations, four diverse judge models evaluate them, embedding-based clustering mines progressively harder examples, self-contained Docker containers verify that golden completions compile while hallucinated variants produce the expected runtime error, and a final human-expert review removes any remaining biased or trivially decidable samples. We evaluate 11 open-weight FIM models from five families spanning 0.5B-32B parameters: a six-point Qwen2.5-Coder scaling slate, plus a cross-family slate (CodeLlama, DeepSeek-Coder-V2, StarCoder2). The strongest model reaches only 84.5% pass@1, no family exceeds 0.77 Edit Similarity, and every family produces hallucination-aligned completions on a non-trivial share of samples, confirming that the difficulty exposed by DELULU is task-intrinsic rather than family-specific. We release the benchmark, containers, and evaluation framework at https://github.com/microsoft/delulu. * Work done during a project at Microsoft CoreAI. 2 "Hallucination" has multiple definitions in the literature, ranging from any factually incorrect generation [Ji et al., 2022] to broader notions of unfaithfulness; in the code setting, taxonomies span logic, specification, and knowledge errors [Lee et al., 2025, Agarwal et al., 2024]. We use the term in the code sense-completions that are syntactically valid and semantically plausible yet reference or rely on facts that are not true of the resolved program context.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2605.07024")
get_code_for_paper("2605.07024")
have("2605.07024")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2605.07024.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2605.07024.svg)](https://syntology.ai/paper/2605.07024)

Connect an agent — have() is free.