Measuring Reliability of Large Language Models through Semantic Consistency

Harsh Raj, Domenic Rosati, Subhabrata Majumdar

TL;DR

Large language models (LLMs) often give contradictory answers when asked the same question rephrased in slightly different ways. While prior consistency evaluations relied on rigid, exact token matching, this paper introduces a framework to measure semantic consistency for open-ended text generation using natural language inference and paraphrase models. The findings reveal that model size improves consistency even when factual accuracy degrades, and that decoding strategies (greedy vs. sampling) heavily dictate how self-consistent a model remains.

What Problem Does This Paper Address?

For language models to be reliable in real-world systems, semantically equivalent prompts should yield semantically equivalent responses. If a model says "Paris is the capital of France" to one prompt but denies it when the question is phrased slightly differently, it cannot be trusted.

Historically, consistency benchmarks (such as LAMA or ParaRel) measured consistency by checking whether generated answers were identical at the token or character level ($y_i = y_j$). However, in natural language generation (NLG), answers can be phrased in dozens of valid ways without sharing identical vocabulary. Rigid lexical checks underestimate model consistency and fail entirely for open-ended freeform generation.

Methods

The authors generalize previous consistency metrics by replacing the exact token equality operator with an agreement function $f(y_i, y_j) \in [0, 1]$ over pairs of outputs generated from paraphrased prompts:

$$\text{Cons}_{\text{sem}}(Y) = \frac{1}{n(n-1)} \sum_{i,j=1, i \neq j}^n f(y_i, y_j)$$

They explore several agreement functions:

  • Paraphrase Detection (PP): A DeBERTa-v3 model fine-tuned on PAWS to detect whether two answers convey the same meaning.
  • Natural Language Inference (NLI): A DeBERTa model trained on MNLI assessing Entailment and Contradiction.
  • Semantic Similarity: BERTScore.
  • Lexical Baselines (for comparison): ROUGE-1 overlap (R1-C) and Named Entity Recognition overlap (NER).

The team evaluated open-source OPT models (125M to 2.7B parameters) and GPT-3 (text-davinci-002, 175B), testing both greedy decoding and nucleus sampling.

Datasets

  • TruthfulQA: The core benchmark of 817 question-answer prompts designed to elicit common human falsehoods and misconceptions.
  • Paraphrased TruthfulQA Questions: Paraphrases generated via DocT5Query, Quality Controlled paraphrase generation (QC), and few-shot GPT-3 (yielding 8,956 candidates), filtered down using a PAWS-trained detector and manual review to 3,962 high-quality paraphrased questions.
  • PAWS & MNLI: Used to train and evaluate the paraphrase detector and inference models.
  • Human Annotation Sample: A dataset of 100 questions (903 generated answer pairs) labeled by human annotators to validate consistency metrics (inter-annotator Fleiss' $\kappa = 0.84$).

Key Insights and Ideas

  • Accuracy and consistency are orthogonal: Consistency metrics show negligible (or even slightly negative) correlations with task accuracy measures like ROUGE-1 and BLEURT ($\rho \approx -0.10$ to $-0.22$). An LLM can be consistently wrong or inconsistently right—proving that benchmarking accuracy alone is insufficient to evaluate trustworthiness.
  • Model size boosts consistency despite inverse scaling: On TruthfulQA, larger OPT models exhibit "inverse scaling" (they generate less truthful answers as parameter count grows). However, semantic consistency steadily increases with parameter scale. Larger models understand prompts better, even when hallucinating.
  • Sampling is the enemy of consistency: Nucleus sampling drastically impairs consistency compared to greedy decoding. The stochasticity introduced during token selection causes models to contradict themselves across alternative prompt variations.
  • Semantic metrics align with human judgment: Lexical overlap metrics like ROUGE-1 ($\rho = 0.32$) and NER overlap ($\rho = 0.15$) poorly predict human judgments of output consistency. In contrast, NLI Entailment ($\rho = 0.70$) and Paraphrase detection ($\rho = 0.52$) correlate strongly with human evaluations.

Key Results

Model Decoding Accuracy (BLEURT) Consistency (Paraphrase) Consistency (Entailment) Consistency (ROUGE-1)
OPT-125M Greedy 50.0 27.7% 26.1% 12.0%
OPT-2.7B Greedy 43.6 37.6% 27.4% 11.6%
GPT-3 (175B) Greedy 62.6 62.2% 42.5% 30.4%
OPT-2.7B Sampled 48.9 14.2% 6.6% 0.3%
GPT-3 (175B) Sampled 60.5 54.0% 32.0% 19.9%
  • Nucleus sampling caused OPT-2.7B paraphrase consistency to plummet from 37.6% to 14.2%, and contradiction rates jumped from 28.6% to 36.7%.
  • Entailment demonstrated the highest alignment with human judgment of consistency ($\rho = 0.70$).

Limitations and Future Work

  • Metric Cascading Errors: The semantic consistency score depends on the accuracy of the underlying judge model (e.g., DeBERTa); any errors in NLI or paraphrase detection propagate directly into the score.
  • Benchmark Specificity: The study primarily focuses on TruthfulQA, where inverse scaling is prevalent. Evaluating tasks and datasets where standard scaling laws hold remains future work.
  • Task Scope: The experiments focus on question answering. Future research should apply and validate this framework on more diverse generative settings, including multi-turn dialogue, summarization, and multimodal generation.

Summary updated

BibTeX
@inproceedings{raj2022measuring,
  author = {Harsh Raj and Domenic Rosati and Subhabrata Majumdar},
  title = {{Measuring Reliability of Large Language Models through Semantic Consistency}},
  booktitle = {MLSW @ NeurIPS},
  year = {2022},
  url = {https://openreview.net/forum?id=SgbpddeEV-C},
}
Figure