SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2608.21019 · 2026

Target-Aware Calibration Data Selection for Preserving Uncertainty in Quantized Language Models

Kaiwen Zheng, Zhen Yang, Liang He, Yixuan Chen, Kangning Cui, Sizai Hou, Yaofang Liu

arXiv · PDF · Open in the Atlas

Code that ran

7 of 8 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; 7 failures of our instrument; 1 no recorded run), measured 2026-11-24; 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/2608.21019.json · badge: /api/ran/2608.21019.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
xi-xiaoran/DPQ community
Papers with Code archive
7 ran · 1 no recorded run
FunctionStatusWhere it lives
calibration_text_with_fp_top Ran
ran; our contract draft was wrong, not the code
xi-xiaoran/DPQ/scripts_py/build_dpq_calibs.py
code served (permissive licence) · get_code("1e3deee3f2460b79")
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) 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

# Define ARGS for calibration_text_with_fp_top function
# The function takes two parameters: row and pred, both dicts

row = {
    'prompt': 'What is the capital of France?',
    'options': ['Paris', 'London', 'Berlin', 'Madrid'],
    'gold_idx': 0
}

pred = {
    'pred_idx': 2
}

ARGS = {
    'row': row,
    'pred': pred
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
calibration_text_with_gold Ran
ran; our contract draft was wrong, not the code
xi-xiaoran/DPQ/scripts_py/build_dpq_calibs.py
code served (permissive licence) · get_code("9d70487c823ee066")
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) 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)

# Construct a valid row dict for the function
row = {
    'prompt': 'What is the capital of France?',
    'options': ['Paris', 'London', 'Berlin', 'Madrid'],
    'gold_idx': 0
}

ARGS = {
    'row': row
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
candidate_to_calib_rows Ran
ran; our contract draft was wrong, not the code
xi-xiaoran/DPQ/scripts_py/build_dpq_calibs.py
code served (permissive licence) · get_code("31a80269d4a61e88")
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

# Define helper function used in the main function
def calibration_text_with_gold(row: dict) -> str:
    prompt = str(row.get('prompt', '')).strip()
    options = list(row.get('options') or [])
    try:
        gold_idx = int(row.get('gold_idx', -1))
    except Exception:
        gold_idx = -1
    if 0 <= gold_idx < len(options):
        return prompt + str(options[gold_idx])
    return prompt

def calibration_text_with_fp_top(row: dict, pred: dict) -> str:
    prompt = str(row.get('prompt', '')).strip()
    options = list(row.get('options') or [])
    try:
        pred_idx = int(pred.get('pred_idx', -1))
    except Exception:
        pred_idx = -1
    if 0 <= pred_idx < len(options):
        return prompt + str(options[pred_idx])
    return calibration_text_with_gold(row)

# Construct sample data for selected parameter
sample_selected = [
    {
        'id': 'sample_1',
        'dataset': 'test_dataset',
        'row': {
            'prompt': 'What is 2+2? ',
            'options': ['3', '4', '5'],
            'gold_idx': 1
        },
        'pred': {
            'pred_idx': 1
        },
        'margin': 0.15,
        'doubt': 0.35,
        'entropy': 0.42,
        'is_unknown': False
    },
    {
        'id': 'sample_2',
        'dataset': 'test_dataset',
        'row': {
            'prompt': 'What is the capital of France? ',
            'options': ['London', 'Paris', 'Berlin'],
            'gold_idx': 1
        },
        'pred': {
            'pred_idx': 0
        },
        'margin': 0.25,
        'doubt': 0.55,
        'entropy': 0.68,
        'is_unknown': True
    }
]

# Define ARGS for candidate_to_calib_rows function
ARGS = {
    'selected': sample_selected,
    'method': 'uncertainty_sampling'
}
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
make_anchor_rows Ran
ran; our contract draft was wrong, not the code
xi-xiaoran/DPQ/scripts_py/build_dpq_calibs.py
code served (permissive licence) · get_code("5feab165a89394d7")
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) 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 random
from itertools import cycle, islice
from typing import Any, Iterable

def take_cycle(rows: list[dict[str, Any]], n: int, seed: int) -> list[dict[str, Any]]:
    if n <= 0:
        return []
    if not rows:
        raise RuntimeError('No anchor rows available')
    rng = random.Random(seed)
    base = list(rows)
    rng.shuffle(base)
    if len(base) >= n:
        return base[:n]
    return list(islice(cycle(base), n))

def make_anchor_rows(anchor_rows: list[dict[str, Any]], n: int, seed: int, prefix: str) -> list[dict[str, Any]]:
    out: list[dict[str, Any]] = []
    for i, r in enumerate(take_cycle(anchor_rows, n, seed)):
        out.append({'id': f"{prefix}_{i}_{r.get('id', i)}", 'text': str(r.get('text') or r.get('prompt') or '').strip(), 'kind': str(r.get('kind', 'generic_anchor')), 'source_id': str(r.get('id', i))})
    return [r for r in out if r['text']]

# Setup code
anchor_rows = [
    {'id': 'row_0', 'text': 'This is the first anchor text', 'kind': 'type_a'},
    {'id': 'row_1', 'text': 'This is the second anchor text', 'kind': 'type_b'},
    {'id': 'row_2', 'prompt': 'This is a prompt field', 'kind': 'type_c'},
]

n = 5
seed = 42
prefix = 'anchor'

ARGS = {
    'anchor_rows': anchor_rows,
    'n': n,
    'seed': seed,
    'prefix': prefix,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
select_balanced Ran
ran; our contract draft was wrong, not the code
xi-xiaoran/DPQ/scripts_py/build_dpq_calibs.py
code served (permissive licence) · get_code("1d96854fe713b56f")
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) 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 random
from itertools import cycle, islice
from typing import Any, Iterable

def split_key(item: dict[str, Any]) -> str:
    d = str(item['dataset'])
    if 'arc' in d:
        return 'arc'
    if 'squad' in d:
        return 'squad_unans' if int(item.get('gold_idx', -1)) == 1 else 'squad_ans'
    return d

def select_balanced(items: list[dict[str, Any]], total: int, seed: int, *, score_key: str='doubt', reverse: bool=True, random_select: bool=False) -> list[dict[str, Any]]:
    if total <= 0:
        return []
    rng = random.Random(seed)
    quotas = {'arc': total // 2, 'squad_ans': (total - total // 2) // 2, 'squad_unans': total - total // 2 - (total - total // 2) // 2}
    selected: list[dict[str, Any]] = []
    used: set[str] = set()
    for sp, k in quotas.items():
        group = [x for x in items if split_key(x) == sp]
        if random_select:
            rng.shuffle(group)
        else:
            group = sorted(group, key=lambda x: float(x.get(score_key, 0.0)), reverse=reverse)
        take = group[:k]
        selected.extend(take)
        used.update((f"{x['dataset']}::{x['id']}" for x in take))
    if len(selected) < total:
        rest = [x for x in items if f"{x['dataset']}::{x['id']}" not in used]
        if random_select:
            rng.shuffle(rest)
        else:
            rest = sorted(rest, key=lambda x: float(x.get(score_key, 0.0)), reverse=reverse)
        selected.extend(rest[:total - len(selected)])
    if len(selected) < total and selected:
        selected = list(islice(cycle(selected), total))
    rng.shuffle(selected)
    return selected[:total]

# Construct test data
items = [
    {'dataset': 'arc_easy', 'id': 'arc_1', 'doubt': 0.9},
    {'dataset': 'arc_hard', 'id': 'arc_2', 'doubt': 0.7},
    {'dataset': 'arc_challenge', 'id': 'arc_3', 'doubt': 0.5},
    {'dataset': 'squad', 'id': 'squad_1', 'gold_idx': 0, 'doubt': 0.8},
    {'dataset': 'squad', 'id': 'squad_2', 'gold_idx': 0, 'doubt': 0.6},
    {'dataset': 'squad', 'id': 'squad_3', 'gold_idx': 1, 'doubt': 0.4},
    {'dataset': 'squad', 'id': 'squad_4', 'gold_idx': 1, 'doubt': 0.3},
    {'dataset': 'other', 'id': 'other_1', 'doubt': 0.2},
]

ARGS = {
    'items': items,
    'total': 6,
    'seed': 42,
    'score_key': 'doubt',
    'reverse': True,
    'random_select': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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_key Ran
ran; our contract draft was wrong, not the code
xi-xiaoran/DPQ/scripts_py/build_dpq_calibs.py
code served (permissive licence) · get_code("398dcb80f86c8daf")
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) 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

# Analyze the function:
# - Takes one parameter: item (dict[str, Any])
# - Accesses item['dataset'] and converts to string
# - Checks if 'arc' or 'squad' are in the string
# - For 'squad', also accesses item.get('gold_idx', -1) and converts to int
# - Returns a string

# Create test items for different branches
item_arc = {
    'dataset': 'arc_challenge',
    'gold_idx': 0
}

item_squad_ans = {
    'dataset': 'squad_v2',
    'gold_idx': 0
}

item_squad_unans = {
    'dataset': 'squad_v2',
    'gold_idx': 1
}

item_other = {
    'dataset': 'other_dataset',
    'gold_idx': -1
}

# Use the arc case as the primary test
ARGS = {
    'item': item_arc
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
take_cycle Ran
ran; our contract draft was wrong, not the code
xi-xiaoran/DPQ/scripts_py/build_dpq_calibs.py
code served (permissive licence) · get_code("3b420e28834f1602")
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) 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 random
from itertools import cycle, islice
from typing import Any, Iterable

# Construct valid arguments for take_cycle function

# rows: list[dict[str, Any]] - a list of dictionaries
rows = [
    {"id": 1, "name": "alice", "value": 10},
    {"id": 2, "name": "bob", "value": 20},
    {"id": 3, "name": "charlie", "value": 30},
]

# n: int - number of items to take
n = 5

# seed: int - random seed for reproducibility
seed = 42

ARGS = {
    "rows": rows,
    "n": n,
    "seed": seed,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
build_mixed_recipe Not yet run
unverified (harvested, no recorded run)
xi-xiaoran/DPQ/scripts_py/build_dpq_calibs.py
code served (permissive licence) · get_code("38c65bd0e9aed014")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 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 8 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-24.

Repositories linked to this paper

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

Abstract

Quantization is widely used to deploy large language models, but its effect on uncertainty behavior, such as confidence, margins, and abstention, is rarely treated as a primary objective. We frame calibration-data selection for quantization as a target-dependent uncertaintypreservation problem. Different deployments emphasize different regions of the input distribution, yet prior work mainly optimizes accuracy-oriented compression metrics or adjusts scores after quantization. We formalize this goal with distributional and boundary preservation risks, and provide a simple mixture-mismatch argument explaining why no single calibration recipe should be expected to fit all targets. We introduce Doubt-Preserving Quantization (DPQ), a lightweight pre-quantization recipe family that uses fullprecision predictions to construct target-aligned calibration mixtures of high-doubt examples and generic anchors. Across 8 language models, 9 NLP benchmarks, and 22 comparison methods, the leading fixed recipe changes with the preservation target: DPQ-r75 leads on SQUAD2 answerability-boundary preservation, while milder or single-signal variants, including DPQ-r50, confidence-only, and entropy-only, better preserve broad multiplechoice QA behavior. These results show that calibration data should be selected for the specific full-precision score behavior a deployment needs to preserve, rather than treated as a fixed quantization detail. Code is available at https://github.com/xi-xiaoran/DPQ.

For agents

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

get_harvested_code_for_paper("2608.21019")
get_code_for_paper("2608.21019")
have("2608.21019")

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

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

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

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

Connect an agent — have() is free.