Efficient Nearest Neighbor based Uncertainty Estimation for Natural Language Processing Tasks
Wataru Hashimoto, Hidetaka Kamigaito, Taro Watanabe
TL;DR
The paper introduces k-Nearest Neighbor Uncertainty Estimation (kNN-UE), a density-based UE method that also incorporates neighbor label information to calibrate NLP predictions with a single forward pass. By weighting base logits with a learned combination of neighbor distances and label agreement, kNN-UE improves confidence calibration and selective prediction across SA, NLI, and NER, in both in-domain and out-of-domain settings. The authors evaluate against strong baselines, analyze top-k and the label-term contribution, and explore efficient nearest-neighbor techniques (PQ, IVF, PCA) to address latency, offering practical recommendations and revealing trade-offs. The work demonstrates significant gains in UE metrics while providing insights into when and how to use approximate NN methods without severely compromising calibration, making it attractive for deployment in real-world NLP pipelines.
Abstract
Trustworthiness in model predictions is crucial for safety-critical applications in the real world. However, deep neural networks often suffer from the issues of uncertainty estimation, such as miscalibration. In this study, we propose $k$-Nearest Neighbor Uncertainty Estimation ($k$NN-UE), which is a new uncertainty estimation method that uses not only the distances from the neighbors, but also the ratio of labels in the neighbors. Experiments on sentiment analysis, natural language inference, and named entity recognition show that our proposed method outperforms the baselines and recent density-based methods in several calibration and uncertainty metrics. Moreover, our analyses indicate that approximate nearest neighbor search techniques reduce the inference overhead without significantly degrading the uncertainty estimation performance when they are appropriately combined.
