Editable Neural Networks

1 INTRODUCTION . Deep neural networks match and often surpass human performance on a wide range of tasks including visual recognition ( Krizhevsky et al . ( 2012 ) ; D. C. Ciresan ( 2011 ) ) , machine translation ( Hassan et al . ( 2018 ) ) and others ( Silver et al . ( 2016 ) ) . However , just like humans , artificial neural networks sometimes make mistakes . As we trust them with more and more important decisions , the cost of such mistakes grows ever higher . A single misclassified image can be negligible in academic research but can be fatal for a pedestrian in front of a self-driving vehicle . A poor automatic translation for a single sentence can get a person arrested ( Hern ( 2018 ) ) or ruin company ’ s reputation . Since mistakes are inevitable , deep learning practitioners should be able to adjust model behavior by correcting errors as they appear . However , this is often difficult due to the nature of deep neural networks . In most network architectures , a prediction for a single input depends on all model parameters . Therefore , updating a neural network to change its predictions on a single input can decrease performance across other inputs . Currently , there are two workarounds commonly used by practitioners . First , one can re-train the model on the original dataset augmented with samples that account for the mistake . However , this is computationally expensive as it requires to perform the training from scratch . Another solution is to use a manual cache ( e.g . lookup table ) that overrules model predictions on problematic samples . ∗Equal contribution While being simple , this approach is not robust to minor changes in the input . For instance , it will not generalize to a different viewpoint of the same object or paraphrasing in natural language processing tasks . In this work , we present an alternative approach that we call Editable Training . This approach involves training neural networks in such a way that the trained parameters can be easily edited afterwards . Editable Training employs modern meta-learning techniques ( Finn et al . ( 2017 ) ) to ensure that model ’ s mistakes can be corrected without harming its overall performance . With thorough experimental evaluation , we demonstrate that our method works on both small academical datasets and industry-scale machine learning tasks . We summarize the contributions of this study as follows : • We address a new problem of fast editing of neural network models . We argue that this problem is extremely important in practice but , to the best of our knowledge , receives little attention from the academic community . • We propose Editable Training — a model-agnostic method of neural network training that learns models , whose errors can then be efficiently corrected.1 • We extensively evaluate Editable Training on large-scale image classification and machine translation tasks , confirming its advantage over existing baselines . 2 RELATED WORK . In this section , we aim to position our approach with respect to existing literature . Namely , we explain the connections of Editable Neural Networks with ideas from prior works . Meta-learning is a family of methods that aim to produce learning algorithms , appropriate for a particular machine learning setup . These methods were shown to be extremely successful in a large number of problems , such as few-shot learning ( Finn et al . ( 2017 ) ; Nichol et al . ( 2018 ) ) , learnable optimization ( Andrychowicz et al . ( 2016 ) ) and reinforcement learning ( Houthooft et al . ( 2018 ) ) . Indeed , Editable Neural Networks also belong to the meta-learning paradigm , as they basically ” learn to allow effective patching ” . While neural network correction has significant practical importance , we are not aware of published meta-learning works , addressing this problem . Catastrophic forgetting is a well-known phenomenon arising in the problem of lifelong/continual learning ( Ratcliff ( 1990 ) ) . For a sequence of learning tasks , it turns out that after deep neural networks learn on newer tasks , their performance on older tasks deteriorates . Several lines of research address overcoming catastrophic forgetting . The methods based on Elastic Weight Consolidation ( Kirkpatrick et al . ( 2016 ) ) update model parameters based on their importance to the previous learning tasks . The rehearsal-based methods ( Robins ( 1995 ) ) occasionally repeat learning on samples from earlier tasks to ” remind ” the model about old data . Finally , a line of work ( Garnelo et al . ( 2018 ) ; Lin et al . ( 2019 ) ) develops specific neural network architectures that reduce the effect of catastrophic forgetting . The problem of efficient neural network patching differs from continual learning , as our setup is not sequential in nature . However , correction of model for mislabeled samples must not affect its behavior on other samples , which is close to overcoming catastrophic forgetting task . Adversarial training . The proposed Editable Training also bears some resemblance to the adversarial training ( Goodfellow et al . ( 2015 ) ) , which is the dominant approach of adversarial attack defense . The important difference here is that Editable Training aims to learn models , whose behavior on some samples can be efficiently corrected . Meanwhile , adversarial training produces models , which are robust to certain input perturbations . However , in practice one can use Editable Training to efficiently cover model vulnerabilities against both synthetic ( Szegedy et al . ( 2013 ) ; Yuan et al . ( 2017 ) ; Ebrahimi et al . ( 2017 ) ; Wallace et al . ( 2019 ) ) and natural ( Hendrycks et al . ( 2019 ) ) adversarial examples . 1The source code is available online at https : //github.com/xtinkt/editable 3 EDITING NEURAL NETWORKS . In order to measure and optimize the model ’ s ability for editing , we first formally define the operation of editing a neural network . Let f ( x , θ ) be a neural network , with x denoting its input and θ being a set of network parameters . The parameters θ are learned by minimizing a task-specific objective function Lbase ( θ ) , e.g . cross-entropy for multi-class classification problems . Then , if we discover mistakes in the model ’ s behavior , we can patch the model by changing its parameters θ . Here we aim to change model ’ s predictions on a subset of inputs , corresponding to misclassified objects , without affecting other inputs . We formalize this goal using the editor function : θ̂=Edit ( θ , le ) . Informally , this is a function that adjusts θ to satisfy a given constraint le ( θ̂ ) ≤ 0 , whose role is to enforce desired changes in the model ’ s behavior . For instance , in the case of multi-class classification , le can guarantee that the model assigns input x to the desired label yref : le ( θ̂ ) = maxyi log p ( yi|x , θ̂ ) − log p ( yref |x , θ̂ ) . Under such definition of le , the constraint le ( θ̂ ) ≤ 0 is satisfied iff argmaxyi log p ( yi|x , θ̂ ) = yref . To be practically feasible , the editor function must meet three natural requirements : • Reliability : the editor must guarantee le ( θ̂ ) ≤ 0 for the chosen family of le ( · ) ; • Locality : the editor should minimize influence on f ( · , θ̂ ) outside of satisfying le ( θ̂ ) ≤ 0 ; • Efficiency : the editor should be efficient in terms of runtime and memory ; Intuitively , the editor locality aims to minimize changes in model ’ s predictions for inputs unrelated to le . For classification problem , this requirement can be formalized as minimizing the difference between model ’ s predictions over the ” control ” set Xc : E x∈Xc # [ f ( x , θ̂ ) 6= f ( x , θ ) ] → min . 3.1 GRADIENT DESCENT EDITOR . A natural way to implement Edit ( θ , le ) for deep neural networks is using gradient descent . Parameters θ are shifted against the gradient direction−α∇θle ( θ ) for several iterations until the constraint le ( θ ) ≤ 0 is satisfied . We formulate the SGD editor with up to k steps and learning rate α as : Editkα ( θ , le , k ) = { θ , if le ( θ ) ≤ 0 or k = 0 Editk−1α ( θ − α · ∇θle ( θ ) , le ) , otherwise ( 1 ) The standard gradient descent editor can be further augmented with momentum , adaptive learning rates ( Duchi et al . ( 2010 ) ; Zeiler ( 2012 ) ) and other popular deep learning tricks ( Kingma & Ba ( 2014 ) ; Smith & Topin ( 2017 ) ) . One technique that we found practically useful is Resilient Backpropagation : RProp , SignSGD by Bernstein et al . ( 2018 ) or RMSProp by Tieleman & Hinton ( 2012 ) . We observed that these methods produce more robust weight updates that improve locality . 3.2 EDITABLE TRAINING . The core idea behind Editable Training is to enforce the model parameters θ to be ” prepared ” for the editor function . More formally , we want to learn such parameters θ , that the editor Edit ( θ , le ) is reliable , local and efficient , as defined in above . Our training procedure employs the fact that Gradient Descent Editor ( 1 ) is differentiable w.r.t . θ . This well-known observation ( Finn et al . ( 2017 ) ) allows us to optimize through the editor function directly via backpropagation ( see Figure 1 ) . Editable Training is performed on minibatches of constraints le ∼ p ( le ) ( e.g . images and target labels ) . First , we compute the edited parameters θ̂ = Edit ( θ , le ) by applying up to k steps of gradient descent ( 1 ) . Second , we compute the objective that measures locality and efficiency of the editor function : Obj ( θ , le ) = Lbase ( θ ) + cedit · Ledit ( θ ) + cloc · Lloc ( θ ) ( 2 ) Ledit ( θ ) = max ( 0 , le ( Editkα ( θ , le ) ) ( 3 ) Lloc ( θ ) = E x∼p ( x ) DKL ( p ( y|x , θ ) ||p ( y|x , Editkα ( θ , le ) ) ) ( 4 ) Intuitively , Ledit ( θ ) encourages reliability and efficiency of the editing procedure by making sure the constraint is satisfied in under k gradient steps . The final term Lloc ( θ ) is responsible for locality by minimizing the KL divergence between the predictions of original and edited models . We use hyperparameters cedit , cloc to balance between the original task-specific objective , editor efficiency and locality . Setting both of them to large positive values would cause the model to sacrifice some of its performance for a better edit . On the other hand , sufficiently small cedit , cloc will not cause any deterioration of the main training objective while still improving the editor function in all our experiments ( see Section 4 ) . We attribute this to the fact that neural networks are typically overparameterized . Most neural networks can accommodate the edit-related properties and still have enough capacity to optimize Obj ( θ , le ) . The learning step α and other optimizer parameters ( e.g . β for RMSProp ) are trainable parameters of Editable Training and we optimize them explicitly via gradient descent .

Summary: This paper makes a convincing case for improving the usefulness of production level, large scale models by making them quickly editable without extensive retraining. A standard meta-learning method called MAML is used to augment the initial training phase of such models, or to "patch" them later on. The paper demonstrates effectiveness for both image classification and machine translation tasks, covering a wide range of relevant scenarios.