Abstract
Large language models are able to learn new tasks in context, where they are provided with instructions and a few annotated examples. However, the effectiveness of in-context learning is dependent on the provided context, and the performance on a downstream task can vary considerably, depending on the instruction. Importantly, such dependency on the context can surface in unpredictable ways, e.g., a seemingly more informative instruction might lead to a worse performance. In this paper, we propose an alternative approach, which we term In-Context Probing (ICP). Similar to in-context learning, we contextualize the representation of the input with an instruction, but instead of decoding the output prediction, we probe the contextualized representation to predict the label. Through a series of experiments on a diverse set of classification tasks, we show that in-context probing is significantly more robust to changes in instructions. We further show that ICP performs competitive or superior to finetuning and can be particularly helpful to build classifiers on top of smaller models, with less than a hundred training examples.
Introduction
In-Context Learning (ICL) has revolutionized how we interact with Large Language Models (LLMs), allowing them to solve tasks via few-shot prompting without weight updates. However, ICL is notoriously brittle. Performance often swings wildly based on the exact phrasing of instructions—a phenomenon known as prompt sensitivity. Furthermore, the decoding process is prone to "surface form competition," where a model may internally understand a concept but fail to generate the specific token required for a label. Finally, autoregressive decoding is computationally expensive for simple classification tasks.
This research introduces In-Context Probing (ICP), a method designed to bypass the decoder's inconsistencies by training a lightweight classifier directly on the model's internal representations.
Methods: In-Context Probing
Instead of treating the LLM as a text generator, ICP treats it as a contextualized feature extractor. The process involves three steps:
- Contextualization: The model is fed an instruction followed by the input text.
- Representation Extraction: Hidden states are extracted from the final layer of the encoder.
- Probing: A shallow classifier (e.g., Logistic Regression) is trained on these vectors to predict the target label.
By bypassing the decoder, ICP avoids the "verbalization" bottleneck, focusing instead on the semantic information already captured in the encoder's latent space.
Experimental Setup
The authors evaluated ICP against standard and calibrated ICL across three diverse classification tasks:
- MQP (Medical Question Pairs): Semantic equivalence of medical queries.
- CLIMATE (Climate Fever): Fact-checking climate claims (Support, Refute, Neutral).
- TWEETEVAL: Hate speech detection.
Experiments utilized the FLAN-T5 family, ranging from "Small" (80M parameters) to "XXL" (11B parameters).
Key Results and Robustness
The most significant advantage of ICP is its stability. While ICL performance fluctuates significantly with minor instruction changes, ICP remains remarkably consistent across different prompt variations.
Performance Highlights:
- Instruction Robustness: In the CLIMATE task, ICL performance varied by over 20 points across instructions, while ICP remained stable.
- Model Scaling: ICP enables smaller models to perform tasks where they previously failed. For instance, FLAN-T5-Small often performs at random-guess levels with ICL but becomes a viable classifier with ICP.
- Sample Efficiency: ICP reaches parity with or exceeds ICL with as few as 40 to 100 labeled examples.
- Parameter Efficiency: A probe with ~10K parameters on an 11B parameter model (FLAN-XXL) can match or outperform full-model finetuning, representing a 1,000,000x reduction in trainable parameters.
Conclusion
In-Context Probing offers a robust, efficient alternative to standard prompting for classification. By anchoring task knowledge in internal representations rather than volatile text generation, ICP mitigates the sensitivity issues inherent in ICL. While currently focused on encoder-decoder models, ICP represents a significant step toward more reliable and efficient deployment of LLMs for specialized classification tasks.
Summary updated