Posterior Differential Regularization with f-divergence for Improving Model Robustness

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

Abstract

We address the problem of enhancing model robustness through regularization. Specifically, we focus on methods that regularize the model posterior difference between clean and noisy inputs. Theoretically, we provide a connection of two recent methods, Jacobian Regularization and Virtual Adversarial Training, under this framework. Additionally, we generalize the posterior differential regularization to the family of $f$-divergences and characterize the overall regularization framework in terms of Jacobian matrix. Empirically, we systematically compare those regularizations and standard BERT training on a diverse set of tasks to provide a comprehensive profile of their effect on model in-domain and out-of-domain generalization. For both fully supervised and semi-supervised settings, our experiments show that regularizing the posterior differential with $f$-divergence can result in well-improved model robustness. In particular, with a proper $f$-divergence, a BERT-base model can achieve comparable generalization as its BERT-large counterpart for in-domain, adversarial and domain shift scenarios, indicating the great potential of the proposed framework for boosting model generalization for NLP models.

Introduction: The Brittleness of NLP Models

State-of-the-art NLP models like BERT are incredibly powerful but notoriously "brittle." While they perform near human-level on standard benchmarks (in-domain), their performance often collapses when faced with domain shift (e.g., moving from Wikipedia text to biomedical articles) or adversarial attacks. These attacks involve small, intentional perturbations—like adding a distracting sentence—that do not change the meaning for a human but can completely confuse the model.

Performance degradation of standard BERT-base models when moving from in-domain to out-of-domain/adversarial settings.

Existing techniques like Jacobian Regularization (JR) and Virtual Adversarial Training (VAT) attempt to fix this by "smoothing" the model's output. However, a clear theoretical connection between these methods and a generalized framework for handling model uncertainty was previously lacking.

Proposed Framework: Posterior Differential Regularization

This paper introduces Posterior Differential Regularization, which adds a penalty term to the loss function that minimizes the "distance" between the model's prediction for a clean input $x$ and a noisy version $\hat{x}$.

Key Innovations

  • The $f$-divergence Family: Instead of relying solely on standard metrics like KL-divergence, the approach generalizes regularization to the entire family of $f$-divergences, including Squared Hellinger and Jensen-Shannon.
  • Theoretical Bridge: The authors prove that regularizing with $f$-divergence is mathematically equivalent to an adaptive version of Jacobian Regularization. While standard JR treats all output classes the same, $f$-divergence weighting rescales the Jacobian matrix based on the model's confidence.
  • RPT vs. VAT: The framework compares Random Perturbation Training (RPT), which uses random noise, against Virtual Adversarial Training (VAT), which uses an inner loop to find the "worst-case" noise direction.

Experimental Evaluation

The researchers evaluated their framework across three major NLP tasks:

  • Question Answering (QA): Trained on SQuAD v1.1/v2.0; evaluated for domain shift on BioASQ and adversarial robustness on Adversarial SQuAD.
  • Natural Language Inference (NLI): Trained on MNLI; evaluated on the HANS dataset, which tests if models rely on simple word-overlap heuristics.
  • Sentiment Analysis: Trained on SST-2; evaluated for domain shift on the IMDB movie review dataset.

Results and Discussion

The experiments reveal that $f$-divergence regularization acts as a "force multiplier," allowing smaller models to achieve performance levels previously reserved for much larger architectures.

Performance comparison under adversarial attacks, showing significant gains for VAT-regularized models.

Key Insights

  • Closing the Gap: On the SQuAD v1.1 benchmark, BERT-base with VAT regularization achieved an F1 score of 90.2, nearly matching the 90.9 score of the much larger BERT-large model.
  • Adversarial Defense: On the HANS dataset (NLI), standard BERT-base achieves ~58% accuracy. Applying VAT with KL-divergence boosted this to 67.7%, a massive jump in robustness against heuristic-based traps.
  • Confidence-Weighted Smoothing: The discovery that $f$-divergence regularization is "smart" is central to the paper. It enforces more stability on classes where the model is already confident and allows more variance where the model is uncertain, preventing over-fitting to noisy signals.
  • Efficiency Gains: Regularization allows a BERT-base model (110M parameters) to match the robustness of a BERT-large model (340M parameters), which has significant implications for deploying models on edge devices with limited memory.

Conclusion

While VAT requires an "inner loop" to calculate adversarial directions—increasing training time compared to standard fine-tuning—the gains in robustness and data efficiency are substantial. In semi-supervised settings, a model trained with only 50% of labeled data plus $f$-divergence regularization on unlabeled data performed as well as a standard model trained on the full 100% dataset. Future work may explore this framework for weakly supervised learning where the adaptive nature of $f$-divergence could be particularly useful.

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