SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2406.01806 · EMNLP · 2024

Contextualized Sequence Likelihood: Enhanced Confidence Scores for Natural Language Generation

Jimeng Sun, Zhen Lin, Shubhendu Trivedi

arXiv · PDF · Open in the Atlas

Code that ran

8 of 14 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 7 failures of our instrument; 6 no recorded run), measured 2026-11-22; 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/2406.01806.json · badge: /api/ran/2406.01806.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
zlin7/contextsl canonical (classifier label)
classifier basis: census
8 ran · 6 no recorded run
FunctionStatusWhere it lives
area_under_accuracy_coverage_curve Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
zlin7/contextsl/pipeline/eval_uq.py
code served (permissive licence) · get_code("b2800ffbe076300f")
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 float, ndim 0, dtype family float, shape () 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
import pandas as pd
from sklearn import metrics

# The function expects:
# u: array-like of uncertainty/confidence scores
# a: array-like of accuracy values
# Both should be numeric sequences of the same length

# Create small test data
u = np.array([0.1, 0.3, 0.2, 0.5, 0.4])  # uncertainty scores
a = np.array([0.9, 0.7, 0.8, 0.6, 0.75])  # accuracy values

ARGS = {
    'u': u,
    'a': a
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, pandas, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () 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
area_under_roc Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
zlin7/contextsl/pipeline/eval_uq.py
code served (permissive licence) · get_code("9184f3b764e75240")
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 float, ndim 0, dtype family float, shape () 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
from sklearn import metrics

torch_seed = 0

# Analyze the function:
# - area_under_roc(u, a)
# - u: passed to -u, negated. Used in roc_curve as scores
# - a: converted to int with .astype(int), used in roc_curve as y_true
# - Both need to be array-like with same length
# - roc_curve expects binary labels in a

# Create small numpy arrays
np.random.seed(0)

# u: scores/predictions (shape: 5,)
u = np.random.randn(5).astype(np.float32)

# a: binary labels (0 or 1), shape must match u
a = np.array([0, 1, 1, 0, 1], dtype=np.int64)

ARGS = {
    "u": u,
    "a": a,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () 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
calibrate_conf Ran
ran; our contract draft was wrong, not the code
zlin7/contextsl/pipeline/calib.py
code served (permissive licence) · get_code("2542866fb6773158")
How it ran

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

import numpy as np
import pandas as pd

class MockSummObj:
    def __init__(self):
        # Create sample data matching the expected structure
        # For 'mlga~neg_mlgc' setting
        index_1d = pd.Index(range(10), name='idx')
        self.uqs = {
            'conf_name': {
                'neg_mlgc': pd.Series(np.random.randn(10), index=index_1d),
                'neg_ic': pd.DataFrame(np.random.randn(10, 3), index=index_1d)
            }
        }
        self.acc = {
            'mlga': pd.Series(np.random.randint(0, 2, 10), index=index_1d),
            'ia': pd.DataFrame(np.random.randint(0, 2, (10, 3)), index=index_1d)
        }

summ_obj = MockSummObj()

ARGS = {
    'summ_obj': summ_obj,
    'conf_name': 'conf_name',
    'setting': 'mlga~neg_mlgc',
    'calib_seed': 7,
    'calib_size': 0.2,
    'calib_method': None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_D_mat Ran
ran, honoured the contract we drafted
zlin7/contextsl/pipeline/clustering.py
pointer only (licence: MIT); the stored copy get_code serves, from tian-bai/optcs, is pointer only (licence: NONE) · get_code("8d0c51ce26ff6e51")
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 tian-bai/optcs, 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.

get_L_mat Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
zlin7/contextsl/pipeline/clustering.py
pointer only (licence: MIT); the stored copy get_code serves, from tian-bai/optcs, is pointer only (licence: NONE) · get_code("cf36dbb016c0d562")
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 tian-bai/optcs, 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.

get_calib_obj Ran
ran; our contract draft was wrong, not the code
zlin7/contextsl/pipeline/calib.py
code served (permissive licence) · get_code("7245efea9bc89fd6")
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 Uncal. 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 numpy as np
from sklearn.calibration import CalibratedClassifierCV
from sklearn.svm import SVC

class Uncal(object):

    def __init__(self) -> None:
        pass

    def fit(self, y_score, y):
        pass

    def predict_proba(self, y_score):
        assert y_score.shape[1] == 1
        return np.concatenate([1 - y_score, y_score], axis=1)

def get_calib_obj(method, cv=3, **kwargs):
    if method is None:
        return Uncal()
    if method == 'defaultSVC':
        return CalibratedClassifierCV(None, cv=cv)
    raise ValueError(f'Unknown method {method}')

# Setup arguments for get_calib_obj
ARGS = {
    'method': None,
    'cv': 3
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Uncal — a Uncal output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Uncal 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_key_from_generated_strings_path_new Ran
ran; our contract draft was wrong, not the code
zlin7/contextsl/dataeval/load.py
code served (permissive licence) · get_code("8a40fe7e97a47599")
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 os
import tempfile

# Create temporary directory structure to simulate the path
temp_dir = tempfile.mkdtemp()
specs_dir = os.path.join(temp_dir, "experiment_specs_v1")
os.makedirs(specs_dir, exist_ok=True)

# Create a file path with .pkl extension
run_id_name = "run_12345.pkl"
file_path = os.path.join(specs_dir, run_id_name)

# Touch the file to ensure it exists
open(file_path, 'a').close()

ARGS = {
    'path': file_path,
    'clean': True
}
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 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
sample_to_prompt Ran
ran; our contract draft was wrong, not the code
zlin7/contextsl/dataeval/triviaqa_new.py
code served (permissive licence) · get_code("8de010f6c34a5f98")
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)

# The function expects a 'sample' dict with a 'question' key
# The 'question' can be either a string or a list of strings
# The function returns a formatted prompt string

# Case 1: sample with a single question (string)
sample_single = {
    'question': 'What is the capital of France?'
}

# Case 2: sample with multiple questions (list of strings)
sample_multiple = {
    'question': [
        'What is the capital of France?',
        'What is 2+2?',
        'What color is the sky?'
    ]
}

# The function accepts **kwargs but doesn't use them in the body
# We can pass an empty dict or additional unused kwargs

ARGS = {
    'sample': sample_single
}
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
generate_config Not yet run
unverified (harvested, no recorded run)
zlin7/contextsl/dataeval/nq_open_new.py
code served (permissive licence) · get_code("2c38e83c3c6eb721")
How it ran

no invocation recorded.

get_affinity_mat Not yet run
unverified (harvested, no recorded run)
zlin7/contextsl/pipeline/clustering.py
code served (permissive licence) · get_code("06026d0e9fd177b1")
How it ran

no invocation recorded.

load_tokenizer_with_prefix_space Not yet run
unverified (harvested, no recorded run)
zlin7/contextsl/models/_load_model.py
code served (permissive licence) · get_code("0c11fac6a22807b2")
How it ran

no invocation recorded.

preprocess_data Not yet run
unverified (harvested, no recorded run)
zlin7/contextsl/dataeval/nq_open_new.py
code served (permissive licence) · get_code("0251f96f3be99807")
How it ran

no invocation recorded.

preprocess_data Not yet run
unverified (harvested, no recorded run)
zlin7/contextsl/dataeval/triviaqa_new.py
code served (permissive licence) · get_code("874d540a196bc77b")
How it ran

no invocation recorded.

sample_to_prompt Not yet run
unverified (harvested, no recorded run)
zlin7/contextsl/dataeval/nq_open_new.py
code served (permissive licence) · get_code("856cb0455a991719")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 3 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 3 the same month, 2 later) and 11 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
area_under_accuracy_coverage_curve 2 other papers
1 dated earlier, 1 the same month
2305.19187 (2023-05)
Generating with Confidence: Uncertainty Quantification for Black-box Large Language Models
2406.03158 (2024-06)
CSS: Contrastive Semantic Similarity for Uncertainty Quantification of LLMs
get_D_mat 2 other papers
1 the same month, 1 later
2406.03158 (2024-06)
CSS: Contrastive Semantic Similarity for Uncertainty Quantification of LLMs
2411.17983 (2024-11)
Optimized Conformal Selection: Powerful Selective Inference After Conformity Score Optimization
get_L_mat 2 other papers
1 the same month, 1 later
2406.03158 (2024-06)
CSS: Contrastive Semantic Similarity for Uncertainty Quantification of LLMs
2411.17983 (2024-11)
Optimized Conformal Selection: Powerful Selective Inference After Conformity Score Optimization

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-22.

Repositories linked to this paper

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

Abstract

The advent of large language models (LLMs) has dramatically advanced the state-of-the-art in numerous natural language generation tasks. For LLMs to be applied reliably, it is essential to have an accurate measure of their confidence. Currently, the most commonly used confidence score function is the likelihood of the generated sequence, which, however, conflates semantic and syntactic components. For instance, in question-answering (QA) tasks, an awkward phrasing of the correct answer might result in a lower probability prediction. Additionally, different tokens should be weighted differently depending on the context. In this work, we propose enhancing the predicted sequence probability by assigning different weights to various tokens using attention values elicited from the base LLM. By employing a validation set, we can identify the relevant attention heads, thereby significantly improving the reliability of the vanilla sequence probability confidence measure. We refer to this new score as the Contextualized Sequence Likelihood (CSL). CSL is easy to implement, fast to compute, and offers considerable potential for further improvement with task-specific prompts. Across several QA datasets and a diverse array of LLMs, CSL has demonstrated significantly higher reliability than state-of-the-art baselines in predicting generation quality, as measured by the AUROC or AUARC.

For agents

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

get_harvested_code_for_paper("2406.01806")
get_code_for_paper("2406.01806")
have("2406.01806")

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

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

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

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

Connect an agent — have() is free.