Abstract
Large language models (LLMs) have demonstrated impressive capabilities in various tasks using the in-context learning (ICL) paradigm. However, their effectiveness is often compromised by inherent bias, leading to prompt brittleness, i.e., sensitivity to design settings such as example selection, order, and prompt formatting. Previous studies have addressed LLM bias through external adjustment of model outputs, but the internal mechanisms that lead to such bias remain unexplored. Our work delves into these mechanisms, particularly investigating how feedforward neural networks (FFNs) and attention heads result in the bias of LLMs. By Interpreting the contribution of individual FFN vectors and attention heads, we identify the biased LLM components that skew LLMs' prediction toward specific labels. To mitigate these biases, we introduce UniBias, an inference-only method that effectively identifies and eliminates biased FFN vectors and attention heads. Extensive experiments across 12 NLP datasets demonstrate that UniBias significantly enhances ICL performance and alleviates prompt brittleness of LLMs.
Introduction
Large Language Models (LLMs) are notoriously sensitive to the way information is presented. A slight change in the order of examples, a minor tweak in formatting, or the choice of specific words can cause the model’s accuracy to fluctuate wildly. This phenomenon, known as "prompt brittleness," is a significant hurdle for the reliable deployment of LLMs in real-world scenarios.
Most existing solutions treat the LLM as a "black box," attempting to calibrate the final output probabilities to compensate for observed biases. However, these external "band-aids" do not address the root cause. UniBias shifts the focus inward, using mechanistic interpretability to identify the specific internal components—Feed-Forward Network (FFN) vectors and attention heads—that drive these biases and surgically neutralizing them during inference.
Identifying the Internal Drivers of Bias
The researchers utilized the Logit Lens technique to project the model's internal hidden states into the vocabulary space. This allowed them to see which tokens specific neurons were "thinking" about. Their investigation revealed two primary internal sources of bias:
- Hardcoded FFN Preferences: Certain FFN vectors were found to be essentially "hardcoded" to boost specific labels (e.g., always favoring "positive" or "Option A") regardless of the input context. These components create a baseline "noise" that skews the model's decision-making.
- "Lazy" Attention Heads: The study identified specific attention heads that act as primary drivers of recency bias. These heads consistently assign disproportionately high weights to the final example provided in a prompt, effectively ignoring the earlier context and leading the model to simply parrot the last label it saw.
The UniBias Framework
UniBias is an inference-only method that identifies and masks these biased components without requiring any retraining or fine-tuning. The pipeline identifies "bad actors" based on three key criteria:
- Relatedness: The component must actually contribute to the prediction of task-relevant labels.
- Bias: The component must show a consistent preference for one label over others.
- Low Variance: The component must be "stubborn," providing the same biased signal across different inputs.
Once these components are identified using a small support set (typically around 20 samples per class), UniBias applies a mask to set their contributions to zero during the forward pass. This removes the internal drivers of bias before they can influence the final output.
Experimental Results
The effectiveness of UniBias was tested across 12 diverse NLP datasets—including sentiment analysis (SST-2, MR), natural language inference (RTE), and reasoning (MMLU)—using model families such as Llama-2 (7B and 13B) and GPT-J.
Performance and Stability
UniBias consistently outperformed both standard In-Context Learning (ICL) and state-of-the-art calibration methods. On Llama-2 7B, UniBias achieved a 3.39% accuracy improvement over standard ICL.
More importantly, UniBias dramatically improved model stability. In tests where prompt formatting and example selection were varied, standard LLMs showed a variance in accuracy of up to 26%. With UniBias, this variance dropped to less than 4%, making the models significantly more robust to how a human phrases a prompt.
Zero-Shot Gains
Even in zero-shot settings where no examples are provided, UniBias proved beneficial. By identifying and removing components biased toward specific multiple-choice options (like a preference for "Option A"), the method improved performance on complex reasoning tasks like the MMLU.
Conclusion and Future Directions
UniBias demonstrates that prompt brittleness is not an inevitable trait of LLMs but a result of specific, identifiable internal components. By performing "internal surgery" rather than external calibration, UniBias provides a more direct and effective way to stabilize model behavior.
While the current method requires a small support set to identify biased components, future research aims to identify "globally biased" neurons that are task-independent. Disabling these components could lead to the creation of "Universal Unbiased LLMs" that are inherently robust across all applications.
Summary updated