[Paper Review] Understanding and Mitigating Spurious Correlations in Text Classification with Neighborhood Analysis
This paper introduces neighborhood analysis to understand how pre-trained language models learn spurious correlations in text classification, revealing that spurious tokens cluster with genuine sentiment words in embedding space. It proposes NFL (Do Not Forget Your Language), a regularization method that preserves semantic alignment and significantly improves model robustness on out-of-distribution data without auxiliary data.
Recent research has revealed that machine learning models have a tendency to leverage spurious correlations that exist in the training set but may not hold true in general circumstances. For instance, a sentiment classifier may erroneously learn that the token "performances" is commonly associated with positive movie reviews. Relying on these spurious correlations degrades the classifiers performance when it deploys on out-of-distribution data. In this paper, we examine the implications of spurious correlations through a novel perspective called neighborhood analysis. The analysis uncovers how spurious correlations lead unrelated words to erroneously cluster together in the embedding space. Driven by the analysis, we design a metric to detect spurious tokens and also propose a family of regularization methods, NFL (doN't Forget your Language) to mitigate spurious correlations in text classification. Experiments show that NFL can effectively prevent erroneous clusters and significantly improve the robustness of classifiers without auxiliary data. The code is publicly available at https://github.com/oscarchew/doNt-Forget-your-Language.
Motivation & Objective
- To understand why and how pre-trained language models learn spurious correlations that degrade generalization on out-of-distribution data.
- To analyze the role of embedding space neighborhood structures in the emergence of spurious token clustering during fine-tuning.
- To develop a practical, data-free method for detecting spurious tokens using neighborhood-based spuriousness scoring.
- To design a regularization framework, NFL, that prevents models from mis-aligning representations of spurious and genuine tokens during fine-tuning.
Proposed method
- Conduct neighborhood analysis by comparing the nearest neighbors of tokens in the embedding space before and after fine-tuning to detect misalignment indicative of spurious correlation.
- Propose a spuriousness score based on the divergence in neighborhood composition of a token pre- and post-fine-tuning, identifying tokens that cluster with unrelated but semantically similar terms.
- Design NFL (Do Not Forget Your Language), a family of regularization techniques that constrain parameter or output changes during fine-tuning to preserve semantic structure.
- Apply NFL by regularizing either the model’s attention weights or output logits to prevent over-reliance on spurious tokens.
- Use off-the-shelf pre-trained language models (e.g., RoBERTa) as the base, assuming they are free from downstream label bias due to self-supervised pretraining.
- Evaluate detection and mitigation performance on real-world datasets (SST2, Amazon, Jigsaw) without requiring unbiased or auxiliary datasets.
Experimental results
Research questions
- RQ1How do spurious correlations manifest in the embedding space of fine-tuned language models?
- RQ2To what extent do spurious tokens cluster with genuine, label-relevant tokens in the embedding space after fine-tuning?
- RQ3Can neighborhood analysis in the embedding space be used to reliably detect spurious tokens without requiring unbiased or auxiliary datasets?
- RQ4Can regularization methods that preserve semantic alignment in embeddings mitigate spurious correlation and improve out-of-distribution robustness?
- RQ5How does NFL compare to existing detection and mitigation methods in terms of precision and practicality?
Key findings
- Neighborhood analysis reveals that spurious tokens like 'performances' and 'gay' form misleading clusters with genuine sentiment or offensive words in the embedding space after fine-tuning.
- The proposed spuriousness score detects naturally occurring spurious tokens with high precision—comparable to prior methods—without requiring multiple datasets or unbiased data.
- NFL regularization significantly improves model robustness, achieving out-of-distribution performance nearly matching in-distribution performance on sentiment and toxicity classification.
- The method effectively prevents erroneous alignment of spurious and genuine tokens, reducing reliance on superficial correlations.
- Experiments show that NFL improves generalization without requiring additional data, making it a practical and effective mitigation strategy.
- Human evaluation confirms that top-ranked spurious tokens detected by the method (e.g., 'Canada', 'witches') are indeed contextually misleading and likely to mislead models.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.