Enhancing Self-Consistency and Performance of Pre-Trained Language Models through Natural Language Inference (2022)

Abstract: While large pre-trained language models are powerful, their predictions often lack logical consistency across test inputs. For example, a state-of-the-art Macaw question-answering (QA) model answers <i>Yes</i> to <i>Is a sparrow a bird?</i> and <i>Does a bird have feet?</i> but answers <i>No</i> to <i>Does a sparrow have feet?</i>. To address this failure mode, we propose a framework, Consistency Correction through Relation Detection, or <b>ConCoRD</b>, for boosting the consistency and accuracy of pre-trained NLP models using pre-trained natural language inference (NLI) models without fine-tuning or re-training. Given a batch of test inputs, ConCoRD samples several candidate outputs for each input and instantiates a factor graph that accounts for both the model’s belief about the likelihood of each answer choice in isolation and the NLI model’s beliefs about pair-wise answer choice compatibility. We show that a weighted MaxSAT solver can efficiently compute high-quality answer choices under this factor graph, improving over the raw model’s predictions. Our experiments demonstrate that ConCoRD consistently boosts accuracy and consistency of off-the-shelf closed-book QA and VQA models using off-the-shelf NLI models, notably increasing accuracy of LXMERT on ConVQA by 5% absolute. See the project website (https://ericmitchell.ai/emnlp-2022-concord/) for code and data.

## introduction reliable and trustworthy ai systems should demonstrate internal self-consistency, in the sense that their predictions across inputs should imply logically compatible beliefs about the world. however, even powerful large language models are known to lack self-consistency @xcite @xcite . for example, a question-answering (qa) model that answers the question is a sparrow a bird? and does a bird have 1 https://ericmitchell.ai/emnlp-2022-concord/ feet? with yes is implicitly expressing the belief that a sparrow is a bird and a bird has feet. if the same model answers the question does a sparrow have feet? with no, the model expresses the logically incompatible belief a sparrow does not have feet. in such cases, ascertaining the model's "true" belief is difficult, making interpreting and validating its behavior correspondingly challenging. prior work has improved model self-consistency by training with specialized loss functions @xcite or data augmentation @xcite , or alternatively re-ranking model predictions based on their mutual self-consistency using pre-written logical constraints, such as "all mammals have fur" @xcite . however, the first class of methods requires expensive fine-tuning which might be impractical for many practitioners for very large pre-trained models, and re-ranking methods require an explicit collection of the logical relations of interest, making scaling a challenge. still, re-ranking-based approaches have the benefit of not requiring fine-tuning, and we hypothesize that their scalability limitations may be addressed by estimating logical relationships between model predictions on the fly. specifically, we hypothesize that existing pre-trained natural language inference (nli) models can estimate logical relationships between an arbitrary pair of model predictions well enough to provide an effective, scalable substitute for explicit collection of such constraints. leveraging these estimated constraints, we can construct a factor graph representing a probability distribution over model outputs that incorporates both the original model's confidence scores and the nli model's beliefs about logical relationships. our primary contribution is consistency correction through relation detection, or concord, a framework to improve the consistency and performance of a pre-trained base language model without fine-tuning by using more confident and better attested model predictions to override less confident model beliefs. see figure 1 for an overview. to enable propagation of model beliefs, we estimate pair-wise logical relationships between model predictions using a pre-trained nli model. using these pair-wise relationships, we define an undirected graphical model representing a distribution over responses accounting for both the base model's beliefs and the nli model's estimates of answer compatibility. we efficiently find the approximate mode of this distribution among the base model's top answer choices for each input as the solution of a maxsat problem, which consistently produces more accurate and self-consistent predictions than using the raw model predictions. in section 4.1 we find that concord produces an 8.1% absolute improvement in f1 of a pre-trained macaw model @xcite on the beliefbank qa dataset @xcite . in section 4.2 we find a 5.0% absolute improvement in accuracy of a pre-trained lxmert model @xcite on the convqa dataset @xcite , and in section 4.3 we find that con-cord enables test-time model editing @xcite , updating model predictions at test time when presented with new information. ## related work prior work for maintaining consistency in the question-answering space often involves additional training to improve performance. @xcite transform the natural questions @xcite dataset question-answer pairs into premise-hypothesis pairs, then uses an nli model trained on this dataset as a decider for unanswerable questions. @xcite generate questions from unlabeled texts, then filter them to ensure roundtrip consistency; pre-training on this synthetic set improves performance on squad 2.0 @xcite and natural questions. @xcite augment qapairs with their logically symmetric and transitive counterparts through linguistic approaches to enhance cross-dataset qa performance. concord differs significantly from these question-answeringspecific approaches because no fine-tuning of the base model is needed and the methodology is not specific to question-answering. similarly to concord, @xcite re-rank model predictions by solving an optimization problem defined by a combination of the base model confidence scores and pair-wise constraints representing the logical compatibility of different model predictions stored in a persistent memory, which they call beliefbank. the key distinguishing property of concord is the fact that pair-wise constraints between model predictions are dynamically estimated by a pre-trained nli model, rather than drawn from a fixed, pre-collected set of constraints. dynamically estimating the constraints has a variety of benefits, eliminating the need for manually collecting the logical constraints of interest, automating the process of determining whether a particular constraint applies to a particular pair of predictions, and likely inheriting improvements in natural language inference (nli, maccartney and manning ( 2008 )) models over time. nli has long been used to maintain logical consistency in generated dialogue utterances @xcite @xcite , radiology report domain entities @xcite , and summarization @xcite . perhaps most similarly, @xcite use nli to estimate constraints between factual statements produced by gpt-3. these prior approaches support our intuition for using nli models to improve logical consistency among batches of answers. while the authors explore applications of this framework to multi-step reasoning for true/false questions or statements, our work focuses on applying this methodology to more gen-figure 2 : an example factor graph for a simplified batch with two questions, @xmath0. although tbilisi is the most likely answer for both questions, the assignment of variables that is best under the estimated contradiction constraint flips the answer to the first question to kabul. the top-2 answer choices for each question are sampled from the base model, and a soft contradiction constraint is detected between variables z1 (representing the truth of the answer tbilisi for q1) and z3 (representing the truth of the answer tbilisi for q2). ## consistency correction through relation detection concord contains three key components, the base model, a relation model (typically a pre-trained nli model), and an inference procedure that combines the predictions of the two models into a more accurate and self-consistent set of beliefs. importantly, both the base model and relation model are pre-trained, off-the-shelf models; concord does not update any weights or require training data for either model, using only a small validation set for hyperparameter tuning. we next explain the function of each of these components when executing concord. ## experiments our experiments are broadly designed to answer the high-level question: can concord leverage the relational knowledge in pre-trained nli models to produce more accurate, self-consistent system behavior, without additional data or fine-tuning? further, we investigate concord's applicability to performing test-time model editing @xcite , or injection of new information, and concord's sensitivity to the choice of hyperparameters and types of relations detected. ## discussion & conclusion we have presented the concord framework for enforcing self-consistency in pre-trained language models using relations estimated by pre-trained nli models, showing that it improves over off-theshelf performance in a variety of settings without requiring any fine-tuning. our findings suggest that existing pre-trained nli models can be a useful building block for boosting performance of nlp systems by providing useful estimates of logical relationships between model predictions across various models and datasets for qa and visual qa. concord also suggests several directions for future work. integrating concord with meth-