Posterior Differential Regularization with f-divergence for Improving Model Robustness

Hao Cheng, Xiaodong Liu, Lis Pereira, Yaoliang Yu, Jianfeng Gao

Abstract: Hao Cheng, Xiaodong Liu, Lis Pereira, Yaoliang Yu, Jianfeng Gao. Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies.

2021.

Introduction

While state-of-the-art Natural Language Processing (NLP) models like BERT demonstrate near-human performance on standard benchmarks, they often exhibit significant fragility when deployed in real-world scenarios. This brittleness typically manifests in two ways: domain shift, where the model encounters text from a different distribution (e.g., moving from Wikipedia to biomedical literature), and adversarial attacks, where intentional perturbations are introduced to deceive the model.

Research indicates that these failures occur because models often exploit superficial statistical biases in training data rather than developing a deep linguistic understanding. As illustrated in Figure 1, these vulnerabilities can lead to performance collapses ranging from 25% to 39% when models are tested outside their training domain or against adversarial distractors.

Performance drop between in-domain and out-of-domain/adversarial evaluations.

Methodology: Posterior Differential Regularization (PDR)

To address this, we propose Posterior Differential Regularization (PDR), a task-agnostic framework designed to enhance model smoothness and robustness. The core objective of PDR is to ensure that a model's predictions remain consistent even when the input is subjected to noise or perturbations.

The f-divergence Framework

PDR introduces a regularization term to the standard loss function that penalizes the difference between the model's posterior distribution for a clean input and its distribution for a perturbed (noisy) version of that same input. We generalize this approach using the family of $f$-divergences, including:

  • Kullback-Leibler (KL) Divergence
  • Squared Hellinger Distance (SHL)
  • Jensen-Shannon Divergence (JSD)

The Jacobian Connection and Adaptive Regularization

A key theoretical contribution of this work is the mathematical link between $f$-divergence regularization and Jacobian Regularization. We demonstrate that regularizing with $f$-divergences is equivalent to a weighted version of Jacobian Regularization, where the penalty is scaled by the model's confidence (posterior probabilities). This adaptivity allows the model to enforce stricter smoothness when it is confident and allow more variance when it is uncertain, leading to more efficient learning of robust features.

We evaluate two primary perturbation strategies: Random Perturbation Training (RPT), which utilizes simple random noise, and Virtual Adversarial Training (VAT), which identifies the "worst-case" noise direction to challenge the model during training.

Experimental Evaluation

We tested the PDR framework across three core NLP tasks:

  1. Question Answering (QA): Models trained on SQuAD v1.1/v2.0 were evaluated on BioASQ (domain shift) and Adversarial SQuAD.
  2. Natural Language Inference (NLI): Models trained on MNLI were evaluated on the HANS dataset, which specifically targets syntactic heuristics.
  3. Sentiment Analysis: Models trained on SST-2 were evaluated on the IMDB dataset (domain shift).

Key Results in Adversarial Defense

The impact of PDR is most pronounced in adversarial settings. As shown in Table 4, a standard BERT-base model achieves only 58.4% accuracy on the HANS dataset. By applying VAT with KL-divergence ($VAT_{KL}$), accuracy jumps to 67.7%. Remarkably, this allows the BERT-base model (110M parameters) to nearly match the performance of the much larger BERT-large model (340M parameters), which scores 67.9%.

Performance on adversarial datasets (AddSent, AddOneSent, HANS).

Domain Transfer and In-Domain Performance

In domain shift scenarios, such as the BioASQ (QA) task, PDR improved the F1 score from 57.1 to 61.8. Crucially, unlike many robustness techniques that sacrifice standard accuracy for stability, PDR consistently improved in-domain performance across nearly all datasets. Furthermore, the framework proved highly effective in semi-supervised settings; models trained on only 50% of labeled data using PDR on additional unlabeled data matched the performance of models trained on 100% of the labels.

Conclusion

Posterior Differential Regularization provides a mathematically grounded and effective method for closing the robustness gap in NLP. By utilizing confidence-weighted $f$-divergence penalties, PDR enables smaller models to achieve the stability and performance of significantly larger architectures. Future work will explore the application of this framework to weakly supervised learning tasks where labeled data is inherently noisy or scarce.

Summary updated

BibTeX
@inproceedings{cheng2021posterior,
  author = {Hao Cheng and Xiaodong Liu and Lis Pereira and Yaoliang Yu and Jianfeng Gao},
  title = {{Posterior Differential Regularization with f-divergence for Improving Model Robustness}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2021},
  url = {https://openreview.net/forum?id=r85-Ro3OZZ9},
}
Figure