SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2410.10414 · ICLR · 2025

On Calibration of LLM-based Guard Models for Reliable Content Moderation

Hao Wang, Hengguan Huang, Ye Wang, Hongfu Liu, Xiangming Gu

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/2410.10414.json · badge: /api/ran/2410.10414.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
waffle-liu/calibration_guard_model canonical (classifier label)
classifier basis: census
4 ran · 2 no recorded run
FunctionStatusWhere it lives
calibrate_py Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
waffle-liu/calibration_guard_model/eval_model_dep.py
code served (permissive licence) · get_code("4c39995866b47811")
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 ndarray, ndim 2, dtype family float, shape (4, 1) 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 numpy as np

# Set seed for reproducibility
np.random.seed(0)

# Create small valid arguments for calibrate_py
num_classes = 4

# p_y: probability distribution over classes (must sum to ~1)
p_y = np.array([0.1, 0.2, 0.3, 0.4])

# p_cf: confusion matrix diagonal or None
# For 'diagonal' mode, this should be a 1D array of diagonal values
p_cf = np.array([0.9, 0.85, 0.8, 0.75])

# mode: one of 'diagonal' or 'identity'
mode = 'diagonal'

ARGS = {
    'p_y': p_y,
    'p_cf': p_cf,
    'mode': mode
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (4, 1) — shape (4, 1) 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
get_equal_bins Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
waffle-liu/calibration_guard_model/calibration/utils.py
code served (permissive licence) · get_code("7dc9736cdb2847c4")
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 numpy as np
from typing import List

def split(sequence: List, parts: int) -> List[List]:
    assert parts <= len(sequence)
    array_splits = np.array_split(sequence, parts)
    splits = [list(l) for l in array_splits]
    assert len(splits) == parts
    return splits

def get_equal_bins(probs: List[float], num_bins: int=10) -> List[float]:
    """Get bins that contain approximately an equal number of data points."""
    sorted_probs = sorted(probs)
    if num_bins > len(sorted_probs):
        num_bins = len(sorted_probs)
    binned_data = split(sorted_probs, num_bins)
    bins: List[float] = []
    for i in range(len(binned_data) - 1):
        last_prob = binned_data[i][-1]
        next_first_prob = binned_data[i + 1][0]
        bins.append((last_prob + next_first_prob) / 2.0)
    bins.append(1.0)
    bins = sorted(list(set(bins)))
    return bins

# Create test arguments
probs_list = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 1.0]
num_bins_value = 5

ARGS = {
    "probs": probs_list,
    "num_bins": num_bins_value
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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_equal_prob_bins Ran
ran; our contract draft was wrong, not the code
waffle-liu/calibration_guard_model/calibration/utils.py
code served (permissive licence) · get_code("d1ebc0d7093a4203")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from typing import List

torch.manual_seed(0)

# Construct arguments for get_equal_prob_bins
probs = [0.1, 0.2, 0.3, 0.4]
num_bins = 10

ARGS = {
    "probs": probs,
    "num_bins": num_bins
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 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 Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
waffle-liu/calibration_guard_model/calibration/utils.py
code served (permissive licence) · get_code("8e9dfd4ba4bf9fa3")
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. 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
from typing import List, TypeVar

T = TypeVar('T')

# Set seed for reproducibility
torch.manual_seed(0)
np.random.seed(0)

# The function takes a sequence (List[T]) and an integer parts
# It uses np.array_split to split the sequence into parts
# The sequence can be any list-like object

# Create a simple test sequence
test_sequence = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
num_parts = 3

ARGS = {
    "sequence": test_sequence,
    "parts": num_parts
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list 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
compute_results_classifier_hug Not yet run
unverified (harvested, no recorded run)
waffle-liu/calibration_guard_model/eval_utils.py
code served (permissive licence) · get_code("8028fee51e12d3b0")
How it ran

no invocation recorded.

moderation_prompt_for_chat Not yet run
unverified (harvested, no recorded run)
waffle-liu/calibration_guard_model/eval_utils.py
code served (permissive licence) · get_code("9a447532c1113a53")
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, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 0 later) and 3 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
get_equal_bins 2 other papers
2 dated earlier
1910.12656 (2019-10)
Beyond temperature scaling: Obtaining well-calibrated multiclass probabilities with Dirichlet calibration
2312.04021 (2023-12)
A Study on the Calibration of In-context Learning
get_equal_prob_bins 2 other papers
2 dated earlier
1910.12656 (2019-10)
Beyond temperature scaling: Obtaining well-calibrated multiclass probabilities with Dirichlet calibration
2312.04021 (2023-12)
A Study on the Calibration of In-context Learning
split 2 other papers
2 dated earlier
1910.12656 (2019-10)
Beyond temperature scaling: Obtaining well-calibrated multiclass probabilities with Dirichlet calibration
2312.04021 (2023-12)
A Study on the Calibration of In-context Learning

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

Large language models (LLMs) pose significant risks due to the potential for generating harmful content or users attempting to evade guardrails. Existing studies have developed LLM-based guard models designed to moderate the input and output of threat LLMs, ensuring adherence to safety policies by blocking content that violates these protocols upon deployment. However, limited attention has been given to the reliability and calibration of such guard models. In this work, we empirically conduct comprehensive investigations of confidence calibration for 9 existing LLM-based guard models on 12 benchmarks in both user input and model output classification. Our findings reveal that current LLM-based guard models tend to 1) produce overconfident predictions, 2) exhibit significant miscalibration when subjected to jailbreak attacks, and 3) demonstrate limited robustness to the outputs generated by different types of response models. Additionally, we assess the effectiveness of post-hoc calibration methods to mitigate miscalibration. We demonstrate the efficacy of temperature scaling and, for the first time, highlight the benefits of contextual calibration for confidence calibration of guard models, particularly in the absence of validation sets. Our analysis and experiments underscore the limitations of current LLM-based guard models and provide valuable insights for the future development of well-calibrated guard models toward more reliable content moderation. We also advocate for incorporating reliability evaluation of confidence calibration when releasing future LLM-based guard models 1 .

For agents

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

get_harvested_code_for_paper("2410.10414")
get_code_for_paper("2410.10414")
have("2410.10414")

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

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

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

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

Connect an agent — have() is free.