Introduction
In-Context Learning (ICL) has emerged as a powerful paradigm for Large Language Models (LLMs), enabling them to perform complex tasks using only a few demonstrations. However, ICL is notoriously sensitive to the specific ordering of these examples. A simple permutation of the same few-shot examples can cause performance to fluctuate wildly, ranging from state-of-the-art accuracy to near-random guessing. This paper, presented at NAACL 2024, introduces Probability Distribution Ordering (PDO), a method to identify optimal example sequences without requiring additional labeled data.
The Challenge of Example Ordering
Current methods for mitigating ordering sensitivity often rely on a labeled development set to validate different permutations. However, in low-resource or few-shot scenarios, such data is rarely available. If one possesses enough labeled data for a validation set, fine-tuning often becomes a more viable alternative. The authors address this by asking: can we select the best ordering using only the few examples provided in the prompt?
Probability Distribution Ordering (PDO)
PDO operates on the principle of "learning from label proportions." It evaluates candidate permutations based on how well the model's predicted label distributions align with expected priors.
Principle I: FewShot (Null Input Bias)
In the absence of extra data, a robust ordering should minimize intrinsic bias. PDO measures this by providing a "null" input (e.g., an empty string) to the model. A biased prompt might cause the model to predict a specific label even for empty input. PDO selects the ordering that minimizes the KL-divergence between the model’s output for a null input and a uniform distribution.
Principle II: FewShotUP (Unlabeled Data Alignment)
When a small set of unlabeled data is available, PDO ensures that the average predicted label distribution across this set matches the known or assumed task prior. For instance, in a balanced sentiment analysis task, the optimal ordering should yield a roughly 50/50 split in predictions.
As shown in the figure above, lower KL divergence (indicating better alignment with priors) strongly correlates with higher classification accuracy, particularly for the FewShotUP variant.
Experimental Results
The researchers evaluated PDO across 13 text classification datasets and 9 autoregressive LLMs (ranging from GPT-2 to LLaMA-13B).
Performance and Consistency
PDO consistently improves average accuracy while significantly reducing performance variance. By "raising the floor," the method prevents the model from falling into the low-performance traps associated with poor example ordering.
The boxplots demonstrate that PDO-PMI not only achieves higher median accuracy across most models but also tightens the distribution of results, making ICL much more reliable. For LLaMA-13B, PDO (FewShotUP) reached an average accuracy of 75.5%, a notable improvement over the 72.2% achieved by random ordering.
Improved Calibration
Beyond accuracy, PDO enhances model calibration. For OPT-13B, the Expected Calibration Error (ECE) dropped from 20.4% to 16.6%. This ensures that the model's confidence scores are more representative of its actual likelihood of being correct, which is critical for real-world deployment.
Conclusion and Future Work
PDO provides a data-efficient solution to the instability of few-shot learning. By leveraging label distribution priors, it identifies high-performing example sequences without the need for extensive labeled validation sets. While currently limited to classification tasks with fixed label sets, future research may extend these principles to open-ended generation and larger-scale frontier models.
Summary updated