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

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

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

In-Context Learning (ICL) has become the standard paradigm for leveraging Large Language Models (LLMs) without parameter updates. Traditionally, predictions are derived by comparing the probabilities assigned to specific "label tokens" (e.g., "Positive" vs. "Negative"). This approach assumes that the pre-defined "un-embedding" vectors for these tokens in the model's output head are the optimal way to separate classes in the high-dimensional hidden space.

However, this paper identifies a fundamental flaw: human-selected token vectors often create suboptimal decision boundaries. Even advanced calibration methods that shift or rotate these probabilities remain constrained within these limited token-based subspaces. We propose Hidden Calibration (Hidd.C), which bypasses token probabilities entirely by operating directly on the model's internal hidden states.

Methodology: Hidden Calibration

Hidden Calibration replaces token-based logits with a nearest-centroid classifier acting on the last hidden states ($h$) of the language model. The process involves two primary phases:

  1. Centroid Calculation: Using a small calibration set (e.g., 16 examples per class), the model extracts the last hidden state for each example and calculates the mean vector (centroid) for each class.
  2. Inference: For a new query, the model extracts its last hidden state and assigns the label of the nearest centroid based on Euclidean distance or cosine similarity.
Comparison of previous token-based methods (B) which rely on token embedding similarity, versus the proposed Hidden Calibration (C) which utilizes centroids in the hidden state space.

This method is computationally efficient, requiring only a few forward passes and no gradient-based training, effectively treating the frozen LLM as a high-quality feature extractor.

Analysis: The Token Space Bottleneck

Visualizations using Principal Component Analysis (PCA) reveal why token-based criteria fail. The directions defined by label tokens often exhibit significant inter-class overlap. In contrast, Hidden Calibration identifies directions in the hidden space where classes are linearly separable.

PCA visualization of hidden states. Token-based methods (Un-calibrated, Batch Cali.) struggle with class overlap, while Hidden Calibration (Hidd.C) achieves a much higher F1 score by finding a more distinct decision boundary.

Furthermore, the research demonstrates that adding demonstrations ($k$) to a prompt causes the model's internal hidden states for the same class to "cluster" more tightly. This intra-class convergence makes simple linear boundaries, like those used in Hidd.C, increasingly effective as the number of examples grows.

Key Results and Robustness

The researchers evaluated Hidd.C across 6 models (including Llama 2 and OPT variants) and 10 diverse datasets covering sentiment analysis, NLI, and topic classification. Key findings include:

  • Performance Gains: Hidd.C consistently outperformed all baselines, including Vanilla ICL and advanced rotation-based calibrations, by 20% to 50%.
  • Robustness: Standard ICL is notoriously sensitive to prompt wording and example ordering. Because Hidd.C relies on underlying semantic representations rather than surface-level token probabilities, it exhibits significantly higher stability across different prompt templates.
  • Sample Efficiency: Even with minimal calibration data (one example per class), Hidd.C often surpassed other methods that utilized larger datasets.

Conclusion

By shifting the decision criteria from the token space to the hidden state space, Hidden Calibration addresses the inherent suboptimality of traditional ICL. The massive performance gains and improved robustness suggest that the internal representations of LLMs are far more organized and separable than their output token probabilities imply. This work provides a new state-of-the-art for ICL and offers deeper insights into how demonstrations shape the internal logic of language models.

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