Abstract Large language models (LLMs) specializing in natural language generation (NLG) have recently started exhibiting promising capabilities across a variety of domains. However, gauging the trustworthiness of responses generated by LLMs remains an open challenge, with limited research on uncertainty quantification (UQ) for NLG. Furthermore, existing literature typically assumes white-box access to language models, which is becoming unrealistic either due to the closed-source nature of the latest LLMs or computational constraints. In this work, we investigate UQ in NLG for black-box LLMs. We first differentiate uncertainty vs confidence: the former refers to the “dispersion” of the potential predictions for a fixed input, and the latter refers to the confidence on a particular prediction/generation. We then propose and compare several confidence/uncertainty measures, applying them to selective NLG where unreliable results could either be ignored or yielded for further assessment. Experiments were carried out with several popular LLMs on question-answering datasets. Results reveal that a simple measure for the semantic dispersion can be a reliable predictor of the quality of LLM responses, providing valuable insights for practitioners on uncertainty management when adopting LLMs.
Introduction: The Black-Box Challenge
As Large Language Models (LLMs) are increasingly deployed in high-stakes fields like medicine or law, knowing when to trust a model's output is critical. Most existing research on Uncertainty Quantification (UQ) assumes "white-box" access—meaning researchers can see the model's internal logit probabilities for every token.
However, the most powerful modern models (like GPT-4) are often closed-source "black boxes" accessed via APIs that only return text. Furthermore, standard UQ metrics like entropy fail in natural language because different sequences of words (e.g., "The sun is hot" vs. "Our star has a high temperature") mean the same thing. This research addresses two main challenges:
- How to measure uncertainty without access to internal model math.
- How to distinguish between Uncertainty (how ambiguous is the question?) and Confidence (how reliable is this specific answer?).
Methodology: A Framework for Black-Box UQ
The authors propose a three-step pipeline to quantify uncertainty using only the text outputs of an LLM.
1. Sampling
For a given input, the model generates $m$ different responses (e.g., 10 or 20) using a non-zero sampling temperature. This "dispersion" of answers provides the raw data for uncertainty analysis.
2. Similarity Mapping
The next step is calculating pairwise similarity between all generated responses. Instead of relying on lexical overlap (which fails to capture meaning), the authors use Natural Language Inference (NLI). A smaller, specialized model (DeBERTa) determines if one response entails or contradicts another, allowing the system to group responses by semantic meaning rather than just word choice.
3. Graph-Based Measures
The responses are treated as nodes in a graph, where edges represent semantic similarity. Spectral graph theory is then applied to derive several key measures:
- $U_{EigV}$ (Eigenvalue Sum): A continuous measure of how many distinct "meanings" are present in the sample pool. A higher sum indicates higher uncertainty.
- $C_{Deg}$ (Degree Centrality): Measures how well-connected a specific response is to all others. High connectivity implies high confidence in that specific answer.
- $C_{Ecc}$ (Eccentricity): Uses the eigenvectors of the Graph Laplacian to find a response's distance from the "semantic center" of the generated cluster.
Key Results and Insights
The methods were evaluated on popular Question-Answering (QA) benchmarks including CoQA, TriviaQA, and Natural Questions (nq) using models like LLaMA-13B and gpt-3.5-turbo.
Performance Gains
The authors used the Area Under Accuracy-Rejection Curve (AUARC) to measure performance. This metric evaluates how much the model's accuracy improves as you progressively reject the most "uncertain" or "low-confidence" answers.
- Accuracy Boost: On TriviaQA using LLaMA, selecting only the top 50% of samples based on their
Deg(E)measure improved accuracy from a base of 62% to approximately 90%. - Black-Box Superiority: Surprisingly, these black-box methods often outperformed "white-box" baselines like Semantic Entropy, which require expensive access to token-level logits.
Core Findings
- Confidence > Uncertainty for Selective NLG: For "selective generation" (deciding whether to show an answer or say "I don't know"), response-specific confidence measures are more effective than general input uncertainty measures.
- Efficiency: Even with just $m=3$ samples, the ability to predict whether an answer is correct improves significantly over random baselines.
- NLI is Essential: Semantic similarity consistently outperforms lexical similarity because LLMs often use different phrasing for the same concept.
Limitations and Future Work
While promising, the framework has limitations. It relies on the model's "dispersion"; if the sampling temperature is set to 0 (greedy decoding), the model always produces the same answer, making these measures unusable. Additionally, generating multiple responses increases computational cost and latency. Finally, if a model is "confidently wrong" due to training data errors (factual hallucinations), dispersion-based methods may still struggle to identify the mistake. Future work will explore applying these techniques to more open-ended creative and reasoning tasks.
Summary updated