Introduction
In-context learning (ICL) is the mechanism that allows Large Language Models (LLMs) to solve new tasks simply by observing a few examples in a prompt. Most research into ICL assumes "causal sufficiency"—the idea that the provided data contains all the necessary information to explain the relationship between inputs ($x$) and outputs ($y$).
However, real-world data is rarely so clean. We frequently encounter endogeneity, where hidden confounders (HCs)—unobserved factors influencing both inputs and labels—create spurious correlations. For instance, in sentiment analysis, "regional culture" might act as a hidden confounder affecting both the reviewer's vocabulary and their final rating. If a Transformer is pre-trained on such confounded data, it learns a biased "meta-weight," leading to predictable prediction bias during ICL.
This paper investigates whether pre-training on confounded data leads to biased ICL predictions and introduces a cost-effective, gradient-free method to mitigate this bias without expensive fine-tuning.
Methodology: Characterizing and Fixing Bias
Bias Characterization
The authors mathematically demonstrate that the bias in a Transformer's ICL prediction is proportional to the "confounding strength" of hidden variables. Interestingly, ICL bias behaves differently than standard statistical methods like Ordinary Least Squares (OLS). Because of the attention mechanism's geometry, ICL allows for natural "bias cancellation" across different feature dimensions under certain conditions.
Double-Debiasing (DDbias)
To address this bias, the paper introduces Double-Debiasing (DDbias), a two-step, gradient-free prompting strategy:
- Step 1: Prompt the biased, pre-trained Transformer with a small set of "unconfounded" examples (clean data free from hidden confounder interference) to generate a biased prediction ($\hat{y}_b$).
- Step 2: Prompt the model again, but use the residual (the difference between the true label and the biased prediction) as the target.
By providing residuals in the prompt, DDbias forces the model to perform an implicit gradient update that moves the prediction toward the unbiased truth, effectively "subtracting" the learned bias.
Datasets and Evaluation
The authors validated their theoretical findings using both synthetic and real-world datasets:
- Synthetic Regression: Environments with linear and non-linear data generation protocols where confounding strength could be precisely controlled.
- Real-World Yelp Datasets: Tasks included predicting foot traffic based on review sentiment (Restaurant Popularity Index, RPI) and predicting star ratings (Restaurant Overall Rating, ROR). In these datasets, factors like "location" or "socio-economic status" acted as hidden confounders.
Key Results
The empirical results strongly align with the theoretical predictions:
- Bias Confirmation: In synthetic tests, prediction error scaled linearly with confounding strength.
- Performance Gains: DDbias significantly outperformed vanilla models and complex causal baselines (like DMCEE). On the Yelp ROR task, vanilla LLaMA exhibited an error rate of 0.46. Applying DDbias with 60 ICL examples slashed that error to 0.16.
- Efficiency: DDbias proved more effective than traditional Instrumental Variable (IV) approaches, especially when valid "instruments" are difficult to identify. Furthermore, as the ratio of clean prompting samples to pre-training samples increases, the prediction bias consistently vanishes.
Limitations and Future Directions
While DDbias is highly effective and robust even if the "unconfounded" examples are slightly noisy, it still requires a human or secondary process to identify a small batch (15–60) of clean examples.
Additionally, much of the core theory is derived using linear self-attention. Although empirical evidence suggests DDbias works for non-linear, deeper Transformers (e.g., those using ReLU and Softmax), a comprehensive theoretical proof for the non-linear case remains an open challenge. Finally, exploring how these biases shift across different out-of-distribution (OOD) training and testing regimes is a promising next step for the community.
Summary updated