Fast Few-shot Debugging for NLU Test Suites (2022)

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.

## introduction when deep transformer models make mistakes, ml engineers have had little recourse but to collect a better training set and hope the problem is fixed. adversarial datasets have exposed a variety of phenomena under which models trained on common datasets fail, particularly for question answering and natural language inference @xcite @xcite @xcite . they have provided new test data to expose problems but not always new training data to correct them. recently, the natural language processing community has adopted methodologies inspired by software development for probing and testing the capabilities of a model. @xcite introduce checklist, which helps users to develop test suites of examples, organized by capability. collecting hundreds or thousands of examples for each error phenomenon is slow, expensive, and not always feasible. in this paper, we investigate how just a few examples of a phenomenon ("debugging examples", which were not in the original dataset) can be utilized to correct a model. the goal is higher accuracy on the phenomenon ("debugging accuracy") while retaining accuracy on the original dataset ("original accuracy"). this problem differs from domain adaptation and few-shot learning because performance must be maintained on original examples, and no new classes are introduced. we repurpose published test suites for several natural language understanding (nlu) tasks as debugging problems, not just diagnostics. we identify methods that can update a model using a few debugging examples without the expense of iterating over the whole original training set. we introduce a new fast method that samples in-danger examples from the original training set to obtain even better original accuracy for comparable debugging accuracy. ## related work two recent works @xcite study how to modify transformer language models so that they store updated facts, testing their approaches on downstream tasks such as zero-shot relation extraction and closed-book fact checking. to apply these methods, one is given a modified fact as an example to train on, and one must predict the modified fact correctly (success rate) while achieving low performance deterioration on the original test set. because success rate is measured on just one example which is available at training time, to determine whether the update really generalizes, de cao et al. (2021) also measures equivalence accuracy, which reflects accuracy on paraphrases of the updated fact. by contrast, our setting provides ten examples (not just one) for a phenomenon where the predictions are to be updated. the phenomenon being debugged may involve deeper semantics than a factoid update, which usually requires only a reassociation of particular words that appear in the example. we assume we are given a testing set for the phenomenon, so we can measure generalization by directly measuring accuracy on the testing examples instead of paraphrasing the training examples. despite these differences, ideas from these papers provide relevant ideas that can be used in our debugging setting as well. one baseline considered by @xcite , which we call intensive finetuning, simply takes the updated facts (for us, the debugging training set) and repeatedly performs gradient descent updates on them until they are classified correctly. the proposed approach of @xcite is to minimize loss on the updated facts (the debugging set) subject to either an l ∞ or l 2 constraint on the difference of the model parameters. we consider these as baselines. as de cao et al. (2021) observe, constraining the norm of the parameter update is only loosely tied to how a parameter change can affect the output of a model. for this reason they introduce an approach based on constraining the kullback-leibler divergence between the updated model and the original. their proposed method trains a hypernetwork to read a single updated example and make a change minimizing debugging loss subject to the kullback-leibler divergence constraint. that does not apply as well to our scenario of multiple debugging examples, but we borrow the idea of using kullback-leibler divergence to incentivize similar predictions in a more straightforward baseline. @xcite introduce a meta-learning method for making a model that will preserve original accuracy when performing a series of gradient descent steps to change the label of any particular example. we are interested in methods that can be applied to any model, and for real debugging it is not necessary that all examples be easily relabeled. contemporaneously to our work, @xcite investigate few-shot debugging on error categories that are apparently too broad to be corrected with just a few examples. although they report some success with feature matching methods such as prototypical networks @xcite , they either suppose that test examples are identified as needing a correction or not (i.e. debugging or original), more like domain adaptation, or else train the prototypical network on a combined training set, which is the slowness we are trying to avoid. our setting requires a single model that can be applied to all examples without source information. ## method we suppose we are given a model p θ (x, y) trained on training set x. we are also given debugging training set x , and original test set x test and debugging test set x test . these four sets are pairwise disjoint. we consider the cross-entropy loss l(x, y; θ) = -p θ (x, y) log p θ (x, y). our method initializes θ 0 = θ and then performs intensive fine-tuning on the debugging set x , by performing adam (kingma and ba, 2015) iterations θ t+1 = adam(l, x , θ t ) where adam(l, s, θ) represents the parameter update achieved by training θ with respect to the loss l over a complete epoch on s. intensive fine-tuning stops at the mini- collecting w is a fast process involving iterating through a random shuffle of x and stopping when the required number of examples is retrieved. the expected iteration time depends only on the error rates and correlation of the errors of the models and not on the size of the original training set |x|. finally we restart from the original parameters θ and intensively fine-tune using the set x ∪ w . we take θ 0 = θ and iterate adam our data splits and our code for extracting examples from checklist are available for download. 1 for hans we use the bert cased model and for checklist we use the uncased model. ## conclusion we study the new problem of few-shot debugging natural language understanding problems on narrowly defined test suites, addressing a real-life need not addressed by past benchmark datasets. intensive fine-tuning on debugging examples with a few newly misclassified examples is substantially faster than full epoch retraining, and retains superior accuracy on the original dataset in more of our tests than any other fast method, for competitive debugging accuracy. kullback-leibler regularization may achieve better debugging accuracy, but its original accuracy is lagging, probably because it samples randomly rather than focusing on the newly misclassified examples that the debugging examples are opposed to. our results suggest a way for practitioners to quickly address problems in deployed systems and inspire the search for more refined ways of using debugging information. to further this research, there is a need for test suites that are not constructed by templates, so that the debugging phenomena are less easily learned, and yet not too broad to be taught in the few-shot setting. this limitation forced us to focus on relatively small differences in accuracy. because our method requires only a few debugging examples, it should be practical to construct test suites by hand or by manually organizing existing misclassifications. a test suites hans. the multi-genre natural language inference (mnli) dataset @xcite tests natural language inference in multiple domains, such as fiction, letters, telephone speech, and government reports. it is framed as a three-class classification problem of pairs of sentences, as entailment, neutral, or contradiction. mnli provides matched and mismatched development and test sets, in which the mismatched setting tests domains not present in the training data. here we consider a model trained on mnli and take its accuracy on the matched development set as a measure of its original performance. hans @xcite is a dataset that compiles phenomena that may not be adequately learned from the mnli training set. three heuristics (lexical overlap, sequence, or constituent) for generating challenging examples are considered, each with ten subcases, for a total of thirty subcases. templates are used to generate one thousand training and one thousand test examples for each. for our experiments, we individually consider the five subcases on which the mnli model attains the lowest accuracy before debugging. since we are interested in few-shot debugging, we randomly take ten of the hans training examples for a subcase as our debugging set x but use the rest (990) as x test for testing debugging performance. hans examples are labeled only as entailment or non-entailment, without specifying whether the non-entailments should be contradiction or neutral classifications. when training on a non-entailment example, we backpropogate through a logit representing the total non-entailment probability specified by the three-class model checklist. checklist (ribeiro et al., 2020) compiles test suites for sentiment analysis (sst-2) and duplicate question detection (qqp), two datasets which can be found in the glue benchmark @xcite . sst-2 binarizes classifications from stanford sentiment treebank @xcite into positive or negative, but some test suites of checklist utilize a neutral target label. we eliminate such test suites. some test suites of checklist test invariance or directional properties of classifications (e.g. whether two examples are classified with the same label, without specifying what that label should be) and we eliminate those as well, focusing only on suites with given labels for each example. we are left with three suites on which accuracy of the base sst-2 model before debugging is worse than the overall sst-2 accuracy. quora question pairs (qqp) is already a binary classification task and no adjustments to the test suites are needed. again, we consider only test suites consisting of individually labeled examples. we take the five suites where the base qqp model achieves lowest accuracy before debugging. for each suite, we randomly pick 10 examples for x and put the rest (usually about 1000) in x test . the full names of the tests utilized are as follows. for hans: cn_after_if_clause, sn_past_participle, cn_disjunction, ln_passive, and sn_np/s. for sst-2: used to but now, hard negation of positive with neutral stuff in the middle should be negative, and my opinion is what matters. for qqp: do you have to x your dog before y it, a or b is not the same as a and b, what was person's life before becoming x / what was person's life after becoming x, traditional srl wrong active passive swap, and traditional srl wrong active passive swap with people.