Fast Few-shot Debugging for NLU Test Suites

Christopher Malon, Kai Li, Erik Kruus

Introduction

Deep learning models for Natural Language Understanding (NLU), such as BERT, frequently exhibit systematic "blind spots." For instance, a sentiment analysis model might consistently fail on sentences involving negation with neutral words, or a natural language inference (NLI) model might rely on simplistic word-overlap heuristics rather than true semantic understanding.

Traditionally, addressing these bugs required the labor-intensive collection of thousands of new examples followed by full model retraining—a process that is computationally expensive and slow. Conversely, simple fine-tuning on a few "debugging" examples often leads to catastrophic forgetting, where the model fixes the specific bug but loses general accuracy on its original task. This paper proposes a "fast few-shot debugging" method that balances the speed of fine-tuning with the stability of full retraining.

Methodology: "In-danger" Sampling

The authors introduce a novel sampling strategy to mitigate catastrophic forgetting during rapid updates. While standard intensive fine-tuning repeatedly updates the model on a small set of debugging examples ($X'$) until they are mastered, the proposed method identifies and protects vulnerable knowledge:

  1. Dry Run: Perform a temporary update on the debugging examples.
  2. Identify "In-danger" Examples: Scan the original training set to find examples ($W$) that the model correctly classified before the update but failed after the dry run.
  3. Surgical Fine-tuning: Restart from the original model and fine-tune on the combined set of debugging examples and these specific "in-danger" samples ($X' \cup W$).

This approach ensures that the model retains the specific original knowledge most threatened by the new information.

Experimental Setup

The method was evaluated using two primary NLU test suites:

  • HANS (Heuristic Analysis for NLI Systems): Targets linguistic traps in MNLI models, such as lexical overlap heuristics.
  • CheckList: Probes sentiment analysis (SST-2) and duplicate question detection (QQP) for capabilities like handling passive voice or taxonomies.

For each phenomenon, only 10 examples were used for debugging, with approximately 990 unseen examples used to test generalization.

Results and Discussion

Performance and Stability

The proposed method achieved a superior balance between fixing bugs and maintaining original task performance. As shown in Figure 1, the method is sensitive to the number of shots; while 5 examples are often insufficient for reliable debugging, 10 to 20 examples provide a stable and effective fix.

Original vs. Debugging Accuracy across different shot counts.

In the HANS "Passive" suite, the model's accuracy jumped from a baseline of 0.4% to 99.4% after 10-shot debugging. Crucially, the original MNLI accuracy only experienced a marginal decline from 83.8% to 83.2%, outperforming other fast constraint-based methods (see Table 1).

Performance comparison on HANS test suites showing debugging and original accuracy pairs.

Efficiency

The primary advantage of this approach is its operational speed. The "in-danger" sampling method typically finishes in about 25 seconds. Compared to "slow" methods like oversampling or full retraining, which can take between 3.5 and 7 hours, this represents a 60x to 720x speedup.

Conclusion and Future Work

Fast few-shot debugging proves that models can learn underlying linguistic rules from very few examples without memorizing specific shots. While highly effective, the authors note that future work should explore non-template-based test suites to ensure these fixes generalize to natural linguistic variety. Additionally, scaling the method to handle dozens of simultaneous phenomena remains a key challenge for production environments.

Summary updated

Abstract

We study few-shot debugging of transformer based natural language understanding models, using recently popularized test suites to not just diagnose but correct a problem. Given a few debugging examples of a certain phenomenon, and a held-out test set of the same phenomenon, we aim to maximize accuracy on the phenomenon at a minimal cost of accuracy on the original test set. We examine several methods that are faster than full epoch retraining. We introduce a new fast method, which samples a few in-danger examples from the original training set. Compared to fast methods using parameter distance constraints or Kullback-Leibler divergence, we achieve superior original accuracy for comparable debugging accuracy.
BibTeX
@inproceedings{malon2022fast,
  author = {Christopher Malon and Kai Li and Erik Kruus},
  title = {{Fast Few-shot Debugging for NLU Test Suites}},
  booktitle = {DeeLIO @ ACL},
  year = {2022},
  doi = {10.18653/v1/2022.deelio-1.8},
}
Figure