Controlling Neural Networks with Rule Representations

1 Introduction . Deep neural networks ( DNNs ) excel at numerous tasks such as image classification [ 28 , 29 ] , machine translation [ 22 , 30 ] , time series forecasting [ 11 , 21 ] , and tabular learning [ 2 , 25 ] . DNNs get more accurate as the size and coverage of training data increase [ 17 ] . While investing in high-quality and large-scale labeled data is one path , another is utilizing prior knowledge – concisely referred to as ‘ rules ’ : reasoning heuristics , equations , associative logic , constraints or blacklists . In most scenarios , labeled datasets are not sufficient to teach all rules present about a task [ 4 , 12 , 23 , 24 ] . Let us consider an example from Physics : the task of predicting the next state in a double pendulum system , visualized in Fig . 1 . Although a ‘ data-driven ’ black-box model , fitted with conventional supervised learning , can fit a relatively accurate mapping from the current state to next , it can easily fail to capture the canonical rule of ‘ energy conservation ’ . In this work , we focus on how to teach ‘ rules ’ in effective ways so that DNNs absorb the knowledge from them in addition to learning from the data for the downstream task . The benefits of learning from rules are multifaceted . First , rules can provide extra information for cases with minimal data supervision , improving the test accuracy . Second , the rules can improve trust and reliability of DNNs . One major bottleneck for widespread use of DNNs is them being ‘ black-box ’ . The lack of understanding of the rationale behind their reasoning and inconsistencies of their outputs with human judgement often reduce the trust of the users [ 3 , 26 ] . By incorporating rules , such inconsistencies can be minimized and the users ’ trust can be improved . For example , if a DNN for loan delinquency prediction can absorb all the decision heuristics used at a bank , the loan officers of the bank can rely on the predictions more comfortably . Third , DNNs are sensitive to slight changes 35th Conference on Neural Information Processing Systems ( NeurIPS 2021 ) . to the inputs that are human-imperceptible [ 15 , 20 , 31 ] . With rules , the impact of these changes can be minimized as the model search space is further constrained to reduce underspecification [ 7 , 10 ] . When ‘ data-driven ’ and ‘ rule-driven ’ learning are considered jointly , a fundamental question is how to balance the contribution from each . Even when a rule is known to hold 100 % of the time ( such as the principles in natural sciences ) , the contribution of rule-driven learning should not be increased arbitrarily . There is an optimal trade-off that depends not only on the dataset , but also on each sample . If there are training samples that are very similar to a particular test sample , a weaker rule-driven contribution would be desirable at inference . On the other hand , if the rule is known to hold for only a subset of samples ( e.g . in Retail , the varying impact of a price change on different products [ 6 ] ) , the strength of the rule-driven learning contribution should reflect that . Thus , a framework where the contributions of data- and rule-driven learning can be controlled would be valuable . Ideally , such control should be enabled at inference without the need for retraining in order to minimize the computational cost , shorten the deployment time , and to adjust to different samples or changing distributions flexibly . In this paper , we propose DEEPCTRL that enables joint learning from labeled data and rules . DEEPCTRL employs separate encoders for data and rules with the outputs combined stochastically to cover intermediate representations coupling with corresponding objectives . This representation learning is the key to controllability , as it allows increasing/decreasing the rule strength gradually at inference without retraining . To convert any non-differentiable rules into differentiable objectives , we propose a novel perturbation-based method . DEEPCTRL is agnostic to the data type or the model architecture , and DEEPCTRL can be flexibly used in different tasks and with different rules . We demonstrate DEEPCTRL on important use cases from Physics , Retail , and Healthcare , and show that it : ( i ) improves the rule verification ratio significantly while yielding better accuracy by merely changing the rule strength at inference ; ( ii ) enables hypotheses to be examined for each sample based on the optimal ratio of rule strength without retraining ( for the first time in literature , to the best of our knowledge ) ; and ( iii ) improves target task performance by changing the rule strength , a desired capability when different subsets of the data are known to satisfy rules with different strengths . Related Work : Various methods have been studied to incorporate ‘ rules ’ into deep learning , considering prior knowledge in wide range of applications . Posterior regularization [ 13 ] is one approach to inject rules into predictions . In [ 18 ] , a teacher-student framework is used , where the teacher network is obtained by projecting the student network to a ( logic ) rule-regularized subspace and the student network is updated to balance between emulating the teacher ’ s output and predicting the labels . Adversarial learning is utilized in [ 32 ] , specifically for bias rules , to penalize unwanted biases . In [ 12 ] a framework is proposed that exploits Lagrangian duality to train with rules . In [ 24 ] learning with constraints is studied , via formulation over the space of confusion matrices and optimization solvers that operate through a sequence of linear minimization steps . In [ 27 ] constraints are injected via KL divergence for variational autoencoders , for controlling output diversity or disentangled latent factor representations . DEEPCTRL differentiate from the all aforementioned in how it injects the rules , with the aspect that it allows controllability of the rule strength at the inference without retraining , enabled by accurate learning of the rule representations in the data manifold . This unlocks new capabilities , beyond simply improving rule verification for a target accuracy . 2 Learning Jointly from Rules and Task . Let us consider the conventional approach [ 9 , 12 , 14 ] for incorporating rules via combining the training objectives for the supervised task and a term that denotes the violation of rule : L = Ltask + λLrule , ( 1 ) where λ is the coefficient for the rule-based objective . There are three limitations of this approach that we aim to address : ( i ) λ needs to be defined before learning ( e.g . can be a hyperparameter guided with validation score ) , ( ii ) λ is not adaptable to target data at inference if there is any mismatch with the training setup , and ( iii ) Lrule needs to be differentiable with respect to learnable parameters . DEEPCTRL modifies canonical training by creating rule representations , coupled with data representations , which is the key to enable the rule strength to be controlled at inference time . Fig . 2 overviews DEEPCTRL and Algorithm 1 describes its corresponding training process . We propose to modify the canonical training approach by introducing two passages for the input-output relationship of the task , via data encoder φd and rule encoder φr . In this way , our goal is to make each encoder individually learn the latent representations ( zd and zr ) , corresponding to extracted information from the labeled data and the rule . Then , the two representations are stochastically concatenated ( with the operation denoted as ⊕ ) to obtain a single representation z . To adjust the relative contributions of data vs. rule encoding , we use a random variable α ∈ [ 0 , 1 ] , which also couples ( zd , zr ) with the corresponding objectives ( Ltask , Lrule ) ( Lines 4 & 5 in Algorithm 1 ) . α is sampled from the distribution P ( α ) . The motivation to use a random α is to encourage learning the mapping with a range of values , so that at inference , the model can yield high performance with any particular chosen value . The output of the decision block ( ŷ ) is used in the entire objective . By modifying the control parameter α at inference , users can control the behavior of the model to adapt it to unseen data . The strength of the rule on the output decision can be enhanced by increasing the value of α . Setting α = 0 would minimize the contribution of the rule at inference , but as shown in the experiments , the result can still be better than in conventional training since during the training process a wide range of α are considered . Typically , an intermediate α value yields the optimal solution given specific performance , transparency and reliability goals . To ensure that a model shows distinct and robust behavior when α→ 0 or α→ 1 and thus interpolates accurately later , we propose to sample α more heavily at the two extremes rather than uniformly from [ 0 , 1 ] . To this end , we choose to sample from a Beta distribution ( Beta ( β , β ) ) . We observe strong results with β = 0.1 in Algorithm 1 Training process for DEEPCTRL . Input : Training data D = { ( xi , yi ) : i = 1 , · · · , N } . Output : Optimized parameters Require : Rule encoder φr , data encoder φd , decision block φ , and distribution P ( α ) . 1 : Initialize φr , φd , and φ 2 : while not converged do 3 : Get mini-batch Db from D and αb ∈ R from P ( α ) 4 : Get z = αbzr ⊕ ( 1− αbzd ) where zr = φr ( Db ) and zd = φd ( Db ) . 5 : Get ŷ = φ ( z ) and compute L = Eα∼P ( α ) [ αLrule + ρ ( 1 − α ) Ltask ] where ρ = Lrule,0/Ltask,0 6 : Update φr , φd , and φ from gradients∇φrL , ∇φdL , and ∇φL 7 : end while most cases and in Section 5 , we further study the impact of the selection of the prior for α . Since a Beta distribution is highly polarized , each encoder is encouraged to learn distinct representations associated with the corresponding encoder rather than mixed representations . Similar sampling ideas were also considered in [ 1 , 33 ] to effectively sample the mixing weights for representation learning . One concern in the superposition of Ltask and Lrule is their scale differences that may cause all learnable parameters to be dominated by one particular objective regardless of α , and hence become unbalanced . This is not a desired behavior as it significantly limits the expressiveness of DEEPCTRL and may cause convergence into a single mode . E.g. , if Lrule is much larger than Ltask , then DEEPCTRL will become a rule-based model even when α is close to 0 . To minimize such imbalanced behavior , we propose to adjust the scaling automatically . Before starting a learning process , we compute the initial loss values Lrule,0 and Ltask,0 on a training set and introduce a scale parameter ρ = Lrule,0/Ltask,0 . Overall , the DEEPCTRL objective function becomes : L = Eα∼P ( α ) [ αLrule + ρ ( 1− α ) Ltask ] . ( 2 ) DEEPCTRL is model-type agnostic – we can choose and appropriate inductive bias for encoders and the decision block based on the type and task . E.g . if the input data is an image and the task is classification , the encoders can be convolutional layers to extract hidden representations associated with local spatial coherence , and the decision block can be an MLP followed by a softmax layer .

Summary: This paper proposes to integrate a combination of rule learning and data learning in the deep neural networks. The core motivation is to introduce prior knowledge and/or other learning methods and learning how to "balance" the pure data-driven part of the neural network with its rule learning component. The final neural network has two components: the rule-based encoder and the data-driven encoder that are combined by a parametrized convex combination. The loss function has also a counterpart that captures the traditional loss function with penalizations on the rule violations. The second part is similar to the Lagrangian approach to training neural networks subject to constraints that has been used successfully in prior (mostly cited) work. The novelty is the introduction of the rule encoder inside the neural network, as examplified by the third application. The paper also proposes an interesting perturbation approach to capture some of the rule behavior.