SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2312.14183 · 2023

On Early Detection of Hallucinations in Factual Question Answering

arXiv · PDF · Open in the Atlas

Code that ran

4 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; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 4 failures of our instrument; 2 no recorded run), measured 2026-11-23; 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/2312.14183.json · badge: /api/ran/2312.14183.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
amazon-science/llm-hallucinations-factual-qa canonical (classifier label)
classifier basis: census
4 ran · 2 no recorded run
FunctionStatusWhere it lives
collect_entry Ran
ran; our contract draft was wrong, not the code
amazon-science/llm-hallucinations-factual-qa/trex_parser.py
code served (permissive licence) · get_code("dda2b409090219b0")
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
from pathlib import Path

triplet = {
    'predicate': {
        'surfaceform': 'knows',
        'uri': 'http://example.com/knows',
        'annotator': 'annotator1'
    },
    'object': {
        'surfaceform': 'Alice',
        'uri': 'http://example.com/person/Q123',
        'annotator': 'annotator2'
    },
    'subject': {
        'surfaceform': 'Bob',
        'uri': 'http://example.com/person/Q456',
        'annotator': 'annotator3'
    }
}

ARGS = {
    'triplet': triplet
}
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 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
extract_all_triples Ran
ran; our contract draft was wrong, not the code
amazon-science/llm-hallucinations-factual-qa/trex_parser.py
code served (permissive licence) · get_code("5dd1176e0c6702d1")
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 DataFrame. 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 json
from pathlib import Path
import tempfile
import os

# Create a temporary JSON file with valid T-Rex data
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "t_rex_sample.json")

# Create sample T-Rex data structure
sample_data = [
    {
        "triples": [
            {
                "subject": {
                    "surfaceform": "Albert Einstein",
                    "uri": "http://www.wikidata.org/entity/Q937",
                    "annotator": "annotator1"
                },
                "predicate": {
                    "surfaceform": "born in",
                    "uri": "http://www.wikidata.org/entity/P19",
                    "annotator": "annotator1"
                },
                "object": {
                    "surfaceform": "Ulm",
                    "uri": "http://www.wikidata.org/entity/Q3174",
                    "annotator": "annotator1"
                }
            },
            {
                "subject": {
                    "surfaceform": "Albert Einstein",
                    "uri": "http://www.wikidata.org/entity/Q937",
                    "annotator": "annotator1"
                },
                "predicate": {
                    "surfaceform": "field of work",
                    "uri": "http://www.wikidata.org/entity/P101",
                    "annotator": "annotator1"
                },
                "object": {
                    "surfaceform": "Physics",
                    "uri": "http://www.wikidata.org/entity/Q413",
                    "annotator": "annotator1"
                }
            }
        ]
    },
    {
        "triples": [
            {
                "subject": {
                    "surfaceform": "Marie Curie",
                    "uri": "http://www.wikidata.org/entity/Q7186",
                    "annotator": "annotator2"
                },
                "predicate": {
                    "surfaceform": "born in",
                    "uri": "http://www.wikidata.org/entity/P19",
                    "annotator": "annotator2"
                },
                "object": {
                    "surfaceform": "Warsaw",
                    "uri": "http://www.wikidata.org/entity/Q270",
                    "annotator": "annotator2"
                }
            }
        ]
    }
]

# Write sample data to temporary file
with open(temp_file, 'w') as f:
    json.dump(sample_data, f)

ARGS = {
    "t_rex_file": temp_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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
filter_subj_obj Ran
ran; our contract draft was wrong, not the code
amazon-science/llm-hallucinations-factual-qa/trex_parser.py
code served (permissive licence) · get_code("5662ca5e5553beeb")
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 DataFrame. 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 pandas as pd
import numpy as np

# Create a sample DataFrame with the required columns
data = {
    'subject_surfaceform': ['John', 'Alice', 'he', 'The Company', None, 'Bob'],
    'object_surfaceform': ['Mary', 'Bob', 'she', 'the Project', 'Object', 'you']
}

df = pd.DataFrame(data)

ARGS = {
    'df': df
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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_next_token Ran
ran; our contract draft was wrong, not the code
amazon-science/llm-hallucinations-factual-qa/result_collector.py
code served (permissive licence) · get_code("68b60a9367249cc7")
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 Tensor, ndim 2, dtype family float, shape (2, 5) 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
import torch.nn as nn

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 5)
    
    def forward(self, x):
        logits = self.linear(x)
        output = type('Output', (), {'logits': logits})()
        return output

model = SimpleModel()
x = torch.randn(2, 4)

ARGS = {
    'x': x,
    'model': model
}
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 Tensor, ndim 2, dtype family float, shape (2, 5) — shape (2, 5) 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
generate_response Not yet run
unverified (harvested, no recorded run)
amazon-science/llm-hallucinations-factual-qa/result_collector.py
code served (permissive licence) · get_code("03559f369dd0f078")
How it ran

no invocation recorded.

load_data Not yet run
unverified (harvested, no recorded run)
amazon-science/llm-hallucinations-factual-qa/result_collector.py
code served (permissive licence) · get_code("975098b74738f343")
How it ran

no invocation recorded.

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

While large language models (LLMs) have taken great strides towards helping humans with a plethora of tasks, hallucinations remain a major impediment towards gaining user trust. The fluency and coherence of model generations even when hallucinating makes detection a difficult task. In this work, we explore if the artifacts associated with the model generations can provide hints that the generation will contain hallucinations. Specifically, we probe LLMs at 1) the inputs via Integrated Gradients based token attribution, 2) the outputs via the Softmax probabilities, and 3) the internal state via self-attention and fully-connected layer activations for signs of hallucinations on open-ended question answering tasks. Our results show that the distributions of these artifacts tend to differ between hallucinated and non-hallucinated generations. Building on this insight, we train binary classifiers that use these artifacts as input features to classify model generations into hallucinations and non-hallucinations. These hallucination classifiers achieve up to $0.80$ AUROC. We also show that tokens preceding a hallucination can already predict the subsequent hallucination even before it occurs.

For agents

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

get_harvested_code_for_paper("2312.14183")
get_code_for_paper("2312.14183")
have("2312.14183")

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

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

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

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

Connect an agent — have() is free.