Harnessing Deep Neural Networks with Logic Rules

Zhiting Hu, Xuezhe Ma, Zhengzhong Liu, Eduard Hovy, Eric Xing

Introduction

Deep neural networks provide a powerful mechanism for learning patterns from massive data, achieving new levels of performance on image classification (Krizhevsky et al.,, 2012), speech recognition (Hinton et al.,, 2012), machine translation (Bahdanau et al.,, 2014), playing strategic board games (Silver et al.,, 2016), and so forth.

Despite the impressive advances, the widely-used DNN methods still have limitations. The high predictive accuracy has heavily relied on large amounts of labeled data; and the purely data-driven learning can lead to uninterpretable and sometimes counter-intuitive results (Szegedy et al.,, 2014; Nguyen et al.,, 2015). It is also difficult to encode human intention to guide the models to capture desired patterns, without expensive direct supervision or ad-hoc initialization.

On the other hand, the cognitive process of human beings have indicated that people learn not only from concrete examples (as DNNs do) but also from different forms of general knowledge and rich experiences (Minksy,, 1980; Lake et al.,, 2015). Logic rules provide a flexible declarative language for communicating high-level cognition and expressing structured knowledge. It is therefore desirable to integrate logic rules into DNNs, to transfer human intention and domain knowledge to neural models, and regulate the learning process.

In this paper, we present a framework capable of enhancing general types of neural networks, such as convolutional networks (CNNs) and recurrent networks (RNNs), on various tasks, with logic rule knowledge. Combining symbolic representations with neural methods have been considered in different contexts. Neural-symbolic systems (Garcez et al.,, 2012) construct a network from a given rule set to execute reasoning. To exploit a priori knowledge in general neural architectures, recent work augments each raw data instance with useful features (Collobert et al.,, 2011), while network training, however, is still limited to instance-label supervision and suffers from the same issues mentioned above. Besides, a large variety of structural knowledge cannot be naturally encoded in the feature-label form.

Our framework enables a neural network to learn simultaneously from labeled instances as well as logic rules, through an iterative rule knowledge distillation procedure that transfers the structured information encoded in the logic rules into the network parameters. Since the general logic rules are complementary to the specific data labels, a natural “side-product” of the integration is the support for semi-supervised learning where unlabeled data is used to better absorb the logical knowledge. Methodologically, our approach can be seen as a combination of the knowledge distillation (Hinton et al.,, 2015; Buciluǎ et al.,, 2006) and the posterior regularization (PR) method (Ganchev et al.,, 2010). In particular, at each iteration we adapt the posterior constraint principle from PR to construct a rule-regularized teacher, and train the student network of interest to imitate the predictions of the teacher network. We leverage soft logic to support flexible rule encoding.

We apply the proposed framework on both CNN and RNN, and deploy on the task of sentiment analysis (SA) and named entity recognition (NER), respectively. With only a few (one or two) very intuitive rules, both the distilled networks and the joint teacher networks strongly improve over their basic forms (without rules), and achieve better or comparable performance to state-of-the-art models which typically have more parameters and complicated architectures.

To the best of our knowledge, this is the first work to integrate logic rules with general workhorse types of deep neural networks in a principled framework. The encouraging results indicate our method can be potentially useful for incorporating richer types of human knowledge, and improving other application domains.

Related Work

Combination of logic rules and neural networks has been considered in different contexts. Neural-symbolic systems (Garcez et al.,, 2012), such as KBANN (Towell et al.,, 1990) and CILP++ (França et al.,, 2014), construct network architectures from given rules to perform reasoning and knowledge acquisition. A related line of research, such as Markov logic networks (Richardson and Domingos,, 2006), derives probabilistic graphical models (rather than neural networks) from the rule set.

With the recent success of deep neural networks in a vast variety of application domains, it is increasingly desirable to incorporate structured logic knowledge into general types of networks to harness flexibility and reduce uninterpretability. Recent work that trains on extra features from domain knowledge (Collobert et al.,, 2011), while producing improved results, does not go beyond the data-label paradigm. Kulkarni et al., (2015) uses a specialized training procedure with careful ordering of training instances to obtain an interpretable neural layer of an image network. Karaletsos et al., (2016) develops a generative model jointly over data-labels and similarity knowledge expressed in triplet format to learn improved disentangled representations.

Though there do exist general frameworks that allow encoding various structured constraints on latent variable models (Ganchev et al.,, 2010; Zhu et al.,, 2014; Liang et al.,, 2009), they either are not directly applicable to the NN case, or could yield inferior performance as in our empirical study. Liang et al., (2008) transfers predictive power of pre-trained structured models to unstructured ones in a pipelined fashion.

Our proposed approach is distinct in that we use an iterative rule distillation process to effectively transfer rich structured knowledge, expressed in the declarative first-order logic language, into parameters of general neural networks. We show that the proposed approach strongly outperforms an extensive array of other either ad-hoc or general integration methods.

Method

In this section we present our framework which encapsulates the logical structured knowledge into a neural network. This is achieved by forcing the network to emulate the predictions of a rule-regularized teacher, and evolving both models iteratively throughout training (section 3.2). The process is agnostic to the network architecture, and thus applicable to general types of neural models including CNNs and RNNs. We construct the teacher network in each iteration by adapting the posterior regularization principle in our logical constraint setting (section 3.3), where our formulation provides a closed-form solution. Figure 1 shows an overview of the proposed framework.

Our approach allows neural networks to learn from both specific examples and general rules. Here we give the settings of these “learning resources”.

Assume we have input variable x∈X{\bm{\mathbf{x}}}\in\mathcal{X} and target variable y∈Y{\bm{\mathbf{y}}}\in\mathcal{Y}. For clarity, we focus on KK-way classification, where Y=ΔK\mathcal{Y}=\Delta^{K} is the KK-dimensional probability simplex and y∈{0,1}K⊂Y{\bm{\mathbf{y}}}\in\{0,1\}^{K}\subset\mathcal{Y} is a one-hot encoding of the class label. However, our method specification can straightforwardly be applied to other contexts such as regression and sequence learning (e.g., NER tagging, which is a sequence of classification decisions). The training data D={(xn,yn)}n=1N\mathcal{D}=\{({\bm{\mathbf{x}}}_{n},{\bm{\mathbf{y}}}_{n})\}_{n=1}^{N} is a set of instantiations of (x,y)({\bm{\mathbf{x}}},{\bm{\mathbf{y}}}).

Further consider a set of first-order logic (FOL) rules with confidences, denoted as R={(Rl,λl)}l=1L\mathcal{R}=\{(R_{l},\lambda_{l})\}_{l=1}^{L}, where RlR_{l} is the llth rule over the input-target space (X,Y)(\mathcal{X},\mathcal{Y}), and λl∈[0,∞]\lambda_{l}\in[0,\infty] is the confidence level with λl=∞\lambda_{l}=\infty indicating a hard rule, i.e., all groundings are required to be true (=1). Here a grounding is the logic expression with all variables being instantiated. Given a set of examples (X,Y)⊂(X,Y)({\bm{\mathbf{X}}},{\bm{\mathbf{Y}}})\subset(\mathcal{X},\mathcal{Y}) (e.g., a minibatch from D\mathcal{D}), the set of groundings of RlR_{l} are denoted as {rlg(X,Y)}g=1Gl\{r_{lg}({\bm{\mathbf{X}}},{\bm{\mathbf{Y}}})\}_{g=1}^{G_{l}}. In practice a rule grounding is typically relevant to only a single or subset of examples, though here we give the most general form on the entire set.

We encode the FOL rules using soft logic (Bach et al.,, 2015) for flexible encoding and stable optimization. Specifically, soft logic allows continuous truth values from the interval $insteadofinstead of\{0,1\}$, and the Boolean logic operators are reformulated as:

Here &\& and ∧\wedge are two different approximations to logical conjunction (Foulds et al.,, 2015): &\& is useful as a selection operator (e.g., A&B=BA\&B=B when A=1A=1, and A&B=0A\&B=0 when A=0A=0), while ∧\wedge is an averaging operator.

2 Rule Knowledge Distillation

A neural network defines a conditional probability pθ(y∣x)p_{\theta}({\bm{\mathbf{y}}}|{\bm{\mathbf{x}}}) by using a softmax output layer that produces a KK-dimensional soft prediction vector denoted as σθ(x){\bm{\mathbf{\sigma}}}_{\theta}({\bm{\mathbf{x}}}). The network is parameterized by weights θ{\bm{\mathbf{\theta}}}. Standard neural network training has been to iteratively update θ{\bm{\mathbf{\theta}}} to produce the correct labels of training instances. To integrate the information encoded in the rules, we propose to train the network to also imitate the outputs of a rule-regularized projection of pθ(y∣x)p_{\theta}({\bm{\mathbf{y}}}|{\bm{\mathbf{x}}}), denoted as q(y∣x)q({\bm{\mathbf{y}}}|{\bm{\mathbf{x}}}), which explicitly includes rule constraints as regularization terms. In each iteration qq is constructed by projecting pθp_{\theta} into a subspace constrained by the rules, and thus has desirable properties. We present the construction in the next section. The prediction behavior of qq reveals the information of the regularized subspace and structured rules. Emulating the qq outputs serves to transfer this knowledge into pθp_{\theta}. The new objective is then formulated as a balancing between imitating the soft predictions of qq and predicting the true hard labels:

A similar imitation procedure has been used in other settings such as model compression (Buciluǎ et al.,, 2006; Hinton et al.,, 2015) where the process is termed distillation. Following them we call pθ(y∣x)p_{\theta}({\bm{\mathbf{y}}}|{\bm{\mathbf{x}}}) the “student” and q(y∣x)q({{\bm{\mathbf{y}}}|{\bm{\mathbf{x}}}}) the “teacher”, which can be intuitively explained in analogous to human education where a teacher is aware of systematic general rules and she instructs students by providing her solutions to particular questions (i.e., the soft predictions). An important difference from previous distillation work, where the teacher is obtained beforehand and the student is trained thereafter, is that our teacher and student are learned simultaneously during training.

Though it is possible to combine a neural network with rule constraints by projecting the network to the rule-regularized subspace after it is fully trained as before with only data-label instances, or by optimizing projected network directly, we found our iterative teacher-student distillation approach provides a much superior performance, as shown in the experiments. Moreover, since pθp_{\theta} distills the rule information into the weights θ{\bm{\mathbf{\theta}}} instead of relying on explicit rule representations, we can use pθp_{\theta} for predicting new examples at test time when the rule assessment is expensive or even unavailable (i.e., the privileged information setting (Lopez-Paz et al.,, 2016)) while still enjoying the benefit of integration. Besides, the second loss term in Eq.(2) can be augmented with rich unlabeled data in addition to the labeled examples, which enables semi-supervised learning for better absorbing the rule knowledge.

3 Teacher Network Construction

We now proceed to construct the teacher network q(y∣x)q({\bm{\mathbf{y}}}|{\bm{\mathbf{x}}}) at each iteration from pθ(y∣x)p_{\theta}({\bm{\mathbf{y}}}|{\bm{\mathbf{x}}}). The iteration index tt is omitted for clarity. We adapt the posterior regularization principle in our logic constraint setting. Our formulation ensures a closed-form solution for qq and thus avoids any significant increases in computational overhead.

where ξl,gl≥0\xi_{l,g_{l}}\geq 0 is the slack variable for respective logic constraint; and CC is the regularization parameter. The problem can be seen as projecting pθp_{\theta} into the constrained subspace. The problem is convex and can be efficiently solved in its dual form with closed-form solutions. We provide the detailed derivation in the supplementary materials and directly give the solution here:

Intuitively, a strong rule with large λl\lambda_{l} will lead to low probabilities of predictions that fail to meet the constraints. We discuss the computation of the normalization factor in section 3.4.

Our framework is related to the posterior regularization (PR) method (Ganchev et al.,, 2010) which places constraints over model posterior in unsupervised setting. In classification, our optimization procedure is analogous to the modified EM algorithm for PR, by using cross-entropy loss in Eq.(2) and evaluating the second loss term on unlabeled data differing from D\mathcal{D}, so that Eq.(4) corresponds to the E-step and Eq.(2) is analogous to the M-step. This sheds light from another perspective on why our framework would work. However, we found in our experiments (section 5) that to produce strong performance it is crucial to use the same labeled data xn{\bm{\mathbf{x}}}_{n} in the two losses of Eq.(2) so as to form a direct trade-off between imitating soft predictions and predicting correct hard labels.

4 Implementations

The procedure of iterative distilling optimization of our framework is summarized in Algorithm 1.

During training we need to compute the soft predictions of qq at each iteration, which is straightforward through direct enumeration if the rule constraints in Eq.(4) are factored in the same way as the base neural model pθp_{\theta} (e.g., the “but”-rule of sentiment classification in section 4.1). If the constraints introduce additional dependencies, e.g., bi-gram dependency as the transition rule in the NER task (section 4.2), we can use dynamic programming for efficient computation. For higher-order constraints (e.g., the listing rule in NER), we approximate through Gibbs sampling that iteratively samples from q(yi∣y−i,x)q({\bm{\mathbf{y}}}_{i}|{\bm{\mathbf{y}}}_{-i},{\bm{\mathbf{x}}}) for each position ii. If the constraints span multiple instances, we group the relevant instances in minibatches for joint inference (and randomly break some dependencies when a group is too large). Note that calculating the soft predictions is efficient since only one NN forward pass is required to compute the base distribution pθ(y∣x)p_{\theta}({\bm{\mathbf{y}}}|{\bm{\mathbf{x}}}) (and few more, if needed, for calculating the truth values of relevant rules).

At test time we can use either the distilled student network pp, or the teacher network qq after a final projection. Our empirical results show that both models substantially improve over the base network that is trained with only data-label instances. In general qq performs better than pp. Particularly, qq is more suitable when the logic rules introduce additional dependencies (e.g., spanning over multiple examples), requiring joint inference. In contrast, as mentioned above, pp is more lightweight and efficient, and useful when rule evaluation is expensive or impossible at prediction time. Our experiments compare the performance of pp and qq extensively.

The imitation parameter π\pi in Eq.(2) balances between emulating the teacher soft predictions and predicting the true hard labels. Since the teacher network is constructed from pθp_{\theta}, which, at the beginning of training, would produce low-quality predictions, we thus favor predicting the true labels more at initial stage. As training goes on, we gradually bias towards emulating the teacher predictions to effectively distill the structured knowledge. Specifically, we define π(t)=min⁡{π0,1−αt}\pi^{(t)}=\min\{\pi_{0},1-\alpha^{t}\} at iteration t≥0t\geq 0, where α≤1\alpha\leq 1 specifies the speed of decay and π0<1\pi_{0}<1 is a lower bound.

Applications

We have presented our framework that is general enough to improve various types of neural networks with rules, and easy to use in that users are allowed to impose their knowledge and intentions through the declarative first-order logic. In this section we illustrate the versatility of our approach by applying it on two workhorse network architectures, i.e., convolutional network and recurrent network, on two representative applications, i.e., sentence-level sentiment analysis which is a classification problem, and named entity recognition which is a sequence learning problem.

For each task, we first briefly describe the base neural network. Since we are not focusing on tuning network architectures, we largely use the same or similar networks to previous successful neural models. We then design the linguistically-motivated rules to be integrated.

Sentence-level sentiment analysis is to identify the sentiment (e.g., positive or negative) underlying an individual sentence. The task is crucial for many opinion mining applications. One challenging point of the task is to capture the contrastive sense (e.g., by conjunction “but”) within a sentence.

We use the single-channel convolutional network proposed in (Kim,, 2014). The simple model has achieved compelling performance on various sentiment classification benchmarks. The network contains a convolutional layer on top of word vectors of a given sentence, followed by a max-over-time pooling layer and then a fully-connected layer with softmax output activation. A convolution operation is to apply a filter to word windows. Multiple filters with varying window sizes are used to obtain multiple features. Figure 2, left panel, shows the network architecture.

One difficulty for the plain neural network is to identify contrastive sense in order to capture the dominant sentiment precisely. The conjunction word “but” is one of the strong indicators for such sentiment changes in a sentence, where the sentiment of clauses following “but” generally dominates. We thus consider sentences SS with an “A-but-B” structure, and expect the sentiment of the whole sentence to be consistent with the sentiment of clause BB. The logic rule is written as:

where 1(⋅){\bm{\mathbf{1}}}(\cdot) is an indicator function that takes 1 when its argument is true, and 0 otherwise; class ‘+’ represents ‘positive’; and σθ(B)+{\bm{\mathbf{\sigma}}}_{\theta}(B)_{+} is the element of σθ(B){\bm{\mathbf{\sigma}}}_{\theta}(B) for class ’+’. By Eq.(1), when SS has the ‘A-but-B’ structure, the truth value of the above logic rule equals to (1+σθ(B)+)/2(1+{\bm{\mathbf{\sigma}}}_{\theta}(B)_{+})/2 when y=+y=+, and (2−σθ(B)+)/2(2-{\bm{\mathbf{\sigma}}}_{\theta}(B)_{+})/2 otherwise Replacing ∧\wedge with &\& in Eq.(5) leads to a probably more intuitive rule which takes the value σθ(B)+{\bm{\mathbf{\sigma}}}_{\theta}(B)_{+} when y=+y=+, and 1−σθ(B)+1-{\bm{\mathbf{\sigma}}}_{\theta}(B)_{+} otherwise.. Note that here we assume two-way classification (i.e., positive and negative), though it is straightforward to design rules for finer grained sentiment classification.

2 Named Entity Recognition

NER is to locate and classify elements in text into entity categories such as “persons” and “organizations”. It is an essential first step for downstream language understanding applications. The task assigns to each word a named entity tag in an “X-Y” format where X is one of BIEOS (Beginning, Inside, End, Outside, and Singleton) and Y is the entity category. A valid tag sequence has to follow certain constraints by the definition of the tagging scheme. Besides, text with structures (e.g., lists) within or across sentences can usually expose some consistency patterns.

The base network has a similar architecture with the bi-directional LSTM recurrent network (called BLSTM-CNN) proposed in (Chiu and Nichols,, 2015) for NER which has outperformed most of previous neural models. The model uses a CNN and pre-trained word vectors to capture character- and word-level information, respectively. These features are then fed into a bi-directional RNN with LSTM units for sequence tagging. Compared to (Chiu and Nichols,, 2015) we omit the character type and capitalization features, as well as the additive transition matrix in the output layer. Figure 2, right panel, shows the network architecture.

The base network largely makes independent tagging decisions at each position, ignoring the constraints on successive labels for a valid tag sequence (e.g., I-ORG cannot follow B-PER). In contrast to recent work (Lample et al.,, 2016) which adds a conditional random field (CRF) to capture bi-gram dependencies between outputs, we instead apply logic rules which does not introduce extra parameters to learn. An example rule is:

The confidence levels are set to ∞\infty to prevent any violation.

We further leverage the list structures within and across sentences of the same documents. Specifically, named entities at corresponding positions in a list are likely to be in the same categories. For instance, in “1. Juventus, 2. Barcelona, 3. …” we know “Barcelona” must be an organization rather than a location, since its counterpart entity “Juventus” is an organization. We describe our simple procedure for identifying lists and counterparts in the supplementary materials. The logic rule is encoded as:

Experiments

We validate our framework by evaluating its applications of sentiment classification and named entity recognition on a variety of public benchmarks. By integrating the simple yet effective rules with the base networks, we obtain substantial improvements on both tasks and achieve state-of-the-art or comparable results to previous best-performing systems. Comparison with a diverse set of other rule integration methods demonstrates the unique effectiveness of our framework. Our approach also shows promising potentials in the semi-supervised learning and sparse data context.

Throughout the experiments we set the regularization parameter to C=6C=6. In sentiment classification we set the imitation parameter to π(t)=1−0.95t\pi^{(t)}=1-0.95^{t}, while in NER π(t)=min⁡{0.9,1−0.9t}\pi^{(t)}=\min\{0.9,1-0.9^{t}\} to downplay the noisy listing rule. The confidence levels of rules are set to λl=1\lambda_{l}=1, except for hard constraints whose confidence is ∞\infty. For neural network configuration, we largely followed the reference work, as specified in the following respective sections. All experiments were performed on a Linux machine with eight 4.0GHz CPU cores, one Tesla K40c GPU, and 32GB RAM. We implemented neural networks using Theano http://deeplearning.net/software/theano, a popular deep learning platform.

We test our method on a number of commonly used benchmarks, including 1) SST2, Stanford Sentiment Treebank (Socher et al.,, 2013) which contains 2 classes (negative and positive), and 6920/872/1821 sentences in the train/dev/test sets respectively. Following (Kim,, 2014) we train models on both sentences and phrases since all labels are provided. 2) MR (Pang and Lee,, 2005), a set of 10,662 one-sentence movie reviews with negative or positive sentiment. 3) CR (Hu and Liu,, 2004), customer reviews of various products, containing 2 classes and 3,775 instances. For MR and CR, we use 10-fold cross validation as in previous work. In each of the three datasets, around 15% sentences contains the word “but”.

For the base neural network we use the “non-static” version in (Kim,, 2014) with the exact same configurations. Specifically, word vectors are initialized using word2vec (Mikolov et al.,, 2013) and fine-tuned throughout training, and the neural parameters are trained using SGD with the Adadelta update rule (Zeiler,, 2012).

1.2 Results

Table 1 shows the sentiment classification performance. Rows 1-3 compare the base neural model with the models enhanced by our framework with the “but”-rule (Eq.(5)). We see that our method provides a strong boost on accuracy over all three datasets. The teacher network qq further improves over the student network pp, though the student network is more widely applicable in certain contexts as discussed in sections 3.2 and 3.4. Rows 4-10 show the accuracy of recent top-performing methods. On the MR and CR datasets, our model outperforms all the baselines. On SST2, MVCNN (Yin and Schutze,, 2015) (Row 5) is the only system that shows a slightly better result than ours. Their neural network has combined diverse sets of pre-trained word embeddings (while we use only word2vec) and contained more neural layers and parameters than our model.

To further investigate the effectiveness of our framework in integrating structured rule knowledge, we compare with an extensive array of other possible integration approaches. Table 2 lists these methods and their performance on the SST2 task. We see that: 1) Although all methods lead to different degrees of improvement, our framework outperforms all other competitors with a large margin. 2) In particular, compared to the pipelined method in Row 6 which is in analogous to the structure compilation work (Liang et al.,, 2008), our iterative distillation (section 3.2) provides better performance. Another advantage of our method is that we only train one set of neural parameters, as opposed to two separate sets as in the pipelined approach. 3) The distilled student network “-Rule-pp” achieves much superior accuracy compared to the base CNN, as well as “-project” and “-opt-project” which explicitly project CNN to the rule-constrained subspace. This validates that our distillation procedure transfers the structured knowledge into the neural parameters effectively. The inferior accuracy of “-opt-project” can be partially attributed to the poor performance of its neural network part which achieves only 85.1% accuracy and leads to inaccurate evaluation of the “but”-rule in Eq.(5).

We next explore the performance of our framework with varying numbers of labeled instances as well as the effect of exploiting unlabeled data. Intuitively, with less labeled examples we expect the general rules would contribute more to the performance, and unlabeled data should help better learn from the rules. This can be a useful property especially when data are sparse and labels are expensive to obtain. Table 3 shows the results. The subsampling is conducted on the sentence level. That is, for instance, in “5%” we first selected 5% training sentences uniformly at random, then trained the models on these sentences as well as their phrases. The results verify our expectations. 1) Rows 1-3 give the accuracy of using only data-label subsets for training. In every setting our methods consistently outperform the base CNN. 2) “-Rule-qq” provides higher improvement on 5% data (with margin 2.6%) than on larger data (e.g., 2.3% on 10% data, and 2.0% on 30% data), showing promising potential in the sparse data context. 3) By adding unlabeled instances for semi-supervised learning as in Rows 5-6, we get further improved accuracy. 4) Row 4, “-semi-PR” is the posterior regularization (Ganchev et al.,, 2010) which imposes the rule constraint through only unlabeled data during training. Our distillation framework consistently provides substantially better results.

2 Named Entity Recognition

We evaluate on the well-established CoNLL-2003 NER benchmark (Tjong Kim Sang and De Meulder,, 2003), which contains 14,987/3,466/3,684 sentences and 204,567/51,578/46,666 tokens in train/dev/test sets, respectively. The dataset includes 4 categories, i.e., person, location, organization, and misc. BIOES tagging scheme is used. Around 1.7% named entities occur in lists.

We use the mostly same configurations for the base BLSTM network as in (Chiu and Nichols,, 2015), except that, besides the slight architecture difference (section 4.2), we apply Adadelta for parameter updating. GloVe (Pennington et al.,, 2014) word vectors are used to initialize word features.

2.2 Results

Table 4 presents the performance on the NER task. By incorporating the bi-gram transition rules (Row 2), the joint teacher model qq achieves 1.56 improvement in F1 score that outperforms most previous neural based methods (Rows 4-7), including the BLSTM-CRF model (Lample et al.,, 2016) which applies a conditional random field (CRF) on top of a BLSTM in order to capture the transition patterns and encourage valid sequences. In contrast, our method implements the desired constraints in a more straightforward way by using the declarative logic rule language, and at the same time does not introduce extra model parameters to learn. Further integration of the list rule (Row 3) provides a second boost in performance, achieving an F1 score very close to the best-performing systems including Joint-NER-EL (Luo et al.,, 2015) (Row 8), a probabilistic graphical model optimizing NER and entity linking jointly with massive external resources, and BLSTM-CRF (Ma and Hovy,, 2016), a combination of BLSTM and CRF with more parameters than our rule-enhanced neural networks.

From the table we see that the accuracy gap between the joint teacher model qq and the distilled student pp is relatively larger than in the sentiment classification task (Table 1). This is because in the NER task we have used logic rules that introduce extra dependencies between adjacent tag positions as well as multiple instances, making the explicit joint inference of qq useful for fulfilling these structured constraints.

Discussion and Future Work

We have developed a framework which combines deep neural networks with first-order logic rules to allow integrating human knowledge and intentions into the neural models. In particular, we proposed an iterative distillation procedure that transfers the structured information of logic rules into the weights of neural networks. The transferring is done via a teacher network constructed using the posterior regularization principle. Our framework is general and applicable to various types of neural architectures. With a few intuitive rules, our framework significantly improves base networks on sentiment analysis and named entity recognition, demonstrating the practical significance of our approach.

Though we have focused on first-order logic rules, we leveraged soft logic formulation which can be easily extended to general probabilistic models for expressing structured distributions and performing inference and reasoning (Lake et al.,, 2015). We plan to explore these diverse knowledge representations to guide the DNN learning. The proposed iterative distillation procedure also reveals connections to recent neural autoencoders (Kingma and Welling,, 2014; Rezende et al.,, 2014) where generative models encode probabilistic structures and neural recognition models distill the information through iterative optimization (Rezende et al.,, 2016; Johnson et al.,, 2016; Karaletsos et al.,, 2016).

The encouraging empirical results indicate a strong potential of our approach for improving other application domains such as vision tasks, which we plan to explore in the future. Finally, we also would like to generalize our framework to automatically learn the confidence of different rules, and derive new rules from data.

Acknowledgments

We thank the anonymous reviewers for their valuable comments. This work is supported by NSF IIS1218282, NSF IIS1447676, Air Force FA8721-05-C-0003, and FA8750-12-2-0342.

References

Appendix A Appendix

We provide the detailed derivation for solving the problem in Eq.(3), Section 3.3, which we repeat here:

The following derivation is largely adapted from (Ganchev et al.,, 2010) for the logic rule constraint setting, with some reformulation that produces closed-form solution.

Let Zη=∑Yp(Y∣X)exp⁡{−∑l,glηl,glλl(1−rl,gl(X,Y))}Z_{\eta}=\sum_{{\bm{\mathbf{Y}}}}p({\bm{\mathbf{Y}}}|{\bm{\mathbf{X}}})\exp\left\{-\sum_{l,g_{l}}\eta_{l,g_{l}}\lambda_{l}(1-r_{l,g_{l}}({\bm{\mathbf{X}}},{\bm{\mathbf{Y}}}))\right\}. Plugging α\alpha into LL

Since ZηZ_{\eta} monotonically decreases as η\eta increases, and from Eq.(A.5) we have ηl,gl≤C\eta_{l,g_{l}}\leq C, therefore:

Plugging Eqs.(A.6) and (A.8) into Eq.(A.4) we obtain the solution of qq as in Eq.(4).

A.2 Identifying Lists for NER

We design a simple pattern-matching based method to identify lists and counterparts in the NER task. We ensure high precision and do not expect high recall. In particular, we only retrieve lists that with the pattern “1. … 2. … 3. …” (i.e., indexed by numbers), and “- … - … - …” (i.e., each item marked with “-”). We require at least 3 items to form a list.

We further require the text of each item follows certain patterns to ensure the text is highly likely to be named entities, and rule out those lists whose item text is largely free text. Specifically, we require 1) all words of the item text all start with capital letters; 2) referring the text between punctuations as “block”, each block includes no more than 3 words.

We detect both intra-sentence lists and inter-sentence lists in documents. We found the above patterns are effective to identify true lists. A better list detection method is expected to further improve our NER results.