Debiasing In-Context Learning by Instructing LLM s How to Follow Demonstrations (2024)

Abstract: In-context learning(ICL) has gained considerable attention due to its data efficiency and task adaptability. Unfortunately, ICL suffers from the demonstration bias, i.e., its performance and robustness are severely affected by the selection and ordering of demonstrations. In this paper, we identify that such demonstration bias may primarily stem from the semantic ambiguity induced by demonstrations, i.e., a demonstration may indicate multiple input-to-label mappings and its mapping can be interpreted differently in different contexts by LLMs. Such semantic ambiguity disrupts task comprehension during ICL and results in performance fluctuations. To resolve the semantic ambiguity problem, this paper further proposes two de-biasing strategies to mitigate demonstration bias in in-context learning. Experiments on six datasets show that our methods can effectively alleviate demonstration bias and significantly improve task performance.

## introduction in-context learning(icl) has gained considerable attention in recent years, wherein a llm can perform an unseen task by only conditioning on several in-context input-output demonstrations @xcite . due to its minimal data requirements and zero parameter updates, icl enables developers to efficiently and flexibly apply llms in different domains @xcite @xcite . despite its effectiveness and popularity, recent studies have highlighted that icl is highly sensitive to the selection and order of demonstrations @xcite -which this paper calls demonstration bias. such a demonstration bias often results in significant performance fluctuations and severely undermines the robustness of llms. although many works have been proposed to search and generate optimal demonstrations for real-world tasks, it is still unclear what the underlying reasons of the demonstration bias in icl are @xcite @xcite @xcite . in this paper, we identify that such a demonstration bias may primarily stem from the semantic ambiguity induced by demonstrations, i.e., a demonstration may indicate multiple input-to-label mappings(this paper refers to the possible input-tolabel mappings of a demonstration as its semantic modes) and its semantic modes can be interpreted differently in different contexts by llms. for in-stance, as shown in figure 1 , the demonstration s1 has three different semantic modes: (1) enhancement/reduction of software functionality; to investigate the impact of demonstration ambiguity, we conduct comprehensive experiments on varying degrees of semantic ambiguity, across different models and datasets. specifically, we first design a semantic ambiguity score which can evaluate the divergence of a demonstration's semantic mode across various contexts. in this way, a low ambiguity score indicates a demonstration will have a stable semantic mode and therefore is less likely to be interpreted differently in differing contexts by llms. based on the above measure, our findings revealed a strong correlation between the semantic ambiguity of demonstration and the performance fluctuation of icl. that is, given a demonstration, as its semantic ambiguity increases, it is more difficult for llms to select the correct semantic modes in in-context learning, which in turn leads to greater instability in performance. based on the above findings, we further propose two de-biasing strategies for in-context learning, named instance-free demonstration reordering and self-explanatory in-context learning, which can effectively help llms accurately select semantic modes and thus significantly reduce the demonstration bias. first, we propose a instance-free demonstration reordering method, which progressively selects demonstrations by maximizing the semantic ambiguity reduction of in-context demonstrations. second, we present the self-explanatory in-context learning framework, which generates explicit explanatory guidelines for each instance and then instructs llms to select appropriate semantic modes by following these guidelines. this self-explanatory mechanism enables llms to reflect their internal thinking, reasoning, and decision guidelines, and these explanatory guidelines can additionally instruct llms the semantic mode demonstrations want to convey. by instructing llms with better demonstration order and self-explanatory guidelines, llms can effectively address the semantic ambiguity problem and significantly reduce the demonstration bias of icl. we conducted experiments on six classification datasets, and the results verified the effectiveness of our methods. in summary, our contributions are as follows: ## semantic ambiguity in in-context learning in this section, we explore the impact of semantic ambiguity within demonstrations on in-context learning. in §2.1, we introduce the notion of a semantic ambiguity score to quantify the level of comprehension exhibited by llms for a given demonstration. then we conduct experiments to further validate our hypothesis in §2.2 and §2.3. ## instructing large language models to follow in-context demonstrations in §2.3, we demonstrate that semantic ambiguity within demonstrations poses challenges for large language models to extract appropriate semantic modes, affecting their capacity to fully comprehend internal tasks and resulting in fluctuations in incontext learning performance. expanding on these insights, this section elucidates our proposed methods designed to help llms improve capabilities to select correct semantic modes and thus mitigate demonstration bias. first, we propose instance-free demonstration reordering method in §3.1, then we present the self-explanatory in-context learning framework in §3.2. ## conclusion our study highlights the significant impact of semantic ambiguity within demonstrations on incontext learning, revealing its potential to introduce biases in predictions. to tackle this issue, we propose two tailored de-biasing strategies for incontext learning, named instance-free demonstration reordering and self-explanatory in-context learning, which effectively assist llms in accurately selecting semantic modes, thereby significantly mitigating demonstration bias. experiments conducted across six datasets verify the effectiveness of our approaches in substantially mitigating demonstration bias and enhancing the performance of in-context learning. our findings hold promise for significantly reducing or eliminating the burden on users seeking optimal demonstrations in real-world applications, thus enabling researchers to harness the in-context learning capabilities of large language models more effectively.