Enhancing Language Model Factuality via Activation-Based Confidence Calibration and Guided Decoding

Xin Liu, Farima Fatahi Bayat, Lu Wang

Abstract

Large Language Models (LLMs) often generate factually incorrect information with high confidence, a phenomenon known as hallucination. This paper introduces ACTCAB (Activation-based Confidence Calibration) and CODEC (Confidence-guided Decoding), a framework that leverages internal model activations to improve both confidence calibration and factual accuracy. By training a lightweight layer on hidden states and using these signals to steer decoding, the authors achieve a 39% reduction in Expected Calibration Error (ECE) and substantial gains in truthfulness on benchmarks like TruthfulQA.

Introduction

The core challenge in deploying LLMs for factual tasks is ensuring their reported confidence aligns with their actual accuracy. Traditional calibration methods relying on output logits or verbalized confidence often fail due to sensitivity to prompt phrasing or shallow signal representation. Furthermore, simple "selective generation" (refusing to answer when uncertain) often sacrifices helpfulness. This work proposes to use internal activations—the model's "internal knowledge"—to provide a more robust confidence signal and use this signal to actively guide the generation process.

Methods

The proposed framework consists of two main components: ACTCAB and CODEC.

ACTCAB: Activation-based Confidence Calibration

ACTCAB shifts the focus from final token probabilities to the model's internal hidden states. A linear layer is trained on the activations of the LLM's final layer. A key innovation is the use of "soft labels" generated via K-fold cross-validation. Instead of binary 0/1 labels, the model is trained on expected accuracy within confidence bins, directly optimizing for calibration.

The ACTCAB training pipeline uses K-fold cross-validation to generate soft labels for training a calibration layer on internal activations.

CODEC: Confidence-guided Decoding

CODEC utilizes the ACTCAB scores in real-time during generation. At each decoding step, CODEC evaluates the confidence of the resulting sequence for top candidate tokens and re-weights the probability distribution. This "nudges" the model toward paths it is more certain about, improving factuality without the need for external knowledge retrieval or heavy re-training.

Experimental Setup

The framework was evaluated on the CaT (Calibration Test) benchmark, encompassing five diverse datasets: Natural Questions (NQ), TriviaQA, SciQ, WikiQA, and TruthfulQA. Testing was conducted across the Llama-2 (7b, 13b) and Llama-3 (8b) model families.

Results and Analysis

ACTCAB demonstrated superior calibration, reducing Expected Calibration Error (ECE) by an average of 39% compared to the previous state-of-the-art, LitCab. More importantly, CODEC significantly improved factual performance across all tested models.

Performance comparison of CODEC against baseline decoding and intervention methods across multiple LLM families and QA tasks.

As shown in the results, CODEC consistently outperforms greedy decoding and other intervention methods like ITI or RepE. Notably, on TruthfulQA, the "True*Info" metric—which balances truthfulness and informativeness—saw a 50% improvement for Llama2-7b compared to standard greedy decoding. Unlike selective generation, which often sees a drop in performance due to over-caution, CODEC maintains high informativeness while boosting accuracy.

Discussion and Limitations

The success of ACTCAB suggests that internal "brain states" are more reliable indicators of truth than surface-level probabilities. CODEC's ability to maintain helpfulness while increasing accuracy is a significant advantage. However, the method requires "white-box" access to activations, precluding its use with closed API-based models. Additionally, while it steers the model toward its own internal knowledge, it cannot compensate for fundamental knowledge gaps where the model lacks the correct information. Future work will explore extending these techniques to long-form generation and multi-step reasoning.

Summary updated

BibTeX
@inproceedings{liu2024enhancing,
  author = {Xin Liu and Farima Fatahi Bayat and Lu Wang},
  title = {{Enhancing Language Model Factuality via Activation-Based Confidence Calibration and Guided Decoding}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.583},
}
Figure