Abstract
In-context learning (ICL) enables Large Language Models (LLMs) to perform tasks using only a few demonstrations. However, ICL is notoriously sensitive to the selection and ordering of these examples. This paper identifies "semantic ambiguity"—where demonstrations can be interpreted through different "semantic modes"—as the root cause of this instability. We propose two strategies to address this: an instance-free demonstration reordering method and a "Self-Explanatory" ICL framework. Our results across six benchmarks show that these methods significantly improve both accuracy and robustness, making LLMs more predictable and effective in few-shot settings.
The Problem: Semantic Ambiguity in ICL
While LLMs can perform tasks without weight updates via ICL, the "demonstration bias" problem often leads to inconsistent performance. A minor change in example order or selection can cause performance to fluctuate significantly. The authors argue that this happens because demonstrations are inherently ambiguous.
As shown in Figure 2, a single example like "The software update improved the UI" can be mapped to different semantic modes (e.g., functionality vs. user experience). If the sequence of examples doesn't clearly point to a single mode, the LLM may adopt an incorrect interpretation, leading to failure.
Proposed Methodology
To clear this "semantic fog," the researchers introduce two primary techniques:
1. Instance-Free Demonstration Reordering
Instead of random shuffling, this method uses a search algorithm to find an optimal sequence. It calculates a Semantic Ambiguity Score to measure how much a model's interpretation of an example shifts across contexts. By selecting demonstrations that maximize task clarity (using metrics like Label Entropy), the model is guided toward the correct semantic mode.
2. Self-Explanatory In-Context Learning
This framework modifies the prompt to force the LLM to generate an explanation before its final answer. This requirement compels the model to commit to a specific semantic path.
To optimize the instructions for this process (e.g., "Provide a corresponding explanation as well"), the authors used Optimization by PROmpting (OPRO), where a larger LLM refines the instructions for a smaller target model.
Experimental Evaluation
The methods were tested on six text classification benchmarks (SST-2, IMDB, CR, ETHOS, AgNews, and FP) using models like Vicuna-13B and Llama 2-13B-chat.
Key Results
- Accuracy Improvements: On the ETHOS hate speech detection dataset, reordering improved accuracy by approximately 10 percentage points over standard ICL.
- Robustness and Variance Reduction: The most significant gain was often in stability. For the IMDB dataset, the standard deviation of performance dropped from 12.95 to 10.7, indicating much more reliable outputs.
- Cross-Model Knowledge Transfer: Explanations generated by larger models (e.g., GPT-3.5) were found to effectively "teach" smaller models (e.g., Vicuna-7B) how to better interpret demonstrations.
Conclusion
By identifying semantic ambiguity as the core issue in ICL instability, this work provides a theoretical foundation for debiasing LLMs. The proposed reordering and self-explanation strategies offer a practical path toward more robust and accurate few-shot learning. Future work will explore these strategies in generative tasks and more complex reasoning scenarios.
Summary updated