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

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

TL;DR

Researchers have discovered that the standard way of performing classification in Large Language Models (LLMs)—relying on the probabilities of specific "label tokens"—is fundamentally suboptimal. By switching to a simple nearest-centroid classifier based on the model's last hidden states, a new method called Hidden Calibration boosts performance by 20% to 50% across various models and datasets while being more robust to prompt design.

What Problem Does This Paper Address?

In-context learning (ICL) has become the de facto way to use LLMs for few-shot tasks. Typically, we provide a few examples (demonstrations) and a query, then look at the model's predicted probability for specific label tokens like "positive" or "negative."

However, this approach has a hidden flaw: it assumes that the model's internal "un-embedding" vectors—the weights used to turn abstract hidden concepts back into specific words—are the best tools for classification. The authors argue that these vectors create suboptimal decision boundaries in the model's high-dimensional hidden space. Even popular "calibration" techniques, which try to fix model biases by shifting these probabilities, are still stuck working within these narrow, hand-picked subspaces. This often leads to fragile performance that changes wildly based on how you phrase your prompt or the order of your examples.

Methods

The authors propose a surprisingly simple alternative: Hidden Calibration (Hidd.C). Instead of looking at the final word probabilities, they look at the "last hidden state"—the dense vector representation the model produces just before it tries to pick a word.

Figure 3: The diagram of Hidden Calibration. Step 1: Calculating the hidden state centroid of each label. Step 2: Find the label of the nearest centroid of the text sample to be the prediction.

The method works in two steps:

  1. Training (Calibration): Take a small set of labeled examples and pass them through the LLM. For each class (e.g., "positive" vs. "negative"), calculate the average hidden state vector, known as the centroid.
  2. Inference: When a new test query comes in, get its last hidden state. Instead of checking word probabilities, simply find which class centroid is closest to this new vector (using Euclidean distance or cosine similarity) and assign that label.

This approach effectively bypasses the "LM head" and finds a more natural linear boundary directly in the model's internal representation space.

Datasets

The researchers evaluated their method using 6 different models (ranging from GPT2-XL to Llama 3-8B) across 10 diverse classification datasets, including:

  • Sentiment Analysis: Rotten Tomatoes, SemEval 2014 (Restaurant & Laptops), Poem Sentiment.
  • Topic Classification: AGNews.
  • Natural Language Inference: GLUE-RTE.
  • Specialized Domains: Financial Phrasebank, Tweet Eval (Emotion, Hate, Sentiment).

They also tested on harder tasks like TREC (6-way classification) and biased datasets like Hate_Speech18.

Key Insights and Ideas

  • Suboptimal Boundaries: Standard methods are limited by the fixed directions of label tokens. As shown in Figure 2, these "token-based" boundaries often fail to separate the actual clusters of data points effectively, even after traditional calibration. Visualization showing that token-based decision boundaries (purple/orange) are poorly aligned with the actual data clusters compared to the centroid-based boundary (green).

  • Hidden State Convergence: A fascinating discovery is that as you add more demonstrations ($k$), the hidden states for the same class naturally cluster closer together. This "intra-class convergence" is what makes simple linear classification so effective.

  • Reduced Overlap: Hidden Calibration finds criteria with significantly less "inter-class overlap." In machine learning, less overlap between class distributions directly translates to a lower theoretical error rate.
  • Prompt Robustness: One of the biggest headaches in LLM engineering is "prompt sensitivity." The authors found that Hidden Calibration is remarkably stable, maintaining high performance regardless of the specific prompt template, the order of demonstrations, or even if the labels in the prompt are imbalanced.
Visualization showing that token-based decision boundaries (purple/orange) are poorly aligned with the actual data clusters compared to the centroid-based boundary (green).

Key Results

The results are striking. Hidden Calibration consistently outperformed all baselines across every model tested.

  • Massive Gains: Compared to vanilla ICL, Hidd.C showed improvements of up to 100%.
  • SOTA Performance: It beat the strongest existing calibration methods by an average of 20% to 50%.
  • Efficiency: Despite the performance boost, the method adds almost zero computational overhead during inference and requires only a tiny "calibration" set (as few as 1-16 samples per class).
Performance comparison across different models and numbers of demonstrations ($k$). Hidden Calibration (darkest bar) consistently leads the pack.

Limitations and Future Work

While powerful, the authors note a few areas for further exploration:

  • Comparison to Fine-tuning: Due to the massive resource requirements of fine-tuning billion-parameter models, a direct head-to-head comparison wasn't performed, though Hidd.C is intended as a lightweight alternative.
  • Label Token Selection: While Hidd.C doesn't use label probabilities, the prompt still contains label tokens for the demonstrations. The authors suggest that automatically selecting the best tokens to use in the prompt remains an open research question.
  • Theoretical "Why": While they observed hidden state clustering, the deep theoretical reason for why LLMs naturally organize their internal space this way during in-context learning deserves more study.

In short, if you're building classification systems with LLMs, it might be time to stop looking at the words the model says and start looking at what it's "thinking" in its hidden layers.

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