A simple yet effective self-debiasing framework for transformer models

Xiaoyue Wang, Xin Liu, Lijie Wang, Suhang Wu, Jinsong Su, Hua Wu

Introduction

Transformer-based models like BERT and RoBERTa have revolutionized Natural Language Understanding (NLU). However, these models often exhibit a tendency to rely on "shortcuts"—statistical biases or heuristics present in training data—rather than learning deep semantic relationships. For instance, in paraphrase identification, a model might incorrectly predict that two sentences are duplicates simply because they share many words (lexical overlap). While this heuristic works for many standard datasets, it fails on Out-of-Distribution (OOD) data where such shortcuts are intentionally misleading.

The DeRC Framework

To address this, we introduce DeRC (Debiasing with a Residual Connection), a self-debiasing framework that leverages the internal hierarchy of Transformer models. Unlike previous methods that require manual bias identification or complex auxiliary models, DeRC is an architectural modification that forces the model to distinguish between biased and unbiased features.

The DeRC framework architecture.

The framework operates through a two-step training mechanism:

  1. Low-layer Representation Learning: A classifier ($f_b$) is attached to a specific low layer (typically layer 4). This classifier is trained to solve the task using only early-stage features, which are predominantly surface-level biases.
  2. Debiasing via Residual Connection: A residual connection passes the output of this low-layer classifier directly to the final top-layer classifier ($f_L$). By providing the "biased" prediction as an input to the final stage, the top-layer representation is incentivized to encode only the "residual" information—the complex semantic features that the low layer missed.

During training, gradient isolation is applied to the residual connection to prevent the top-layer loss from interfering with the low layer's ability to capture biases. At inference time, the residual connection is removed, and the model relies solely on the debiased top-layer representations.

Empirical Motivation

The design of DeRC is motivated by the observation that bias is not uniformly distributed across Transformer layers. Preliminary experiments on BERT show that while biased features (shortcuts) are present throughout the network, unbiased (task-relevant) features are significantly more concentrated in the higher layers.

Accuracy across BERT layers on biased vs. anti-biased data.

As shown in the figure above, the accuracy on "anti-biased" samples (where shortcuts lead to the wrong answer) is very low in early layers and only begins to climb in the latter half of the model. This confirms that low layers are ideal candidates for modeling dataset shortcuts.

Experimental Results

We evaluated DeRC across three major NLU tasks using standard In-Distribution (ID) training sets and specialized OOD test sets:

  • Natural Language Inference (NLI): Trained on MNLI and tested on HANS. DeRC improved accuracy by 10.3% over the BERT baseline.
  • Fact Verification (FactVer): Trained on FEVER and tested on FeverSymmetric. DeRC achieved a 7.5% improvement over BERT, setting a new state-of-the-art.
  • Paraphrase Identification (ParaIden): Trained on QQP and tested on PAWS. DeRC achieved a massive 26.3% improvement.

Conclusion

DeRC provides a simple, model-agnostic way to improve the robustness of Transformer models. By explicitly modeling biases in lower layers and using a residual connection to "subtract" them from the final prediction, the framework encourages the learning of true semantic features. Future work will explore the application of DeRC to generative tasks and a broader range of NLU challenges.

Summary updated

BibTeX
@article{wang2023simple,
  author = {Xiaoyue Wang and Xin Liu and Lijie Wang and Suhang Wu and Jinsong Su and Hua Wu},
  title = {{A simple yet effective self-debiasing framework for transformer models}},
  journal = {Artificial Intelligence},
  year = {2023},
  url = {https://openreview.net/forum?id=6tVUOeu0ul},
}
Figure