Gradients with Respect to Semantics Preserving Embeddings Tell the Uncertainty of Large Language Models
Title: Uncertainty in Large Language Models Revealed by Gradients of Semantics-Preserving Embeddings
Abstract:
Given the propensity of Large Language Models (LLMs) to generate hallucinations, Uncertainty Quantification (UQ) serves as a critical mechanism for establishing their reliability. Current leading UQ techniques for free-form generation depend extensively on sampling, a process that introduces significant computational overhead and variance. To address these limitations, we introduce SemGrad, the inaugural gradient-based UQ approach for free-form generation that operates without sampling, thereby ensuring computational efficiency. While previous gradient-based methods tailored for classification tasks function within parameter space, our approach shifts the focus to semantic space. This strategy is grounded in the premise that a highly confident LLM will produce consistent output distributions even when subjected to input perturbations that are semantically equivalent. We define this stability through gradients in semantic space and develop a Semantic Preservation Score (SPS) to pinpoint the embeddings that most accurately encapsulate semantic meaning, serving as the basis for gradient calculations. Additionally, we present HybridGrad, a method that integrates the advantages of SemGrad with those of parameter gradients. Our experimental results indicate that both proposed methods deliver efficient and robust uncertainty estimates, outperforming state-of-the-art alternatives, especially in scenarios involving multiple valid responses.
Source: arXiv Generated at: 2026-06-02 00:00:00 UTC





