Introduction
Large Language Models (LLMs) have revolutionized natural language processing through In-context Learning (ICL), a paradigm where models perform tasks by observing a few examples within a prompt. Despite its success, ICL is notoriously sensitive to prompt engineering. Minor changes in phrasing or example selection can lead to drastic performance swings. This instability is often driven by "label bias," where a model develops a preference for certain output labels regardless of the actual input content. This paper identifies a previously overlooked category called domain-label bias and introduces Domain-context Calibration (DC), a robust method to neutralize these biases using the task's own vocabulary.
The Typology of Bias in ICL
To better understand why LLMs fail in few-shot settings, the authors categorize label biases into three distinct types:
- Vanilla Label Bias: The model’s inherent preference for specific words (e.g., "positive" over "negative") based on their frequency in pre-training data.
- Context-Label Bias: Bias introduced by the specific examples, their ordering, or the templates used within the prompt.
- Domain-Label Bias: A newly identified bias stemming from the word distribution of the task's specific corpus. For example, in a hate speech detection task, the presence of "Twitter-like" slang or specific social media jargon might lead the model to associate the entire domain with a "hateful" label, even when the input text is benign.
Existing calibration techniques often rely on a neutral string like "N/A" to estimate a model's prior bias. However, the authors demonstrate that these "content-free" strings fail to capture the domain-specific gravity that causes models to lean toward certain labels in specialized datasets.
Domain-context Calibration (DC)
The proposed solution, Domain-context Calibration (DC), replaces generic neutral strings with "domain-rich but semantically-null" inputs. Instead of using "N/A," DC samples random words directly from the unlabeled task dataset to create a baseline that reflects the domain's vocabulary without providing task-specific signal.
The DC Process:
- Sampling: Select $L$ random words from the task corpus, where $L$ matches the average input length of the test samples.
- Estimation: Feed these random strings into the model using the same ICL prompt template to observe the resulting label distribution.
- Averaging: Repeat this process over several iterations to calculate a stable "null" prior.
- Inference: During actual testing, the model's raw output probabilities are divided by this estimated prior to "re-center" the prediction, effectively subtracting the background noise of the domain bias.
Experimental Evaluation
The researchers evaluated DC across 24 text classification datasets, including sentiment analysis (SST-2, SST-5), Natural Language Inference (RTE, CB), and detection tasks (TweetEval, Ethos). The study utilized models ranging from GPT-J to GPT-3 (175B), as well as zero-shot prompting with RoBERTa-large.
Key Findings
- Significant Performance Gains: DC improved the average Macro-F1 of GPT-J by 20% and GPT-3 by 18% across the 24 datasets. The impact was most pronounced in high-bias detection tasks, such as hate speech detection, where gains reached up to 37%.
- The Failure of "N/A": The study revealed that "N/A" is not truly neutral. In sentiment tasks, calibrating with "N/A" actually increased GPT-J's bias toward the "positive" label. In contrast, random in-domain words provided a much more accurate baseline for calibration.
- Scaling and Bias: Larger models do not naturally outgrow these biases. In fact, GPT-3 175B was found to be just as susceptible to domain-label bias as smaller models. Increased scaling enhances the model's ability to form associations, which can inadvertently strengthen incorrect links between a domain's vocabulary and specific labels.
- Stability: DC significantly reduced the performance variance caused by different choices of in-context examples, making ICL a more reliable tool for practitioners.
Conclusion and Future Work
Domain-context Calibration offers a simple, effective, and training-free method to stabilize In-context Learning. By accounting for the specific vocabulary of a task, DC allows LLMs to focus on the actual semantic content of an input rather than being distracted by the "flavor" of the domain.
While highly effective for classification, the authors note that future research is needed to explore how domain-label bias affects open-ended generation tasks like summarization. Additionally, while DC addresses word-level domain bias, other forms of social or stereotypical bias may require complementary mitigation strategies. Nonetheless, DC represents a major step forward in making prompt-based learning more robust across diverse real-world applications.
Summary updated