SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2403.00425 · ICML · 2024

HALC: Object Hallucination Reduction via Adaptive Focal-Contrast Decoding

Huaxiu Yao, Bo Li, Hongyin Luo, Jiawei Zhou, Zhaorun Chen, Zhuokai Zhao

arXiv · PDF · Open in the Atlas

Code that ran

7 of 12 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 6 failures of our instrument; 5 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; 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/2403.00425.json · badge: /api/ran/2403.00425.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
BillChan226/HALC canonical (classifier label)
classifier basis: census
7 ran · 5 no recorded run
FunctionStatusWhere it lives
calculate_accumulative_score Ran
ran, honoured the contract we drafted
BillChan226/HALC/eval/overall_score.py
code served (permissive licence) · get_code("7b2c045107970859")
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

# Construct valid arguments for calculate_accumulative_score
data = [
    {'image_id': 1, 'answer': True},
    {'image_id': 1, 'answer': False},
    {'image_id': 2, 'answer': True},
    {'image_id': 3, 'answer': False},
    {'image_id': 3, 'answer': False},
]

ARGS = {
    'data': data
}
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
format_inputs Ran
ran; our contract draft was wrong, not the code
BillChan226/HALC/models/claim_generator.py
code served (permissive licence) · get_code("d1ffbb6af3208715")
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 = {
    "question": "What is the capital of France?",
    "answer": "Paris"
}
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
get_answer Ran
ran; our contract draft was wrong, not the code
BillChan226/HALC/models/answerer.py
code served (permissive licence) · get_code("a0c217c9a4b3e68c")
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. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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

torch.manual_seed(0)

class MockProcessor:
    def __call__(self, img, qs, return_tensors=None):
        # Simulates processor behavior: takes image and question, returns dict with tensors
        batch_dict = {
            'input_ids': torch.randint(0, 1000, (1, 8)),
            'attention_mask': torch.ones(1, 8, dtype=torch.long),
            'pixel_values': torch.randn(1, 3, 224, 224),
        }
        return self
    
    def to(self, device, dtype):
        # Returns self to allow chaining
        return self
    
    def keys(self):
        return ['input_ids', 'attention_mask', 'pixel_values']
    
    def __getitem__(self, key):
        if key == 'input_ids':
            return torch.randint(0, 1000, (1, 8))
        elif key == 'attention_mask':
            return torch.ones(1, 8, dtype=torch.long)
        elif key == 'pixel_values':
            return torch.randn(1, 3, 224, 224)
    
    def decode(self, tensor, skip_special_tokens=False):
        # Simulates decoding generated token ids back to text
        return "a cat on a mat"


class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(8, 4)
    
    def generate(self, **kwargs):
        # Returns generated token ids as a tensor
        # Shape: (batch_size, sequence_length)
        return torch.randint(0, 1000, (1, 10))


class MockImage:
    pass


processor = MockProcessor()
model = MockModel()
img = MockImage()
qs = "What is in the image?"

ARGS = {
    'processor': processor,
    'model': model,
    'img': img,
    'qs': qs,
}
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
get_claim Ran
ran; our contract draft was wrong, not the code
BillChan226/HALC/models/claim_generator.py
code served (permissive licence) · get_code("1e1856185896a734")
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 list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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

torch.manual_seed(0)

class MockTokenizer:
    def __call__(self, text, return_tensors=None, padding=None, truncation=None, max_length=None):
        # Return a mock tokenizer output with input_ids
        batch_size = 1
        seq_length = 10
        input_ids = torch.randint(0, 1000, (batch_size, seq_length))
        return MockTokenizerOutput(input_ids)
    
    def batch_decode(self, token_ids, skip_special_tokens=False):
        # Return decoded strings
        batch_size = token_ids.shape[0]
        return [f"decoded_text_{i}" for i in range(batch_size)]

class MockTokenizerOutput:
    def __init__(self, input_ids):
        self.input_ids = input_ids

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.device = torch.device('cpu')
        self.linear = nn.Linear(4, 4)
    
    def generate(self, input_ids, max_length=None, num_beams=None, early_stopping=None):
        # Return mock generated token ids
        batch_size = input_ids.shape[0]
        gen_length = 10
        return torch.randint(0, 1000, (batch_size, gen_length))

# Create instances
tokenizer = MockTokenizer()
model = MockModel()
question = "What is the capital of France?"
answer = "Paris"

ARGS = {
    'tokenizer': tokenizer,
    'model': model,
    'question': question,
    'answer': answer
}
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 list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
get_res Ran
ran; our contract draft was wrong, not the code
BillChan226/HALC/models/questioner.py
code served (permissive licence) · get_code("71e7ce8bf939f5d4")
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 list, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 openai
import time

# Mock the openai module since we can't make real API calls
class MockOpenAI:
    @staticmethod
    def ChatCompletion_create(model, messages, temperature, max_tokens):
        # Return a mock response with properly formatted question & entity pairs
        mock_response = {
            'choices': [
                {
                    'message': {
                        'content': 'What color is the dog?&dog\nWhat color is the cat?&cat'
                    }
                }
            ]
        }
        return mock_response

# Patch openai module
openai.ChatCompletion.create = MockOpenAI.ChatCompletion_create

# Create a simple stand-in NLP object (not actually used in the function body)
class SimpleNLP:
    def __init__(self):
        self.name = "simple_nlp"

nlp = SimpleNLP()

# Test inputs
entity = "dog.cat"
sent = "There is a black dog and a white cat in the image."
max_tokens = 1024

ARGS = {
    'nlp': nlp,
    'entity': entity,
    'sent': sent,
    'max_tokens': max_tokens
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
openai — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
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
read_json_files Ran
ran; our contract draft was wrong, not the code
BillChan226/HALC/eval/overall_score.py
code served (permissive licence) · get_code("dfe001ee99a936e3")
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 tuple. 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 os
import json
import tempfile
import shutil

# Create a temporary directory with test JSON files
temp_dir = tempfile.mkdtemp()

# Create test JSON files with 'halc' in the filename
test_data_1 = [
    {"id": 1, "text": "sample text 1"},
    {"id": 2, "text": "sample text 2"}
]

test_data_2 = [
    {"id": 3, "text": "sample text 3"}
]

# Write test JSON files (JSONL format - one JSON object per line)
with open(os.path.join(temp_dir, 'halc_test_1.json'), 'w') as f:
    for item in test_data_1:
        f.write(json.dumps(item) + '\n')

with open(os.path.join(temp_dir, 'halc_test_2.json'), 'w') as f:
    for item in test_data_2:
        f.write(json.dumps(item) + '\n')

# Also create a file without 'halc' in the name to ensure it's skipped
with open(os.path.join(temp_dir, 'other_file.json'), 'w') as f:
    f.write(json.dumps({"id": 999, "text": "should be ignored"}) + '\n')

ARGS = {
    'folder_path': temp_dir
}
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 tuple — a tuple output has no array shape of its own; none is 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
remove_duplicates Ran
ran; our contract draft was wrong, not the code
BillChan226/HALC/models/questioner.py
code served (permissive licence) · get_code("8a2ce3b99884243a")
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 list, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 numpy as np

torch.manual_seed(0)

# The function remove_duplicates takes a list of tuples where each tuple is (qs, ent)
# It checks if qs is hashable and uses it as a key in a set to detect duplicates
# qs should be something hashable (string, int, tuple, etc.)
# ent can be any object

# Create sample data with some duplicates
res = [
    ("query_string_1", "entity_1"),
    ("query_string_2", "entity_2"),
    ("query_string_1", "entity_3"),  # duplicate qs
    ("query_string_3", "entity_4"),
    ("query_string_2", "entity_5"),  # duplicate qs
]

ARGS = {
    "res": res
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
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
find_most_similar_strings Not yet run
unverified (harvested, no recorded run)
BillChan226/HALC/decoder_zoo/HALC/context_density/detector.py
code served (permissive licence) · get_code("9528b19eb2cc3b97")
How it ran

no invocation recorded.

get_all_answers Not yet run
unverified (harvested, no recorded run)
BillChan226/HALC/models/answerer.py
code served (permissive licence) · get_code("836aa4874811ce9d")
How it ran

no invocation recorded.

get_output Not yet run
unverified (harvested, no recorded run)
BillChan226/HALC/models/preprocessor.py
code served (permissive licence) · get_code("8122965ad6131653")
How it ran

no invocation recorded.

get_output Not yet run
unverified (harvested, no recorded run)
BillChan226/HALC/models/refiner.py
code served (permissive licence) · get_code("3cc2c9efff7e5609")
How it ran

no invocation recorded.

get_res Not yet run
unverified (harvested, no recorded run)
BillChan226/HALC/models/entity_extractor.py
code served (permissive licence) · get_code("8dbb0079cf7049ec")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 9 are also present in other papers whose code we hold (9 with at least one paper dated earlier, 0 the same month, 0 later) and 3 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.

FunctionAlso present inEarliest-datedOthers named
format_inputs 2 other papers
2 dated earlier
2310.16045 (2023-10)
Woodpecker: Hallucination Correction for Multimodal Large Language Models
2311.13614 (2023-11)
HalluciDoctor: Mitigating Hallucinatory Toxicity in Visual Instruction Data
find_most_similar_strings 1 other paper
1 dated earlier
2310.16045 (2023-10)
Woodpecker: Hallucination Correction for Multimodal Large Language Models
get_all_answers 1 other paper
1 dated earlier
2310.16045 (2023-10)
Woodpecker: Hallucination Correction for Multimodal Large Language Models
get_claim 1 other paper
1 dated earlier
2310.16045 (2023-10)
Woodpecker: Hallucination Correction for Multimodal Large Language Models
get_output 1 other paper
1 dated earlier
2310.16045 (2023-10)
Woodpecker: Hallucination Correction for Multimodal Large Language Models
get_output 1 other paper
1 dated earlier
2310.16045 (2023-10)
Woodpecker: Hallucination Correction for Multimodal Large Language Models
get_res 1 other paper
1 dated earlier
2310.16045 (2023-10)
Woodpecker: Hallucination Correction for Multimodal Large Language Models
get_res 1 other paper
1 dated earlier
2310.16045 (2023-10)
Woodpecker: Hallucination Correction for Multimodal Large Language Models
remove_duplicates 1 other paper
1 dated earlier
2310.16045 (2023-10)
Woodpecker: Hallucination Correction for Multimodal Large Language Models

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-22.

Repositories linked to this paper

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

Abstract

While large vision-language models (LVLMs) have demonstrated impressive capabilities in interpreting multi-modal contexts, they invariably suffer from object hallucinations (OH). We introduce HALC, a novel decoding algorithm designed to mitigate OH in LVLMs. HALC leverages distinct fine-grained optimal visual information in vision-language tasks and operates on both local and global contexts simultaneously. Specifically, HALC integrates a robust auto-focal grounding mechanism (locally) to correct hallucinated tokens on the fly, and a specialized beam search algorithm (globally) to significantly reduce OH while preserving text generation quality. Additionally, HALC can be integrated into any LVLMs as a plug-and-play module without extra training. Extensive experimental studies demonstrate the effectiveness of HALC in reducing OH, outperforming state-of-the-arts across four benchmarks. Code is released at https: //github.com/BillChan226/HALC.

For agents

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

get_harvested_code_for_paper("2403.00425")
get_code_for_paper("2403.00425")
have("2403.00425")

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

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

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

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

Connect an agent — have() is free.