EMNLP2021
Editing Factual Knowledge in Language Models
Nicola De Cao, Wilker Aziz, Ivan Titov
20 citations
Abstract
The factual knowledge acquired during pretraining and stored in the parameters of Language Models (LMs) can be useful in downstream tasks (e.g., question answering or textual inference). However, some facts can be incorrectly induced or become obsolete over time. We present KNOWLEDGEEDITOR, a method which can be used to edit this knowledge and, thus, fix 'bugs' or unexpected predictions without the need for expensive retraining or fine-tuning. Besides being computationally efficient, KNOWLEDGEEDITOR does not require any modifications in LM pretraining (e.g., the use of meta-learning). In our approach, we train a hyper-network with constrained optimization to modify a fact without affecting the rest of the knowledge; the trained hyper-network is then used to predict the weight update at test time. We show KNOWL-EDGEEDITOR's efficacy with two popular architectures and knowledge-intensive tasks: i) a BERT model fine-tuned for fact-checking, and ii) a sequence-to-sequence BART model for question answering. With our method, changing a prediction on the specific wording of a query tends to result in a consistent change in predictions also for its paraphrases. We show that this can be further encouraged by exploiting (e.g., automatically-generated) paraphrases during training. Interestingly, our hyper-network can be regarded as a 'probe' revealing which components need to be changed to manipulate factual knowledge; our analysis shows that the updates tend to be concentrated on a small subset of components. 1 How is Namibia's capital city called? Semantically equivalent Answers Scores Namibia Nigeria Nibia Namibia Tasman -0.43 -0.69 -0.89 -1.08 -1.19 What is the capital of Namibia? Answers Scores Namibia Nigeria Nibia Tasman Namibia -0.32 -0.79 -0.87 -1.14 -1.16 What is the capital of Russia? Answers Scores Moscow Nashville Ufa Kiev Nashua -0.55 -0.97 -1.22 -1.28 -2.09 Another fact (a) Model predictions before the update. Fact to change Fact that also changes How is Namibia's capital city called? Answers Scores Windhoek Tasman Windygates Tasmania Windhoof -0.06 -1.42 -1.52 -1.59 -1.66 What is the capital of Namibia? Answers Scores Windhoek Tasman Windygates Windhoof Tasmania -0.07 -1.50 -1.51 -1.53 -1.53 What is the capital of Russia? Answers Scores Moscow Ufa Nashville Kiev Nashua -0.56 -1.03 -1.04 -1.43 -2.21 Another fact (b) Model predictions with edited parameters. Figure 2: Predictions from a pre-trained language BART model fine-tuned for closed-book question answering. Left: model top-k predictions from Beam Search. Right: top-k after using our method conditioning on changing 'What is the capital of Namibia?' from 'Namibia' (wrong) to 'Windhoek' (correct prediction). Changing one fact also changes a semantically equivalent question and keeps the predictions from other facts the same.