Introduction
In the development of Large Language Models (LLMs), bias is typically viewed as a detrimental characteristic to be mitigated. Whether manifesting as a preference for common tokens (label bias) or sensitivity to prompt phrasing, these inherent quirks often undermine the consistency of few-shot learning. However, recent research from Ping An Technology, Lanzhou University, and the University of Maryland proposes a paradigm shift: rather than calibrating or eliminating these biases, they can be leveraged as high-quality features for classification. Their proposed method, bias-kNN, utilizes an LLM’s biased output probabilities as input for a k-Nearest Neighbor (kNN) classifier, effectively transforming a model's perceived weakness into a robust asset for text classification.
The Challenge of LLM Biases
Few-shot performance in LLMs is notoriously unstable, often fluctuating based on example selection, ordering, and template wording. This instability is driven by several factors:
- Vanilla Label Bias: A tendency to favor tokens frequent in pre-training data (e.g., "Positive" over "Negative") regardless of the specific input.
- Domain Label Bias: Shifts in output distribution caused by the specific topic or domain of the text.
- Surface Form Competition: Overlap in probability space between semantically similar tokens (e.g., "Good" vs. "Great"), which complicates direct prediction.
Traditional calibration methods attempt to correct these biases using neutral inputs (like "N/A") to derive a global correction factor. However, such approaches often fail to capture the nuanced, sample-specific biases encountered during inference.
The bias-kNN Methodology
The bias-kNN approach simplifies the classification process by moving away from the standard practice of selecting the highest-probability token. The workflow consists of four primary stages:
- Feature Extraction: Input text is processed through the LLM using a standard template (e.g., "Review: [X] It was [Y]"). Instead of a single prediction, the model extracts the full probability distribution across designated "verbalizer" tokens.
- Datastore Construction: A small set of labeled examples ($m$ samples per class) is used to populate a datastore with their respective probability distributions and ground-truth labels.
- kNN Inference: For a new test sample, the system generates its probability distribution and identifies the $k$ most similar entries in the datastore using cosine similarity.
- Classification: The final label is assigned via a majority vote among the $k$ nearest neighbors.
Key Insights: Bias as a Discriminative Feature
A central finding of this research is that LLM bias possesses a distinct "directionality." Even when a model is heavily biased toward a specific category, the relative positioning of samples within the probability space remains highly informative.
Furthermore, the researchers discovered that normalized probability distributions serve as more effective feature vectors than raw logits, providing tighter clustering for the kNN search. This approach also offers superior stability compared to standard In-Context Learning (ICL), which is highly sensitive to the choice of few-shot examples.
Experimental Results and Robustness
Evaluated across six diverse classification tasks—including sentiment analysis (SST-2, MR, CR), topic classification (AGNews), and entailment (RTE)—bias-kNN consistently outperformed both zero-shot and standard ICL baselines. For instance, on the SST-2 dataset with GPT-2-large, bias-kNN achieved a mean accuracy of 79.5%, a significant improvement over the 63.3% achieved by standard ICL.
The method also demonstrated remarkable robustness to "verbalizer" selection. While standard prompting might fail if suboptimal words are chosen (e.g., "happy/sad" instead of "good/bad"), bias-kNN maintains high performance as the number of samples in the datastore increases. Additionally, cosine similarity was identified as the most effective distance metric for this application.
Conclusion and Future Directions
While bias-kNN provides a powerful, "plug-and-play" enhancement for few-shot learning, its effectiveness varies by task complexity, with simpler sentiment tasks showing greater gains than complex entailment tasks. Future research may explore the scalability of this approach to larger models (175B+ parameters) and instruction-tuned variants, where biases may be more complex or deeply embedded.
Summary updated