Transferring Representations of Logical Connectives (2021)

Abstract: In modern natural language processing pipelines, it is common practice to “pretrain” a generative language model on a large corpus of text, and then to “finetune” the created representations by continuing to train them on a discriminative textual inference task. However, it is not immediately clear whether the logical meaning necessary to model logical entailment is captured by language models in this paradigm. We examine this pretrain-finetune recipe with language models trained on a synthetic propositional language entailment task, and present results on test sets probing models’ knowledge of axioms of first order logic.

## introduction in modern natural language processing pipelines, it is common practice to "pretrain" a generative language model on a large corpus of text, and then to "finetune" the created representations by continuing to train them on a discriminative textual inference task. this pretrain-finetune recipe has led to state-of-the-art accuracy on natural language inference tasks @xcite , including tasks that explicitly target logical, compositional reasoning @xcite . however, a priori, it is not obvious that language model pretraining should lead models to encode anything mirroring the functions of logical concepts such as entailment, negation, and disjunction, despite their importance in language, and in fact there are many reasons why we might directly expect language modeling not to encode logical meaning: for example, language modeling does not provide models with access to variable bindings or truth values (a key component for defining logical functions), and it only provides models with access to positive training examples (sentences that are true in some possible world, assuming they were true at the time they were uttered) but not negative examples (sentences that have never been attested). this difference between our expectations for these models and their empirical performance gives rise to a broader question: under what conditions can core logical concepts emerge, and what information is sufficient to learn them? we assume entailment as a task is crucial to beginning to form an answer; if a system can accurately determine whether a given premise logically entails a given hypothesis, it may have a representation of logical conjunction, disjunction, conditionals, and negation. thus, by observing how language model pretraining affects the performance of a model of logical entailment, we can better understand the extent to which these models capture logical reasoning capabilities, if at all. the primary question we aim to answer is: does the traditional language modelling objective result in representations which readily support classical logical reasoning? due to the pervasiveness of statistical artifacts in natural language inference datasets @xcite , directly assessing the logical reasoning capabilities of neural models using these datasets is challenging. thus, we design a set of experiments using a toy dataset and task which uses propositional logic sentences in place of natural language, but otherwise uses the same common pretraining+finetuning recipe. note that we do not aim to answer the question "can neural networks do logical reasoning" in general. this question has been explored extensively elsewhere (see e.g. @xcite @xcite ). rather, we are interested in understanding what aspects of logical reasoning can be encoded during unsupervised pretraining. specifically, we test whether sentence encodings learned on a language modeling task transfer to a "downstream" entailment task, i.e. improving the efficiency and/or accuracy of the model trained on the downstream task. ## experiments we compare the performance on the entailment task of a classifier on top of a model pretrained on the language modelling objective described in 2.1 to that of a classifier on top of a model with randomly initialized parameters. models were implemented in pytorch @xcite and were trained using gpus. we conduct a large hyperparameter sweep for each of our four settings: lstms and transformers as classifier models with and without pretraining before the entailment task. we search across learning rate, hidden dimension, symbol embedding dimension, dropout, weight decay, and, respective to each model, number of stacked lstms and number of transformer heads/layers. ## results the entailment dataset is evenly balanced, so maximum class accuracy is 50%. as shown in figure 2 plots the relationship between the per-plexity and accuracy that lstm models converge to. there appears to be a local minimum of perplexity that the models achieve in pretraining, and this data suggests no relationship between lower perplexity of the language model and higher accuracy. the models do not perform well on the diagnostic axiomatic test set dataset across the board, as observed in figure 3 . despite the extensive training in each scenario, the models are unable to regularly capture even extremely simple patterns, such as double negation of one clause. the effect of clause length varies-the models may be picking up on dataset artifacts for shorter premises and hypotheses. furthermore, despite its low performance at the entailment task, the f1 score of the continuous bag of words model is significantly higher than that of the other models. this is an interesting trend that could be due to the pretraining leading the model into a poor initialization, which requires further investigation. ## discussion in our experiments, we find mixed evidence to suggest that language model pretraining on sentences gives a reliable performance increase over models trained entirely from scratch with regards to purely logical entailment. on average, pretrained lstms and transformers perform slightly better than those initialized entirely from scratch, but the performance of these models at held-out test sets which specifically probe fundamental axioms of logical entailment is underwhelming and worse than the baseline model. furthermore, no model performs especially well at the entailment task-logical operators are applied inflexibly to their input, and no model performs near 100% accuracy. it is potentially the case that, within modern natural language inference pipelines, the logical information encoded at the pretraining step is partially responsible for the increase in accuracy at downstream tasks. however, it is hard to say that any such transfer of representations that facilitate explicit logical capabilities occurs. it is possible that language models, if they do not preserve logical information, lead models to perform well at entailment tasks in general by capturing complex lexical heuristics and associations between topics at the pretraining step. in future work, we will test whether pretraining on both positive and negative examples affects entailment performance. furthermore, we will test whether adjusting from a uniform distribution of the symbols to a zipfian distribution causes the performance of the pretrained model to improve, which would suggest that these models rely much more heavily on exploiting frequency heuristics than captured logical capabilities to more accurately model the training data.