Token-based Decision Criteria Are Suboptimal in In-context Learning

Hakaze Cho, Yoshihiro Sakai, Mariko Kato, Kenshiro Tanaka, Akira Ishii, Naoya Inoue

Abstract

In-Context Learning (ICL) typically utilizes classification criteria from output probabilities of manually selected label tokens. However, we argue that such token-based classification criteria lead to suboptimal decision boundaries, despite delicate calibrations through translation and constrained rotation applied. To address this problem, we propose Hidden Calibration, which renounces token probabilities and uses the nearest centroid classifier on the LM’s last hidden states. In detail, we assign the label of the nearest centroid previously estimated from a calibration set to the test sample as the predicted label. Our experiments on 6 models and 10 classification datasets indicate that Hidden Calibration consistently outperforms current token-based baselines by about 20%~50%, achieving a strong state-of-the-art in ICL. Our further analysis demonstrates that Hidden Calibration finds better classification criteria with less inter-class overlap, and LMs provide linearly separable intra-class clusters with the help of demonstrations, which supports Hidden Calibration and gives new insights into the principle of ICL.

Introduction: The Flaw in Token-Based ICL

In-Context Learning (ICL) has become a standard way to leverage Large Language Models (LLMs) for specific tasks by providing a few examples in the prompt. Traditionally, predictions are derived from the probabilities assigned to specific "label tokens" (e.g., "positive" vs. "negative").

However, this approach relies on the model's "un-embedding" layer, which maps internal hidden states to vocabulary tokens. This layer is often biased and arbitrary, creating a mismatch between the model's internal representation of a concept and the specific tokens chosen to represent it. Even advanced calibration techniques that shift or rotate these probabilities are fundamentally limited by the fixed geometry of the chosen tokens. This paper argues that these token-based decision boundaries are suboptimal and proposes a more direct approach.

Methods: Hidden Calibration (Hidd.C)

To overcome the limitations of token-based criteria, the authors introduce Hidden Calibration, a gradient-free method that operates directly on the model's internal hidden states.

The two-step process of Hidden Calibration: calculating class centroids from calibration data and using nearest-centroid classification for inference.

The process consists of two primary steps:

  1. Training (Calibration Phase): A small labeled calibration set is passed through the model. For each class, the last hidden state ($h$) is extracted, and an average vector—the centroid—is calculated.
  2. Inference: For a new test query, the model generates a hidden state $h$. The system then calculates the Euclidean distance between this state and each class centroid. The final prediction is simply the label of the nearest centroid.

This approach is highly efficient, requiring no parameter updates and utilizing a simple linear decision boundary in the high-dimensional hidden space.

Key Insights: Why Hidden States Matter

The success of Hidden Calibration stems from several key observations regarding the internal mechanics of LLMs:

  • Information Preservation: Hidden states act as "informative precursors" to logits and probabilities. By bypassing the token-mapping stage, the method avoids discarding useful high-dimensional information.
  • Natural Clustering and Geometric Freedom: LLMs naturally cluster hidden states by class. Unlike token-based methods, which are "stuck" using boundaries aligned with vocabulary vectors, Hidden Calibration is free to find the optimal boundary anywhere in the hidden space.
PCA visualization of hidden states showing that Hidden Calibration finds a superior decision boundary compared to un-calibrated or rotation-based methods.
  • Intra-class Convergence: Providing demonstrations in the prompt does more than just shift boundaries; it causes internal clusters to become tighter and more linearly separable, a phenomenon the authors call "intra-class convergence."
  • Robustness: Hidden Calibration significantly reduces the model's sensitivity to prompt templates and example ordering, which are common pain points in traditional ICL.

Experimental Results

The researchers evaluated Hidden Calibration across 6 models (including Llama 2, Llama 3, and OPT) and 10 diverse classification datasets spanning sentiment analysis, news categorization, and natural language inference.

  • Performance Gains: Hidd.C consistently outperformed all baselines, including Vanilla ICL and popular calibration methods like Contextual and Batch Calibration. On average, performance improved by 20% to 50%, with some scenarios seeing gains up to 100%.
  • Sample Efficiency: The method is remarkably effective even with minimal data; using just one calibration sample per class often outperformed traditional baselines using many more examples.

Conclusion and Future Directions

Hidden Calibration represents a significant shift in how we interpret LLM outputs for classification. By moving from token probabilities to hidden state centroids, the method achieves state-of-the-art performance with minimal overhead.

While highly effective, some challenges remain. The method still depends on the choice of label tokens used in the prompt construction, and the degree of clustering benefit varies across different model architectures. Future research will explore automatic label token selection and the application of hidden-state analysis to more complex reasoning tasks.

Summary updated

BibTeX
@inproceedings{cho2025token,
  author = {Hakaze Cho and Yoshihiro Sakai and Mariko Kato and Kenshiro Tanaka and Akira Ishii and Naoya Inoue},
  title = {{Token-based Decision Criteria Are Suboptimal in In-context Learning}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=1uQuOSykPr},
}
Figure