SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2401.10768 · EMNLP · 2024

Knowledge Verification to Nip Hallucination in the Bud

Shuming Shi, Xiaojun Quan, Fanqi Wan, Xinting Huang, Wei Bi, Leyang Cui

arXiv · PDF · Open in the Atlas

Code that ran

17 of 22 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; 17 failures of our instrument; 5 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/2401.10768.json · badge: /api/ran/2401.10768.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
fanqiwan/KCA canonical (classifier label)
classifier basis: census
17 ran · 5 no recorded run
FunctionStatusWhere it lives
calculate_effectiveness_statistic Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/eval/gpt_judge/show_results.py
code served (permissive licence) · get_code("f9e2df54998117c3")
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

torch.manual_seed(0)

# Construct parse_results - a list of dicts with 'judge_score' and 'class' keys
parse_results = [
    {'judge_score': 0.85, 'class': 'A'},
    {'judge_score': 0.92, 'class': 'B'},
    {'judge_score': -100, 'class': 'C'},  # This one will be skipped (error)
    {'judge_score': 0.78, 'class': 'D'},
    {'judge_score': -100, 'class': 'E'},  # Another error case
    {'judge_score': 0.88, 'class': 'F'},
]

ARGS = {
    'parse_results': parse_results
}
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
calculate_hallucination_classification_statistic Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/eval/gpt_judge/show_results.py
code served (permissive licence) · get_code("48f1e29ec994c4e4")
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

torch.manual_seed(0)

# Construct parse_results: a list of dicts with 'judge_score', 'class', and 'judge_result' keys
parse_results = [
    {
        'judge_score': 0.85,
        'class': 'hallucination',
        'judge_result': 'This is a valid result'
    },
    {
        'judge_score': 0.92,
        'class': 'factual',
        'judge_result': 'Another valid result'
    },
    {
        'judge_score': -100,
        'class': 'hallucination',
        'judge_result': 'Recovered from error score'
    },
    {
        'judge_score': -100,
        'class': 'factual',
        'judge_result': ''
    }
]

ARGS = {
    'parse_results': parse_results
}
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
compute_question_accuracy Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/examination/hallucination/get_metric.py
code served (permissive licence) · get_code("4baef40c64107f17")
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 numpy as np

torch.manual_seed(0)

# Construct valid arguments for compute_question_accuracy
data = [
    {
        'idx': 'q1_test0',
        'correct': 'True'
    },
    {
        'idx': 'q1_test1',
        'correct': 'True'
    },
    {
        'idx': 'q1_test2',
        'correct': 'False'
    },
    {
        'idx': 'q2_test0',
        'correct': 'True'
    },
    {
        'idx': 'q2_test1',
        'correct': 'False'
    },
    {
        'idx': 'q3_test0',
        'correct': 'False'
    }
]

threshold = 0.5

ARGS = {
    'data': data,
    'threshold': threshold
}
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 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
create_prompt_with_llama2_chat_format Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/examination/templates.py
code served (permissive licence) · get_code("e51c9713fadad16f")
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

# Define the arguments for create_prompt_with_llama2_chat_format
ARGS = {
    'messages': [
        {'role': 'system', 'content': 'You are a helpful assistant.'},
        {'role': 'user', 'content': 'Hello, how are you?'},
        {'role': 'assistant', 'content': 'I am doing well, thank you for asking.'},
        {'role': 'user', 'content': 'What is your name?'},
        {'role': 'assistant', 'content': 'I am Claude, an AI assistant.'}
    ],
    'bos': '<s>',
    'eos': '</s>',
    'add_bos': True
}
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
create_prompt_with_tulu_chat_format Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/examination/templates.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from thu-keg/crab, is pointer only (licence: NONE) · get_code("697d92a5d51eff3e")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from thu-keg/crab, 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.

dispatch_openai_chat_requesets Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/examination/dispatch_openai_requests.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from thu-keg/crab, is pointer only (licence: NONE) · get_code("dcad9ac62979ca49")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from thu-keg/crab, 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.

dispatch_openai_prompt_requesets Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/examination/dispatch_openai_requests.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from thu-keg/crab, is pointer only (licence: NONE) · get_code("71e4259026911444")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from thu-keg/crab, 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.

dispatch_openai_requests Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/eval/gpt_judge/gpt_judge.py
code served (permissive licence) · get_code("dc4bfb543add6e7d")
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 coroutine. 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 openai
import asyncio
from typing import Any, List, Dict, Optional
from unittest.mock import AsyncMock, MagicMock

# Mock the openai module to avoid actual API calls
openai.ChatCompletion = MagicMock()

# Create mock async responses
async def mock_acreate(**kwargs):
    return {"choices": [{"message": {"content": "Mock response"}}]}

openai.ChatCompletion.acreate = AsyncMock(side_effect=mock_acreate)

# Construct arguments
messages_list = [
    [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is 2+2?"}
    ],
    [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is the capital of France?"}
    ]
]

model = "gpt-3.5-turbo"
temperature = 0.7
max_tokens = 100

ARGS = {
    "messages_list": messages_list,
    "model": model,
    "temperature": temperature,
    "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 coroutine — a coroutine output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a coroutine 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
encode_with_prompt_completion_format Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/examination/utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from clinicalml/co-llm, is pointer only (licence: NONE) · get_code("661419d69a095bfe")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from clinicalml/co-llm, 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.

extract_question_id Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/examination/hallucination/get_metric.py
code served (permissive licence) · get_code("d82c972512c051c4")
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

def extract_question_id(idx):
    return idx.replace('_test0', '').replace('_test1', '').replace('_test2', '')

ARGS = {
    'idx': 'question_123_test0'
}
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_completion Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/eval/gpt_judge/gpt_judge.py
code served (permissive licence) · get_code("cbcc22537dba8d33")
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 openai
import time
import asyncio
from typing import Any, List, Dict, Optional

# Mock the openai module since we can't make real API calls
class MockChatCompletion:
    @staticmethod
    async def acreate(model: str, messages: list, temperature: float, max_tokens: int):
        # Simulate async API response
        await asyncio.sleep(0.001)
        return {
            "choices": [{"message": {"content": "This is a mock response."}}],
            "model": model,
            "usage": {"prompt_tokens": 10, "completion_tokens": 5}
        }

# Replace openai.ChatCompletion with mock
openai.ChatCompletion = MockChatCompletion

# Construct messages_list - a list of message conversations
# Each conversation is a list of dicts with "role" and "content" keys
messages_list = [
    [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is 2+2?"}
    ],
    [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is the capital of France?"}
    ]
]

# Define ARGS dict with all parameters for get_completion
ARGS = {
    "messages_list": messages_list,
    "model": "gpt-3.5-turbo",
    "temperature": 0.7
}
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 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_json_list Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/eval/gpt_judge/gpt_judge.py
code served (permissive licence) · get_code("5d17b604c968b41d")
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 os
import tempfile

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

# Write some sample JSONL data
with open(temp_file, 'w') as f:
    f.write(json.dumps({"key1": "value1", "key2": 42}) + "\n")
    f.write(json.dumps({"key1": "value2", "key2": 43}) + "\n")
    f.write(json.dumps({"key1": "value3", "key2": 44}) + "\n")

ARGS = {
    "file_path": 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
get_next_word_predictions Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/examination/utils.py
code served (permissive licence) · get_code("b15d8b1317f1fd0d")
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. 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 SimpleTokenizer:
    def __init__(self):
        self.vocab_size = 100
    
    def __call__(self, texts, padding='longest', return_tensors='pt', add_special_tokens=True):
        # Return a mock tokenizer output
        batch_size = len(texts) if isinstance(texts, list) else 1
        seq_len = 5
        input_ids = torch.randint(0, self.vocab_size, (batch_size, seq_len))
        attention_mask = torch.ones(batch_size, seq_len)
        
        class TokenizerOutput:
            pass
        
        output = TokenizerOutput()
        output.input_ids = input_ids
        output.attention_mask = attention_mask
        return output
    
    def convert_ids_to_tokens(self, ids):
        if isinstance(ids, torch.Tensor):
            ids = ids.tolist()
        if isinstance(ids, int):
            return f"token_{ids}"
        return [f"token_{i}" for i in ids]

class SimpleModel(nn.Module):
    def __init__(self, vocab_size=100, hidden_dim=4):
        super().__init__()
        self.vocab_size = vocab_size
        self.hidden_dim = hidden_dim
        self.linear = nn.Linear(hidden_dim, vocab_size)
        self.device_obj = torch.device('cpu')
    
    @property
    def device(self):
        return self.device_obj
    
    def forward(self, input_ids, attention_mask):
        batch_size = input_ids.size(0)
        # Create mock logits output
        logits = self.linear(torch.randn(batch_size, 1, self.hidden_dim))
        
        class ModelOutput:
            pass
        
        output = ModelOutput()
        output.logits = logits
        return output

model = SimpleModel(vocab_size=100, hidden_dim=4)
tokenizer = SimpleTokenizer()
prompts = ["Hello world", "How are you"]
candidate_token_ids = None
batch_size = 1
return_token_predictions = False
add_special_tokens = True
disable_tqdm = True

ARGS = {
    'model': model,
    'tokenizer': tokenizer,
    'prompts': prompts,
    'candidate_token_ids': candidate_token_ids,
    'batch_size': batch_size,
    'return_token_predictions': return_token_predictions,
    'add_special_tokens': add_special_tokens,
    'disable_tqdm': disable_tqdm
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — 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
parse_fact_enhance_classify_res Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/data_generation/post_process.py
code served (permissive licence) · get_code("958758b5786a4316")
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 re

def parse_fact_enhance_classify_res(raw_response: str):
    replace_map = {'#Prediction:': 'Prediction:', '#Search Query:': 'Search Query:', '#Command:': 'Command:'}
    for old_text, new_text in replace_map.items():
        raw_response = raw_response.replace(old_text, new_text)
    true_resp = re.split('Command:', raw_response)[0]
    split_response = re.split('Prediction:|Search Query:', true_resp)
    if len(split_response) < 2:
        return None
    analysis, final_prediction = (split_response[0], split_response[1])
    final_prediction = final_prediction.strip()
    if final_prediction not in ['<need>', '<no need>']:
        return None
    queris = ''
    if final_prediction == '<need>':
        if len(split_response) == 3:
            queris = split_response[2]
    analysis = analysis.strip()
    queris = queris.strip()
    return {'analysis': analysis, 'final_prediction': final_prediction, 'queris': queris}


raw_response_1 = """
This is some analysis text here.
Prediction: <need>
Search Query: what is the capital of france
Command: do something
"""

raw_response_2 = """
#Prediction: <no need>
#Command: next step
"""

raw_response_3 = """
Some detailed analysis of the fact.
#Prediction: <need>
#Search Query: tell me more
"""

ARGS = {
    'raw_response': raw_response_1
}
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 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
parse_fact_generation_res Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/data_generation/post_process.py
code served (permissive licence) · get_code("63e1e400990ece36")
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

torch.manual_seed(0)

raw_response = "  This is a fact about the world.  \n"

ARGS = {
    "raw_response": raw_response
}
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
parse_test_generation_res Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/data_generation/post_process.py
code served (permissive licence) · get_code("875f0b97337517e6")
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 re
from typing import List, Dict, Optional

# Construct a realistic raw_response string that contains test questions
# in the expected format with proper structure
raw_response = """
Question: What is the capital of France?
Options: (A) London (B) Paris (C) Berlin (D) Madrid
Analysis: France is a European country and its capital is Paris, which is located in the north-central part of the country.
Answer: B

Question: What is 2 + 2?
Options: (A) 3 (B) 4 (C) 5 (D) 6
Analysis: Basic arithmetic shows that adding 2 and 2 equals 4.
Answer: (B)

#Question: What is the largest planet in our solar system?
#Options: (A) Mars (B) Venus (C) Jupiter (D) Saturn
#Analysis: Jupiter is the largest planet in our solar system by mass and volume.
#Answer: C

Question: What color is the sky on a clear day?
Options: (A) Green (B) Blue (C) Red (D) Yellow
Analysis: On a clear day, the sky appears blue due to Rayleigh scattering of light.
Answer: A-
"""

ARGS = {
    "raw_response": raw_response
}
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 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
read_jsonl Ran
ran; our contract draft was wrong, not the code
fanqiwan/KCA/data_generation/inconsistency_processing.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from iSEngLab/LLM4UT_Empirical, is pointer only (licence: NONE) · get_code("02171abe8492fcfd")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from iSEngLab/LLM4UT_Empirical, 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.

compute_metrics Not yet run
unverified (harvested, no recorded run)
fanqiwan/KCA/eval/gpt_judge/gen_summary.py
code served (permissive licence) · get_code("7f0044e5a93e33e2")
How it ran

no invocation recorded.

generate_completions Not yet run
unverified (harvested, no recorded run)
fanqiwan/KCA/examination/utils.py
code served (permissive licence) · get_code("352416cd121404a7")
How it ran

no invocation recorded.

openai_encode_prompt Not yet run
unverified (harvested, no recorded run)
fanqiwan/KCA/data_generation/per_instance_query.py
code served (permissive licence) · get_code("3a8f2cf897f0d356")
How it ran

no invocation recorded.

query_openai_batch Not yet run
unverified (harvested, no recorded run)
fanqiwan/KCA/data_generation/per_instance_query.py
code served (permissive licence) · get_code("e34ff3c5b1f3ba89")
How it ran

no invocation recorded.

request_openai_batch Not yet run
unverified (harvested, no recorded run)
fanqiwan/KCA/data_generation/per_instance_query.py
code served (permissive licence) · get_code("5869d7c37c3993a8")
How it ran

no invocation recorded.

Also present in other papers' code

Of 22 samples lifted from this paper's linked repositories, 22 carry a function identity and 0 do not. Of the 22 distinct functions with an identity, 9 are also present in other papers whose code we hold (6 with at least one paper dated earlier, 6 the same month, 8 later) and 13 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
encode_with_prompt_completion_format 9 other papers
2 dated earlier, 3 the same month, 4 later
2311.05657 (2023-11)
Agent Lumos: Unified and Modular Training for Open-Source Language Agents
2312.07540 (2023-12)
diff History for Neural Language Agents
2401.08565 (2024-01)
Tuning Language Models by Proxy
and 6 more not named here
create_prompt_with_tulu_chat_format 8 other papers
1 the same month, 7 later
2401.16405 (2024-01)
Scaling Sparse Fine-Tuning to Large Language Models
2403.03870 (2024-03)
Learning to Decode Collaboratively with Multiple Language Models
2405.05008 (2024-05)
ADELIE: Aligning Large Language Models on Information Extraction
and 5 more not named here
dispatch_openai_prompt_requesets 8 other papers
1 dated earlier, 2 the same month, 5 later
2310.06830 (2023-10)
Lemur: Harmonizing Natural Language and Code for Language Agents
2401.15006 (2024-01)
Airavata: Introducing Hindi Instruction-tuned LLM
2401.16405 (2024-01)
Scaling Sparse Fine-Tuning to Large Language Models
and 5 more not named here
dispatch_openai_chat_requesets 7 other papers
1 dated earlier, 2 the same month, 4 later
2310.06830 (2023-10)
Lemur: Harmonizing Natural Language and Code for Language Agents
2401.15006 (2024-01)
Airavata: Introducing Hindi Instruction-tuned LLM
2401.16405 (2024-01)
Scaling Sparse Fine-Tuning to Large Language Models
and 4 more not named here
create_prompt_with_llama2_chat_format 6 other papers
2 the same month, 4 later
2401.08565 (2024-01)
Tuning Language Models by Proxy
2401.16405 (2024-01)
Scaling Sparse Fine-Tuning to Large Language Models
2403.03870 (2024-03)
Learning to Decode Collaboratively with Multiple Language Models
and 3 more not named here
generate_completions 6 other papers
1 dated earlier, 2 the same month, 3 later
2310.08491 (2023-10)
Prometheus: Inducing Fine-grained Evaluation Capability in Language Models
2401.15006 (2024-01)
Airavata: Introducing Hindi Instruction-tuned LLM
2401.16405 (2024-01)
Scaling Sparse Fine-Tuning to Large Language Models
and 3 more not named here
get_json_list 4 other papers
2 dated earlier, 1 later, 1 same year, order not determinable
2310.09168 (2023-10)
EXPLORE-INSTRUCT: Enhancing Domain-Specific Instruction Coverage through Active Exploration
2310.20410 (2023-10)
FollowBench: A Multi-level Fine-grained Constraints Following Benchmark for Large Language Models
2024.findings-acl.341 (2024 (year only))
Phased Instruction Fine-Tuning for Large Language Models
and 1 more not named here
read_jsonl 4 other papers
4 later
2412.16620 (2024-12)
A Large-scale Empirical Study on Fine-tuning Large Language Models for Unit Testing
2025.emnlp-main.1337 (2025 (year only))
CopySpec: Accelerating LLMs with Speculative Copy-and-Paste
2505.17612 (2025-05)
Distilling LLM Agent into Small Models with Retrieval and Code Tools
and 1 more not named here
dispatch_openai_requests 1 other paper
1 dated earlier
2310.09168 (2023-10)
EXPLORE-INSTRUCT: Enhancing Domain-Specific Instruction Coverage through Active Exploration

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 demonstrated exceptional performance across various tasks following human alignment, they may still generate responses that sound plausible but contradict factual knowledge, a phenomenon known as hallucination. In this paper, we demonstrate the feasibility of mitigating hallucinations by verifying and minimizing the inconsistency between external knowledge present in the alignment data and the intrinsic knowledge embedded within foundation LLMs. Specifically, we propose a novel approach called Knowledge Consistent Alignment (KCA), which employs a well-aligned LLM to automatically formulate assessments based on external knowledge to evaluate the knowledge boundaries of foundation LLMs. To address knowledge inconsistencies in the alignment data, KCA implements several specific strategies to deal with these data instances. We demonstrate the superior efficacy of KCA in reducing hallucinations across six benchmarks, utilizing foundation LLMs of varying backbones and scales. This confirms the effectiveness of mitigating hallucinations by reducing knowledge inconsistency. Our code, model weights, and data are openly accessible at https://github.com/fanqiwan/KCA.

For agents

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

get_harvested_code_for_paper("2401.10768")
get_code_for_paper("2401.10768")
have("2401.10768")

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

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

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

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

Connect an agent — have() is free.