SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2408.12325 · 2024

Improving Factuality in Large Language Models via Decoding-Time Hallucinatory and Truthful Comparators

arXiv · PDF · Open in the Atlas

Code that ran

11 of 11 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; 11 failures of our instrument; 0 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/2408.12325.json · badge: /api/ran/2408.12325.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
ydk122024/cdt canonical (classifier label)
classifier basis: census
11 ran · 0 no recorded run
FunctionStatusWhere it lives
build_prompt Ran
ran; our contract draft was wrong, not the code
ydk122024/cdt/src/benchmark_evaluation/alpaca_eval.py
code served (permissive licence) · get_code("b13ae15599bf9354")
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
import numpy as np

torch.manual_seed(0)

LLAMA2_PROMPT_RADICAL = {
    'description': 'Llama 2 chat one shot prompt',
    'prompt': '[INST] <<SYS>>\nYou are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe.  Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\n\n<</SYS>>\n\n{instruction} [/INST]'
}

ARGS = {
    'user_query': 'What is the capital of France?',
    'response': 'The capital of France is Paris.',
    'is_chat': False,
    'prompt': LLAMA2_PROMPT_RADICAL
}
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 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
build_prompt Ran
ran; our contract draft was wrong, not the code
ydk122024/cdt/src/benchmark_evaluation/knight_eval.py
code served (permissive licence) · get_code("a3be7b801f8fda87")
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
import numpy as np

LLAMA2_PROMPT_RADICAL = {'description': 'Llama 2 chat one shot prompt', 'prompt': '[INST] <<SYS>>\nYou are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe.  Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\n\n<</SYS>>\n\n{instruction} [/INST]'}

def build_prompt(knowledge, dialog, response, is_chat=False, prompt=LLAMA2_PROMPT_RADICAL):
    input_text_prompt = 'You are a response judge. You MUST determine if the provided response contains non-factual or hallucinated information. The answer you give MUST be "Yes" or "No"' + '\n#Knowledge#: ' + knowledge + '\n#Dialogue History#: ' + dialog + '\n#Response#: ' + response + '\n#Your Judgement#: '
    if is_chat:
        input_text_prompt = prompt['prompt'].format(instruction=input_text_prompt)
    return input_text_prompt

ARGS = {
    'knowledge': 'The Earth orbits the Sun.',
    'dialog': 'User: What does the Earth orbit?\nAssistant: The Earth orbits the Sun.',
    'response': 'The Earth orbits the Sun.',
    'is_chat': True,
    'prompt': LLAMA2_PROMPT_RADICAL
}
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 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
build_prompt Ran
ran; our contract draft was wrong, not the code
ydk122024/cdt/src/benchmark_evaluation/xsum_eval.py
code served (permissive licence) · get_code("d80c60be83bb2afa")
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
import numpy as np

LLAMA2_PROMPT_RADICAL = {'description': 'Llama 2 chat one shot prompt', 'prompt': '[INST] <<SYS>>\nYou are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe.  Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\n\n<</SYS>>\n\n{instruction} [/INST]'}

def build_prompt(input_text, is_chat=False, prompt=LLAMA2_PROMPT_RADICAL):
    input_text_prompt = 'Please complete the extreme summary of the following document in one short sentence: ' + 'Document: ' + input_text + '\n' + 'Summary:'
    if is_chat:
        input_text_prompt = prompt['prompt'].format(instruction=input_text_prompt)
    return input_text_prompt

ARGS = {
    'input_text': 'The quick brown fox jumps over the lazy dog. This is a sample document for testing.',
    'is_chat': True,
    'prompt': LLAMA2_PROMPT_RADICAL
}
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 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
build_prompt_gen Ran
ran; our contract draft was wrong, not the code
ydk122024/cdt/src/benchmark_evaluation/alpaca_eval.py
code served (permissive licence) · get_code("f2d73dda9e665c06")
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
import torch.nn as nn

torch.manual_seed(0)

LLAMA2_PROMPT_RADICAL = {'description': 'Llama 2 chat one shot prompt', 'prompt': '[INST] <<SYS>>\nYou are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe.  Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\n\n<</SYS>>\n\n{instruction} [/INST]'}

ARGS = {
    'user_query': 'What is machine learning?',
    'is_chat': False,
    'prompt': LLAMA2_PROMPT_RADICAL
}
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
build_prompt_gen Ran
ran; our contract draft was wrong, not the code
ydk122024/cdt/src/benchmark_evaluation/knight_eval.py
code served (permissive licence) · get_code("27d49354a7eee2e1")
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)

LLAMA2_PROMPT_RADICAL = {'description': 'Llama 2 chat one shot prompt', 'prompt': '[INST] <<SYS>>\nYou are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe.  Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\n\n<</SYS>>\n\n{instruction} [/INST]'}

ARGS = {
    'knowledge': 'The Earth orbits the Sun every 365 days.',
    'dialog': 'Q: How long does Earth take to orbit the Sun?\nA: ',
    'is_chat': False,
    'prompt': LLAMA2_PROMPT_RADICAL
}
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
build_prompt_no_yes Ran
ran; our contract draft was wrong, not the code
ydk122024/cdt/src/benchmark_evaluation/alpaca_eval.py
code served (permissive licence) · get_code("6439303c87d1473a")
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
import numpy as np

LLAMA2_PROMPT_RADICAL = {'description': 'Llama 2 chat one shot prompt', 'prompt': '[INST] <<SYS>>\nYou are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe.  Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\n\n<</SYS>>\n\n{instruction} [/INST]'}

torch.manual_seed(0)

ARGS = {
    'user_query': 'What is the capital of France?',
    'response': 'The capital of France is Paris, located in the northern part of the country.',
    'is_chat': False,
    'prompt': LLAMA2_PROMPT_RADICAL
}
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 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
format_best Ran
ran; our contract draft was wrong, not the code
ydk122024/cdt/src/benchmark_evaluation/truthfulqa_eval.py
pointer only (licence: MIT); the stored copy get_code serves, from hoeng4/PruneCD, is pointer only (licence: NONE) · get_code("158b8847881a64b3")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from hoeng4/PruneCD, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

is_torch_tpu_available Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ydk122024/cdt/src/peft/import_utils.py
pointer only (licence: MIT); the stored copy get_code serves, from juyongjiang/KaSA, is pointer only (licence: NONE) · get_code("a3daaf3e5bdfc709")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from juyongjiang/KaSA, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

load_csv Ran
ran; our contract draft was wrong, not the code
ydk122024/cdt/src/benchmark_evaluation/truthfulqa_eval.py
pointer only (licence: MIT); the stored copy get_code serves, from hoeng4/PruneCD, is pointer only (licence: NONE) · get_code("2a4c0ecd291e1795")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from hoeng4/PruneCD, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

load_jsonl Ran
ran; our contract draft was wrong, not the code
ydk122024/cdt/src/benchmark_evaluation/knight_eval.py
code served (permissive licence) · get_code("b6224b7268dbdb06")
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 json
import tempfile
import os

# Create a temporary JSONL file for testing
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.jsonl")

# Write valid JSON data to the file
test_data = [
    {"id": 1, "text": "hello"},
    {"id": 2, "text": "world"},
    {"id": 3, "text": "test"}
]

with open(temp_file, 'w') as f:
    json.dump(test_data, f)

ARGS = {
    "fp": temp_file
}
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 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
split_multi_answer Ran
ran; our contract draft was wrong, not the code
ydk122024/cdt/src/benchmark_evaluation/truthfulqa_eval.py
pointer only (licence: MIT); the stored copy get_code serves, from hoeng4/PruneCD, is pointer only (licence: NONE) · get_code("c852bd4d2face0a1")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from hoeng4/PruneCD, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 1 the same month, 4 later) and 7 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_best 7 other papers
3 dated earlier, 4 later
2312.04333 (2023-12)
Is Bigger and Deeper Always Better? Probing LLaMA Across Scales and Layers
2312.15710 (2023-12)
Alleviating Hallucinations of Large Language Models through Induced Hallucinations
2401.05930 (2024-01)
SH2: Self-Highlighted Hesitation Helps You Decode More Truthfully
and 4 more not named here
is_torch_tpu_available 6 other papers
3 dated earlier, 1 the same month, 2 later
2404.04316 (2024-04)
Parameter Efficient Quasi-Orthogonal Fine-Tuning via Givens Rotation
2405.12130 (2024-05)
MoRA: High-Rank Updating for Parameter-Efficient Fine-Tuning
2406.12629 (2024-06)
SeTAR: Out-of-Distribution Detection with Selective Low-Rank Approximation
and 3 more not named here
load_csv 6 other papers
3 dated earlier, 3 later
2312.04333 (2023-12)
Is Bigger and Deeper Always Better? Probing LLaMA Across Scales and Layers
2312.15710 (2023-12)
Alleviating Hallucinations of Large Language Models through Induced Hallucinations
2401.05930 (2024-01)
SH2: Self-Highlighted Hesitation Helps You Decode More Truthfully
and 3 more not named here
split_multi_answer 6 other papers
3 dated earlier, 3 later
2312.04333 (2023-12)
Is Bigger and Deeper Always Better? Probing LLaMA Across Scales and Layers
2312.15710 (2023-12)
Alleviating Hallucinations of Large Language Models through Induced Hallucinations
2401.05930 (2024-01)
SH2: Self-Highlighted Hesitation Helps You Decode More Truthfully
and 3 more not named here

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

Despite their remarkable capabilities, Large Language Models (LLMs) are prone to generate responses that contradict verifiable facts, i.e., unfaithful hallucination content. Existing efforts generally focus on optimizing model parameters or editing semantic representations, which compromise the internal factual knowledge of target LLMs. In addition, hallucinations typically exhibit multifaceted patterns in downstream tasks, limiting the model's holistic performance across tasks. In this paper, we propose a Comparator-driven Decoding-Time (CDT) framework to alleviate the response hallucination. Firstly, we construct hallucinatory and truthful comparators with multi-task fine-tuning samples. In this case, we present an instruction prototype-guided mixture of experts strategy to enhance the ability of the corresponding comparators to capture different hallucination or truthfulness patterns in distinct task instructions. CDT constrains next-token predictions to factuality-robust distributions by contrasting the logit differences between the target LLMs and these comparators. Systematic experiments on multiple downstream tasks show that our framework can significantly improve the model performance and response factuality.

For agents

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

get_harvested_code_for_paper("2408.12325")
get_code_for_paper("2408.12325")
have("2408.12325")

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

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

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

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

Connect an agent — have() is free.