Papers › Contextualized Sequence Likelihood: Enhanced Confidence Scores for Natural Language Generation

Contextualized Sequence Likelihood: Enhanced Confidence Scores for Natural Language Generation

3 Jun 2024arXiv:2406.01806archive 2025-07-28

Zhen Lin, Shubhendu Trivedi, Jimeng Sun

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.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2406.01806")

Code

Syntology Ran 6 of 14 code samples harvested from 1 repository linked to this paper; 8 have no recorded run. Of those that ran: 1 ran · fixture could not drive it; 5 ran with no contract checked.

By repository: official repository: 14 samples from 1 repository, 6 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

zlin7/contextsl officialmentioned in papermentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

14 samples harvested; 6 ran; 0 honoured the contract we drafted; 8 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · fixture could not drive it
5ran
8unverified

Licence: 0 of the 14 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from zlin7/contextsl. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

area_under_accuracy_coverage_curve zlin7/contextsl/pipeline/eval_uq.py official repository ran · fixture could not drive it fingerprinted MIT (permissive) · b2800ffbe076300f · report
area_under_roc zlin7/contextsl/pipeline/eval_uq.py official repository ran fingerprinted MIT (permissive) · 9184f3b764e75240 · report
calibrate_conf zlin7/contextsl/pipeline/calib.py official repository ran MIT (permissive) · 2542866fb6773158 · report
get_calib_obj zlin7/contextsl/pipeline/calib.py official repository ran MIT (permissive) · 7245efea9bc89fd6 · report
get_key_from_generated_strings_path_new zlin7/contextsl/dataeval/load.py official repository ran fingerprinted MIT (permissive) · 8a40fe7e97a47599 · report
sample_to_prompt zlin7/contextsl/dataeval/triviaqa_new.py official repository ran MIT (permissive) · 8de010f6c34a5f98 · report
generate_config zlin7/contextsl/dataeval/nq_open_new.py official repository unverified MIT (permissive) · 2c38e83c3c6eb721 · report
get_D_mat zlin7/contextsl/pipeline/clustering.py official repository unverified MIT (permissive) · 8d0c51ce26ff6e51 · report
get_L_mat zlin7/contextsl/pipeline/clustering.py official repository unverified MIT (permissive) · cf36dbb016c0d562 · report
get_affinity_mat zlin7/contextsl/pipeline/clustering.py official repository unverified MIT (permissive) · 06026d0e9fd177b1 · report
load_tokenizer_with_prefix_space zlin7/contextsl/models/_load_model.py official repository unverified MIT (permissive) · 0c11fac6a22807b2 · report
preprocess_data zlin7/contextsl/dataeval/nq_open_new.py official repository unverified MIT (permissive) · 0251f96f3be99807 · report
preprocess_data zlin7/contextsl/dataeval/triviaqa_new.py official repository unverified MIT (permissive) · 874d540a196bc77b · report
sample_to_prompt zlin7/contextsl/dataeval/nq_open_new.py official repository unverified MIT (permissive) · 856cb0455a991719 · report

Tasks

Question AnsweringText Generation

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

BASECSL

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections