Learning Distributed Representations of Symbolic Structure Using Binding and Unbinding Operations
Abstract
Widely used recurrent units, including Long-short Term Memory (LSTM) and
Gated Recurrent Unit (GRU), perform well on natural language tasks, but their ability to learn structured representations is still questionable.
Exploiting Tensor
Product Representations (TPRs) — distributed representations of symbolic structure in which vector-embedded symbols are bound to vector-embedded structural positions — we propose the TPRU, a recurrent unit that, at each time step, explicitly executes structural-role binding and unbinding operations to incorporate structural information into learning.
Experiments are conducted on both the Logical Entailment task and the Multi-genre Natural Language Inference (MNLI) task, and
our
TPR-derived recurrent unit provides strong performance with signiﬁcantly fewer parameters than LSTM and GRU baselines.
Furthermore, our learnt TPRU trained on MNLI demonstrates solid generalisation ability on downstream tasks.
Introduction
Recent advances in deep learning beneﬁt largely from neural networks’ ability to learn distributed representations of inputs from various domains [8]; even samples from different modalities can be easily compared in a common representation space [16, 42].
In contrast to localist (1-hot) representations that are not able to directly represent the possible componential structure within data [20], distributed representations are potentially capable of inducing implicit structure in the data, or explicit structure that is not presented along with the data.
When it comes to statistical inference, distributed representations show considerable power, attesting to strong ability to encode world knowledge and to efﬁciently use representation space.
However, the interpretability of learnt distributed representations is limited; it is typically quite unclear what speciﬁcally has been encoded in the representations.
Symbolic computing can take advantage of the presented structure of data and denote each substructure as a symbol; throughout computation, the representations derived by symbolic computing maintain the structure of data explicitly, and each substructure can be retrieved by simple straightforward computation [9].
In terms of inducing implicit structure from data, symbolic computing aims to decompose each sample to an ensemble of unique symbols that carry potential substructure of the data.
With enough symbols, the underlying structure of data can be encoded thoroughly.
The explicit usage of symbols in symbolic computing systems improves the capability of induced representations, but also, it brings in issues including inefﬁcient memory usage and computational expense.
Tensor product representation (TPR) [38] is an instantiation of general neural-symbolic computing in which symbol structures are given a ﬁller-role decomposition : the structure is captured by a set of N roles r i (e.g., left-child-of-root), each of which is bound to a ﬁller f i (e.g., a symbol).
A TPR embedding of a symbol structure S derives from vector embeddings of the roles { r i } and their ﬁllers
{ f i } via the outer or tensor product: S = (cid:80) Ni =1 r i ⊗ f i
=
(cid:80) Ni =1 r
i f (cid:62) i = RF (cid:62) , where R and
F respectively denote matrices having the role or ﬁller vectors as columns.
Each r i ⊗ f
i is the embedding of a role-ﬁller binding; ⊗ is the binding operation.
The unbinding operation returns the ﬁller of a particular role in S ; it is performed by the inner product: f i = u (cid:62) i S , where u i is the dual of r i , satisfying u (cid:62) i r j = δ ij .
Letting U be the matrix with columns { u i } , we have U (cid:62) R =
I .
Let { r i } ⊂ R d × 1 .
For present purposes it turns out that it sufﬁces to consider ﬁller vectors { f i } ⊂
R 1 × 1 , in which case S ∈ R d × 1 ; we henceforth denote S as b , a binding complex .
Let f ∈ R N × 1 =
F (cid:62) be the column vector comprised of the N { f i } ⊂ R 1 × 1 .
Now the binding and unbinding operations, simultaneously over all roles, become
[Equation]
and
[Equation]
With binding and unbinding operations and sufﬁcient role vectors, the binding complex b is able to represent data from a wide range of domains, with the structure of the data preserved.
We aim to incorporate symbolic computing into learning distributed representations of data when explicit structure is not presented to neural networks.
Speciﬁcally, we propose a recurrent unit that executes binding and unbinding operations according to Eq. 1.
The proposed recurrent unit leverages both the advantages of distributed representations and the ability to explore and maintain learnt structure from symbolic computing.
Our contribution is threefold:
• We propose a recurrent unit, named TPRU, which integrates symbolic computing with learning distributed representations, and has signiﬁcantly fewer parameters than widely used Long-short Term Memory (LSTM) [21] and Gated Recurrent Unit (GRU) [12].
• We present experimental results with the TPRU on both the Logical Entailment task [18] and the Multi-genre Natural Language Inference (MNLI) dataset [44], both of which arguably require high-quality structured representations for making good predictions.
The proposed unit provides strong performance on both tasks.
• The TPRU trained on MNLI with plain (attentionless) architecture demonstrates solid generalisation ability on downstream natural language tasks.
Related Work
Recent efforts on learning structured distributed representations can be roughly categorised into two types: enforcing a strong global geometrical constraint on the representation space, such as hyperbolic embedding [27, 46], and introducing inductive biases into the architecture of networks, including the Relational Memory Core [36] and neural-symbolic computing methods [9].
The latter category divides into models that insert neural networks into discrete structures [7, 34, 39] and those that insert discrete structures into neural network representations [19].
Our work falls in this last category: learning structured representations by incorporating the inductive biases inherent in TPRs.
Some prior work has incorporated TPRs into RNN representations.
Question-answering on SQuAD [35] was addressed [28] with a GRU in which the hidden state was a single TPR binding; the present work deploys complexes containing multiple bindings.
TPR-style unbinding was applied in caption generation [23], but the representations were deep-learnt and not explicitly designed to be TPRs as in the present work.
A contracted version of TPRs, Holographic Reduced Representations, was utilised to decompose input space and output space with ﬁller-role decomposition [6].
However, our work differs from prior work in that TPR ﬁller-role binding and unbinding operations are explicitly carried out in our proposed recurrent unit, and also, the two operations directly determine the calculation of the update on the hidden states.
The logical entailment task was introduced recently, and a model [18] was proposed that used given parse trees of the input propositions and was designed speciﬁcally for the task.
Our model does not receive parsed input and must learn simultaneously to identify, encode, and use the structure necessary to compute logical entailment.
NLI (or Recognising Textual Entailment) has assumed a central role in NLP [15].
Neural models have persistently made errors explicable as failure to encode propositional structure [10] and our work targets that particular capability.
Our proposed recurrent unit contains essential operations in symbolic computing systems, which encourages the learnt distributed representations to encode more structure-related information.
We can thus expect that our TPRU will give strong performance on both tasks even with signiﬁcantly reduced parameters.
Proposed Recurrent Unit: The TPRU
As shown in both LSTM [21] and GRU [12] design, a gating mechanism helps the hidden state at the current time step to directly copy information from the previous time step, and alleviate vanishing and exploding gradient issues.
Our proposed recurrent unit keeps the gating mechanism and adopts the design of the input gate in GRU.
At each time step, the TPRU receives two input vectors, one of which is the binding complex from the previous time step b t − 1 ∈ R d × 1 and the other is the vector representation of the external input to the network at the current time step x t ∈ R d (cid:48)
× 1 .
The TPRU produces a binding complex b t ∈ R d × 1 .
An input gate g t is computed to calculate a weighted sum of the information produced at current time step (cid:101) b t and the binding complex from the previous time step b t − 1 ,
[Equation]
where σ ( · ) is the logistic sigmoid function, tanh ( · ) is the hyperbolic tangent function, ◦ is the
Hadamard (element-wise) product, and W b ∈ R d × d and W x ∈ R d × d (cid:48) are matrices of learnable parameters.
As we now explain, the calculation of (cid:101) b t is carried out by the unbinding and binding operations of TPR (Eq. 1).
3.1 Unbinding Operation
Consider a set of hypothesised unbinding vectors U
= [ u 1 , u 2 , ..., u N ] ∈ R d × N .
At time step t , these can be used to unbind ﬁllers f b,t from the previous binding complex b t − 1 using Eq.
We posit a matrix W ∈ R d × d (cid:48) that transforms the current input x t ∈ R d (cid:48) × 1 into the binding space
R d ×where it too can be unbound, yielding ﬁllers f x,t :
[Equation]
A strong sparsity constraint is enforced by applying a rectiﬁed linear unit (ReLU) to both f b,t and f x,t [45], and their interaction is calculated by taking the square of the sum of the two sparse vectors.
The resulting vector (cid:101) f t is then normalised to form a distribution f t .
[Equation]
where b b and b x are two scalar parameters for stable learning.
3.2 Binding Operation
Given a hypothesised set of binding role vectors R =
[ r 1 , r 2 , ..., r N ] ∈ R d × N , we apply the binding operation in Eq.
1 to the ﬁllers f t at time t to get the candidate update for the binding complex (cid:101) b t , (cid:101) b t =
Rf t .
The gating mechanism controls the weighted sum of the candidate vector (cid:101) b t and the previous binding complex b t − 1 to produce a binding complex b t at current time step, as given by Eqs.
2 and 3.
3.3 Unbinding and Binding Role Vectors
In the TPRU, there is a matrix of role vectors R used for the binding operation and a matrix of unbinding vectors U used for the unbinding operation.
To control the number of parameters in our proposed unit, instead of directly learning the role and unbinding vectors, a ﬁxed set of vectors
V =
[ v 1 , v 2 , ..., v N ] ∈ R d × N is sampled from a standard normal distribution, and two linear transformations W u , W r ∈ R d × d are learnt to transform V to U
= W u V and R =
W r V .
Therefore, in total, our proposed TPRU has ﬁve learnable matrices, including W u , W r , W b ∈ R d × d and W x , W ∈ R d × d (cid:48) .
Compared to the six parameter matrices of the GRU and the eight of the
LSTM, the total number of parameters in the TPRU is signiﬁcantly fewer.
Tasks
Two entailment tasks, including an abstract logical entailment task and a relatively realistic natural language entailment task, along with other downstream natural language tasks, are considered to demonstrate that the TPRU is capable of inducing structured representation through learning.
Each of the two entailment tasks provides pairs of samples, and for each pair, the model needs to tell whether the ﬁrst (the premise) entails the second (the hypothesis).
As our goal is to learn structured vector representations, the proposed TPRU serves as an encoding function, which learns to process a proposition or sentence one token at a time, and then produces a vector representation.
During learning, two vector representations are produced by the same recurrent unit given a pair of samples, then a simple feature engineering method (e.g. concatenation of the two representations) is applied to form an input vector to a subsequent classiﬁer which makes a ﬁnal prediction.
In general, with a simple classiﬁer, e.g. a linear classiﬁer or a multi-layer perceptron with a single hidden layer, the learning process forces the encoding function to produce high quality representations of samples, either propositions or sentences, and better vector representations lead to stronger performance.
4.1 Logical Entailment
In propositional logic, for a pair of propositions, A and B , the value of A (cid:15) B is independent of the identities of the shared variables between A and B , and is dependent only on the structure of the expression and the connectives in each subexpression, because of α -equivalence.
For example, p ∧ q (cid:15) q holds no matter how we replace variable p or q with any other variables or propositions.
Thus, logical entailment naturally is a good testbed for evaluating a model’s ability to carry out abstract, highly structure-sensitive reasoning [18].
Theoretically, it is possible to construct a truth table that contains as rows/worlds all possible combinations of values of variables in both propositions A and B ; the value of A (cid:15) B can be checked by going through every entry in each row.
An example is given in the supplementary material.
As the logical entailment task emphasises reasoning on connectives, it requires the learnt distributed vector representations to encode the structure of any given proposition to excel at the task.
The dataset used in our experiments has balanced positive and negative classes, and the task difﬁculty of the training set is comparable to that of the validation set.
2 Five test sets are generated to evaluate the generalisation ability at different difﬁculty levels: some test sets have signiﬁcantly more variables and operators than both the training and validation sets (see Table 1).
4.2 Multi-genre Natural Language Inference
Natural language inference (NLI) tasks require inferring word meaning in context as well as the hierarchical relations among constituents in a given sentence (either premise or hypothesis), and then reasoning whether the premise sentence entails the hypothesis sentence or not.
Compared to logical entailment, the inference and reasoning in NLI also rely on the identities of words in sentences in addition to their structure.
More importantly, the ambiguity and polysemicity of language lead to the impossibility of creating a truth table that lists all cases.
Therefore, NLI is an intrinsically hard task.
The Multi-genre Natural Language Inference (MNLI) dataset [44] collected sentence pairs in ten genres; only ﬁve genres are available in the training set, while all ten genres are presented in the development set.
There are three classes, Entailment, Neutral and Contradiction.
The performance of a model on the mismatched genres, which exist in the development but not the training set, tells us how well the structure encoded in distributed vector representations of sentences learnt from seen genres in training generalises to sentence pairs in unseen genres.
As the nature of NLI tasks requires inferring both word meaning and structure of constituents in a given sentence, supervised training signals from labelled datasets enforce an encoding function to analyse meaning and structure at the same time during learning, which eventually forces distributed vector representations of sentences produced from the learnt encoding function to be structured.
Thus, a suitable inductive bias that enhances the ability to learn structures of sentences will enhance success on the MNLI task.
4.3 Downstream Natural Language Tasks
Vector representations of sentences learnt from labelled NLI tasks demonstrate strong transferability and generalisation ability, which indicates that the learnt encoding function can be applied as a general-purpose sentence encoder to other downstream natural language tasks [14].
As our proposed
TPRU is also able to map any given sentence into a distributed vector representation, it is reasonable to evaluate the learnt vector representations on other natural language tasks, and the performance of our proposed recurrent unit will tell us the generalisation ability of the learnt representations.
SentEval [13] presents a collection of natural language tasks in various domains, including sentiment analysis (MR [30], SST [40], CR [22], SUBJ [29], MPQA [43]), paraphrase detection (MRPC [17]), semantic relatedness (SICK [26]), question-type classiﬁcation (TREC [25]) and semantic textual similarity (STS [1, 2, 3, 4, 5]).
Except for STS tasks, in which the cosine similarity of a pair of sentence representations is compared with a human-annotated similarity score, each of the tasks requires learning a linear classiﬁer on top of produced sentence representations to make predictions.
the training set thrice, and ‘ ‡ ’ indicates that the GRU with BiDAF architecture failed twice.
Our TPRU didn’t fail or overﬁt during learning and provided comparable performance with to the LSTM and GRU
[Table]
Training Details
Experiments are conducted in PyTorch [32] with the Adam optimiser [24] and gradient clipping [31].
Reported results are averaged from the results of three different random initialisations
[Table]
5.1 Plain Architecture
For the Logical Entailment task, we train our proposed TPRU as well as LSTM [21] and GRU [12]
RNNs for 90 epochs.
Only the output at the last time step is regarded as the representation of a given proposition, and two proposition representations are concatenated, as done in previous work [18], and fed into a multi-layer perceptron which has only one hidden layer with ReLU activation function.
The initial learning rate is 0 .
001 and divided by 10 every 30 epochs.
The best model is picked based on the performance on the validation set
[Table]
and then evaluated on all ﬁve test sets with different difﬁculty levels.
Symbolic Vocabulary Permutation [18] is applied as data augmentation during learning which systematically replaces variables with randomly sampled variables according to α -equivalence as only connectives matter on this task.
Detailed results are presented Table
[Table]
[Table]
For the MNLI task, our proposed TPRU as well as LSTM and GRU units are trained for 10 epochs.
A global max-pooling over time is applied on top of binding complexes produced by each recurrent unit at all time steps to generate the vector representation for a given sentence.
Given a pair of generated sentence representations u and v , a vector is constructed to represent the difference between two vectors [ u ; v ; | u − v | ; u ◦ v ] , where u ◦ v is the Hadamard (element-wise) product and | u − v | is the absolute difference, and the vector is fed into a multi-layer perceptron with the same settings as given above.
The feature engineering and the choice of classiﬁer are suggested by prior work [37, 41].
The Stanford Natural Language Inference (SNLI) dataset [10] is added as additional training data as recommended [41], and ELMo [33] is applied for producing vector representations of words.
The initial learning rate is 0.0001, and kept constant during learning.
The best model is chosen according to the averaged classiﬁcation accuracy on matched (ﬁve genres that exist in both training and dev set) and mismatched (ﬁve genres in dev set only) set.
LSTM and GRU models use the same settings.
The performance of each model is presented in Table 2.
For downstream natural language tasks, the parameters in the learnt recurrent unit — our proposed
TPRU, LSTM or GRU trained on the MNLI task — are ﬁxed and used to extract vector representations of sentences for each task.
Linear logistic regression or softmax regression is applied when additional learning is required to make predictions.
Details of hyperparameter settings of the classiﬁers can be found in the SentEval package.
3 Table 3 presents macro-averaged results, which are Binary (MR, CR,
SUBJ, MPQA, and SST), STS (Su., including SICK-R and SICK-Benchmark), STS (Un., including
STS12-16), TREC, SICK-E, and MRPC.
[Table] [Table]
5.2 BiDAF Architecture
Bi-directional Attention Flow ( BiDAF ) [37] has been adopted in various natural language tasks, including machine comprehension [37] and question answering [11], and provides strong performance on NLI tasks [41].
The BiDAF architecture can generally be applied to any task that requires modelling relations between pairs of sequences.
As both the Logical Entailment and MNLI tasks require classiﬁcation of whether sequence A entails sequence B , BiDAF is well-suited here.
The BiDAF architecture contains a layer for encoding two input sequences, and another for encoding the concatenation of the output from the ﬁrst layer and the context vectors determined by the bidirectional attention mechanism.
In our experiments, the dimensions of both layers are set to be the same, and same type of recurrent unit is applied across both layers.
The same settings are used for experiments on LSTM, GRU and our TPRU models.
Speciﬁcally, for TPRU, the recurrent units in both layers have the same number of role vectors.
Other learning details are as in the plain architecture.
Tables 1 and 2 respectively present results on the Logical Entailment and the MNLI task, with BiDAF results in parentheses.
Discussion
As presented in Tables 1 and 2, our proposed TPRU provides solid performance.
On the Logical
Entailment task, the TPRU provides similar performance with the LSTM and GRU under both the plain and BiDAF architectures, but the TPRU has signiﬁcantly fewer parameters.
When it comes to larger dimensionality, our TPRU appears to be more stable than LSTM and GRU during learning as we observed that the LSTM with the plain architecture overﬁtted the training set terribly in all three trials and the GRU with the BiDAF architecture failed in two out of three trials.
On the MNLI task, our proposed TPRU consistently outperforms both the LSTM and GRU under all four combinations of different dimensions and architectures.
Unexpectedly, all models, including
LSTM, GRU and our TPRU, provide better results on dev mismatched set than on the matched one, and this is possibly because the dev mismatched set is slightly easier.
In Table 3, the TPRU under the plain architecture generalises as well as the LSTM and GRU on 16 downstream tasks in SentEval.
Effect of Increasing the Number of Role Vectors :
In TPR [38], the number of role vectors indicates the number of unique symbols that will be used in the ﬁnal representations of the data.
[Figure]
Since each symbol is capable of representing a speciﬁc substructure of the input data, increasing the number of role vectors eventually leads to more highly structured representations if there is no limit on the dimensionality of role vectors.
Experiments are conducted to show the effect of increasing the number of role vectors on the performance on both tasks.
As shown in Tables 1 and 2, adding more role vectors into our proposed
TPRU gradually improves the performance on the two entailment tasks.
Interestingly, on the MNLI task, our proposed TPRU with only 16 role vectors achieves similar performance to that of the LSTM and GRU, which implies that the distributed representations learnt in both the LSTM and GRU are highly redundant and can be reduced to 16 or even fewer dimensions, which also shows that the LSTM and GRU are not able to extensively exploit the representation space.
Meanwhile, the introduced symbolic computing executed by binding and unbinding operations in our proposed unit encourages the model to take advantage of distinct role vectors to learn useful structured representations.
Figure 1 presents the learning curves, including training loss and accuracy, of our proposed TPRU with different number of role vectors on the two entailment tasks.
As shown in the graphs, incorporating more role vectors leads to not only better performance, but also faster convergence during training.
The observation is consistent on both the Logical Entailment and MNLI tasks.
Conclusion
We proposed a recurrent unit (TPRU) that executes binding and unbinding operations in Tensor
Product Representations.
The explicit execution in our proposed recurrent unit helps it leverage advantages of both distributed representations and neural-symbolic computing, which essentially allows it to learn structured representations.
Compared to widely used recurrent units, including
LSTM and GRU, our proposed TPRU has many fewer parameters.
The Logical Entailment and Multi-genre Natural Language Inference tasks are selected for experiments as both tasks require highly structured representations to make good predictions.
Plain and
BiDAF architectures are applied on both tasks.
Our proposed TPRU outperforms its comparison partners, the LSTM and GRU, on MNLI tasks with different dimensions and architectures, and it performs similarly to others on the Logical Entailment task.
Analysis shows that adding more role vectors tends to provide stronger results and faster convergence during learning, which parallels the utility of symbols in symbolic computing systems.
We believe that our work pushes the existing research topic on interpreting RNNs into another direction by incorporating symbolic computing.
Future work should focus on the interpretabilty of our proposed TPRU as the symbolic computing is explicitly conducted by binding and unbinding operations.
Acknowledgements
Many thanks to Microsoft Research AI, Redmond for supporting the research, and to Elizabeth
Clark and YooJung Choi for helpful clariﬁcation of concepts.
Thanks to Zeyu Chen for the technical support.
A A Look-up Table Approach to Logical Entailment
Given [Table] and [Table]
[Table] presents all
[Table]
[Table]