Leveraging Positional Bias of LLM In-Context Learning with Class-Few-Shot and Maj-Min Alternating Ordering
摘要
Selecting appropriate examples for in-context learning significantly impacts the performance of Large Language Models. In this paper, we show that leveraging LLMs’ positional biases and incorporating knowledge of class distribution can improve classification outcomes, especially for underrepresented classes. We introduce Class-few-shot, a method that balances class representation among few-shot examples. To investigate this, we conduct almost 10,000 experiments on four datasets and three models, cross-checking how different biases affect models’ performance and how they interact. We show that presenting classes from the most to least numerous using an alternating pattern leads to better results than standard few-shot prompting with the same number of examples. Additionally, we compare the general few-shot and Class-few-shot results, outlining the strengths of both approaches. All of our raw experiment results, prompts and codes are publicly available on GitHub ( https://github.com/olorules/Class-few-shot ).