---
title: Vocabulary-Aware Conformal Prediction (VACP)
url: https://www.emergentmind.com/topics/vocabulary-aware-conformal-prediction-vacp
type: topic
---

# Vocabulary-Aware Conformal Prediction (VACP)

Vocabulary-Aware Conformal Prediction (VACP) is a framework designed for efficient and reliable uncertainty quantification in next-token prediction with large language models (LLMs) that possess extremely large vocabularies (e.g., |V| ≈ 256,000). While Adaptive Prediction Sets (APS) provide provable marginal coverage guarantees for classification and next-token tasks, their naive application to LLMs results in prediction sets containing hundreds of tokens, which are inefficient and uninformative. VACP addresses this by systematically reducing the effective prediction space and sharpening uncertainty quantification, while maintaining marginal coverage guarantees comparable to standard APS [2512.22682].

## 1. Formal Description of VACP

Let $V$ denote the full vocabulary of the LLM. Standard APS constructs the prediction set for a new context $x$ as
\[
C_V(x) = \{ y \in V : s_V(x, y) \leq \tau_{1-\alpha} \}
\]
where
\[
s_V(x, y) = \sum_{j: p_V(x)_{(j)} \geq p_V(x)_y} p_V(x)_{(j)}
\]
is the cumulative softmax mass up to token $y$, with $p_V(x)_y$ the softmax probability for token $y$ and $\tau_{1-\alpha}$ the $(1-\alpha)(1+1/n)$ quantile of calibration scores.

VACP modifies this in three principal steps:
1. **Vocabulary restriction**: Select a subset $V^* \subset V$ such that $P_{(X,Y)\sim D}(Y \in V^*) \equiv p \approx 1$.
2. **Temperature-adjusted scoring**: Apply temperature scaling to sharpen the prediction distribution over $V^*$, using $p_t(y|x) = \exp(z_y / t) / \sum_{y' \in V^*} \exp(z_{y'}/t)$ for model logits $z$ and temperature $t$.
3. **APS on $V^*$**: Run APS on $V^*$ with scores $s_*(x, y) = \sum_{j: p_t(x)_{(j)} \geq p_t(x)_y } p_t(x)_{(j)}$ and threshold $\tau_{1-\alpha}$.

The resulting prediction set
\[
C_{\text{VACP}}(x) = \{ y \in V^* : s_*(x, y) \leq \tau_{1-\alpha} \}
\]
achieves the same marginal coverage as APS on $V$ provided $p \approx 1$.

## 2. Algorithmic Workflow

VACP is structured as follows:

**Step A: Effective Vocabulary Construction**
- *Structural filtering*: Remove control tokens (e.g., <pad>, <eos>, <unused...>), non-printables.
- *Empirical filtering*: For each $y \in V$ (remaining), compute $m_y = \max_{(x, \cdot) \in D_{\text{val}}} \text{softmax}(z(x))_y$. Remove all $y$ with $m_y \leq \epsilon$ ($\epsilon = 10^{-5}$).
- The surviving set defines $V^*$ (e.g., $|V^*| \approx 55,721$ for Gemma-2B).

**Step B: Temperature Selection**
- For each $t$ in a grid $T$:
    - For $(x_i, y_i) \in D_{\text{cal}}$:
        - Mask $z_{ij} = -\infty$ for $j \notin V^*$.
        - Compute $p_t^i = \text{softmax}(z_i / t)$.
        - Compute $s_t^i = \sum_{j: p_t^i(j) \geq p_t^i(y_i)} p_t^i(j)$.
    - Compute threshold $\tau_t$ as above; select $t^*$ giving coverage $\geq 1-\alpha$ with smallest mean set size.

**Step C: Prediction**
- Given new $x$, mask logits for $j \notin V^*$.
- Compute $p_{t^*}(\cdot|x)=\text{softmax}(z/t^*)$.
- Form $C_{\text{VACP}}(x)$ as above.

## 3. Mathematical Guarantees and Core Formulas

With $V^*$, temperature $t$, and nonconformity score $s_*(x, y)$ defined as above, VACP sets use the threshold
\[
\tau_{1-\alpha} = \operatorname{Quantile}\left( \{ s_*(x_i, y_i) \}_{i=1}^n \right) \, \text{at level } (1-\alpha)\frac{n}{n+1}
\]
Marginal coverage satisfies
\[
P_{(X,Y)}[Y \in C_{\text{VACP}}(X)] \geq 1-\alpha,
\]
provided $P(Y \in V^*) = 1$. If $P(Y \in V^*) = p < 1$, coverage is at least $p (1-\alpha)$.

To bound $|V^*|$, Proposition 2 gives $|V_{\text{emp}}| \leq 1/\epsilon$, so choosing $\epsilon = 10^{-5}$ yields $|V_{\text{emp}}| \lesssim 10^5$; structural filtering yields $|V^*| \approx 55,721$.

## 4. Theoretical Analysis

**Theorem 1 (Marginal Coverage under Vocabulary Restriction):**  
If $V^*$ satisfies $p = P(Y \in V^*) = 1$, then $C_{\text{VACP}}$ constructed via APS restricted to $V^*$ ensures $P(Y_{n+1} \in C_{\text{VACP}}(X_{n+1})) \geq 1-\alpha$. The proof follows by noting that calibration and prediction are both restricted to $V^*$, and thus exchangeability holds under the true distribution, preserving the conformal validity argument.

Proposition 2 asserts that empirical filtering controls the size of $V^*$, with the $1/\epsilon$ bound being worst-case; actual LLM output distributions are even sparser (≈3,200 tokens above $10^{-5}$ on average). Exact marginal coverage in practice depends on $P(Y \notin V \setminus V^*) = 0$, a property observed empirically on benchmarks such as SQuAD and WikiText.

## 5. Empirical Results and Efficiency

Experiments on the Gemma-2B model with SQuAD and WikiText-103 benchmarks compared standard APS and VACP for next-token prediction at $\alpha = 0.1$ (nominal 90% coverage). Key outcomes are summarized below:

| Method                      | Empirical Coverage        | Mean $|C|$ (tokens) | Efficiency Ratio   |
|---------------------------- |--------------------------|--------------------|------------------|
| Standard APS (full $V$)     | 91.2% ± 1.3%             | 847                | 1×               |
| VACP (mask + $t=0.1$)       | 89.7% ± 1.4%             | 4.3                | 197×             |

- Median prediction set size: standard APS median $|C|=612$, VACP median $|C|=3$.
- Ablations: APS + mask only (coverage 90.8%, mean $|C| \approx 92$), APS + temperature only ($t=0.1$; coverage 76.4%, mean $|C|\approx 3.1$).
- On WikiText-103 (no recalibration): coverage 88.4%, mean $|C|=6.7$.
- After recalibration: coverage 90.1%, mean $|C|=5.9$.
- By true-token confidence:
    - $p_y > 0.5$: coverage 91.3%, mean $|C|=2.1$
    - $0.1 < p_y \leq 0.5$: coverage 89.4%, mean $|C|=4.8$
    - $p_y \leq 0.1$: coverage 88.1%, mean $|C|=7.2$

These results show VACP achieves near-nominal coverage rates with prediction sets that are approximately 200× smaller than those from uninformed APS.

## 6. Significance and Robustness

VACP demonstrates that conformal prediction methods can be made practical for LLM next-token prediction, with substantial improvements in efficiency while maintaining formal statistical guarantees under strong conditions ($P(Y \in V^*) \approx 1$). Empirical filtering and structural masking eliminate tokens with negligible probability under practical workloads, ensuring practical set sizes without loss of relevant support for $Y$ in evaluation. Furthermore, VACP transfers effectively to new benchmarks without requiring extensive reparameterization or set recalibration.

The design achieves a balance between computational tractability, interpretability (reasonably small prediction sets), and theoretical rigor in coverage. These aspects support its use in high-stakes LLM deployments requiring calibrated set-based uncertainty quantification [2512.22682].

## 7. Context and Relation to Prior Work

VACP builds on the Adaptive Prediction Sets (APS) framework of Romano et al. (2020), whose direct application in large-vocabulary regimes results in unwieldy prediction sets. By integrating semantic masking and temperature-based distribution sharpening, VACP adapts the conformal prediction toolkit to the unique challenges of LLM architectures. The framework is primarily motivated by deficiencies in softmax calibration for LLMs and the need for uncertainty quantification in open-vocabulary, high-entropy predictive tasks. VACP offers theoretical and algorithmic foundations to extend conformal validity to applications previously impeded by efficiency constraints [2512.22682].

Source: https://www.emergentmind.com/topics/vocabulary-aware-conformal-prediction-vacp