Learning Semantic Structure through First-Order-Logic Translation (2024)

Abstract: In this paper, we study whether transformer-based language models can extract predicate argument structure from simple sentences. We firstly show that language models sometimes confuse which predicates apply to which objects. To mitigate this, we explore two tasks: question answering (Q/A), and first order logic (FOL) translation, and two regimes, prompting and finetuning. In FOL translation, we finetune several large language models on synthetic datasets designed to gauge their generalization abilities. For Q/A, we finetune encoder models like BERT and RoBERTa and use prompting for LLMs. The results show that FOL translation for LLMs is better suited to learn predicate argument structure.

## introduction transformer-based language models (lms) @xcite have attracted enormous interest because of their language generating capacities and prowess in many nlp tasks. we are interested in lms and their ability to exploit semantic structure for both grasping linguistic meaning and inference. in this paper, we concentrate on an elementary building block of semantic structure, i.e., predicate argument structure. for example, predicate argument structure determines that the predicate blue applies to house and not car in the sentence: predicate argument structure also determines which arguments fill which places in two place predicates like in front of; in our example, it is the car that is in front of the house, not the house in front of the car. recovering predicate argument structure is crucial to capturing and reasoning about the meaning of natural language sentences. if an lm mixes up which object has which property in a premise, it is guaranteed to make errors in reasoning. while semantic structure eventually involves the scopes of operators and quantifiers and verbal modification using tense or adverbial phrases, in this paper, we concentrate simply on capturing the predicate argument structure of basic predicates applied to object denoting nouns like car. our experiments are restricted to simple sentences involving two indefinite noun phrases (nps) with one or more modifying predicates for each np. an example of one such sentence is (1), containing two noun phrases a red car and a blue house. the motivation behind using such sentences is to study whether current models are able to capture predicate argument structure in relatively simple scenarios. while being able to capture semantic structure in such cases doesn't necessitate generalization to actual linguistic data, it is an important precursor towards this goal. further, synthetic examples also help pinpoint the kinds of difficulties faced by the current models. we investigate two approaches for analysing llms' ability to capture predicate argument structure: we find that both encoder models and llms are able to learn predicate argument structure for simple sentences with just one predicate for each object mentioned. however, encoder models are unable to generalize to more complex sentences involving more predicates for the two objects mentioned, and even llms fail to fully master the predicate argument structure of such sentences. for smaller encoder models, finetuning results in a much higher accuracy when testing on similar patterns to training data but a low accuracy on dissimilar patterns, as a result of overfitting. for llms, the fol translation gives better results in comparison with q/a prompting, showing that llms can generalize from the simple predicate argument structure to more complex sentences. we find that translation approach also has the important advantage of showing when models add hallucinated content, which we argue a q/a method cannot do. in what follows, section 2 provides motivation and surveys relevant prior work. section 3 gives some preliminaries for our study, while section 4 describes our synthetic datasets. section 5 gives the results of our experiments. finally, in section 6, we discuss conclusions and potential future work. their synthetic dataset contains 1040 questions (520 "yes" and "no" questions each) on contexts using schemas (2-a) or (2-b) with different color combinations. for each schema, they provide two questions that are semantically equivalent given the context (e.g. "was the car col1?" and "was there a col1 car?"). they then test whether the models, finetuned on the coqa dataset @xcite , could correctly associate the properties with their relevant bearers in a simple question answering task. they find that all the models except roberta-large @xcite achieve low accuracy on this simple q/a test; the encoder models also behave differently and rather strangely with regard to the original and modified questions. we provide their results in feng and steinhardt (2023) investigate the binding problem for entity referring expressions (typically proper names) linked by predicates, though they did not investigate the predicate argument binding problem per se and certainly not in its full generality. they examine representations in a transformer after attention and linear normalization layers and argue that binding is done though a particular identification vector. in this paper, we look at the binding problem between simple properties conveyed by adjectives and their bearers typically introduced by indefinite noun phrases. our preliminary experiments indicate that even substantial llms do not completely solve this problem. it is known that lms can learn features of abstract syntactic representations of natural language sentences like long distance dependencies involving subject verb argument agreement @xcite and the rarer object past participle agreement in languages like french @xcite . @xcite show lms have near perfect performance on short embedded syntactic dependencies but fail on longer distance embedded dependencies. we are interested in whether lms can learn the mapping from syntax to semantic representations, of which predicate argument structure is the basic building block. @xcite points out the problems of generalization for transformer models. @xcite integrate llms with a theorem prover for natural language inference. they first prompt llms to translate text to fol. the resultant fol is passed to a theorem prover in order to predict an output. in this work, we look at two approaches to extract predicate argument structure from simple sentences: question-answering, and fol translation. for question answering, we look at finetuning for encoder models and prompting for llms. whereas, for fol translation, we look at finetuning of llms. model org-acc mod-acc mistral-7b 97.1 (52.1) 92.5 (42.5) llama-2-7b 74.2 (55.8) 80.2 (34.4) llama-2-13b 99.0 (50.1) 93.3 (45.6) llama-3-8b 81.3 (65.6) 87.1 (58.3) ## preliminaries as mentioned in section 2, we are interested to see whether the models can learn, through finetuning or prompting, the structure of a semantic representation. given the successes of the models with learning syntactic structure, it is feasible to assume a good level of performance. to this end, we first check whether the results from @xcite were just a limitation of smaller encoder models, like bert and roberta. we ran the same experiment on large language models (llms) in the mistral @xcite , llama-2 @xcite and llama-3 @xcite families. the results are shown in since models can not master recovering even a simple predicate argument structure, we need to ask what about a string makes this recovery difficult. formal linguistics provides a map µ from sentences to logical form and predicate argument structure either via an intermediate stage of syntactic structure or directly as in some forms of categorical grammar @xcite . to recover predicate argument structure of a sentence, a model will have to learn an algorithm that given an input string has the same output as µ. by examining µ, we can pinpoint areas of difficulty for learning predicate argument structure. the predicate argument structures of the sentences used in this work can be expressed with a simple, first order logical formula, consisting of a conjunction of positive atomic formulae of the form ϕ(α 1 ) or ψ(α 1 , α 2 ) where α i is a constant or a variable representing an individual object. proper names introduce constants while indefinite noun phrases like a car introduce an existentially quantified variable. for instance, (1) has the logical form ∃x∃y(red(x) ∧ car(x) ∧ blue(y) ∧ house(y) ∧ inf rontof (x, y)). given our input strings and target predicate argument structures, there are two kinds of difficulty an algorithm must solve to find the predicate argument structure. the first has to do with the complexity of a noun phrase (np) with multiple modifiers. in languages like english or french, a complex np like an old, green dirty car is syntactically realized in terms of "modifier depth" and has the syntactic structure @xcite to get the right predicate argument structure with sentences containing such nps, the model has to "unwind" the syntactic tree applying each predicate to the variable that is the argument of the predicate introduced by the noun. the ability to generalize from simple modification to more complex modification in a general way requires an ability to learn recursion. without recursion, a model may learn different patterns for combinations of adjectives. however, this approach would require training on most (if not all) possible combinations of adjectives. the other source of difficulty for learning predicate argument structure are long distance dependencies. syntactic realizations of these involve for example relative clauses as in: the predicate red in (3) is not close to its bearer. such long distance dependencies have various syntactic representations (e.g. trace binding after movement in theories that allow movement) or require type raising in categorical grammars, which rewrites a function to take an argument of different type @xcite , to guide µ to link the predicate with its argument. we look at both kinds of difficulty by investigating lm behavior on a variety of synthetic datasets. these datasets enable us to narrow down what algorithms lms use to capture predicate argument structure given these two dimensions of complexity. for instance, it is possible for a model to do well say on a q/a dataset by finding "short cut" algorithms instead of the true predicate argument structure. for instance, the model might guess the right answer to a question like is there a red car? for a sentence like (1) simply by computing the shortest distance between a color term and car, in the context. but this will fail for examples like (3). we use two tests to determine whether the model has correctly grasped the predicate argument structure of the context. the first is a q/a task that asks about which objects in the context have which properties. the answers to the questions should completely determine the logical form of the context. it turns out, as we show in section 5, that this is difficult to do. the second way is for the model to produce the logical form directly. for this task, we give the model a sentence from our synthetic dataset as input and train it to output a correct logical form for that sentence in first order logic. a complicating factor in the design of the q/a experiments is what form the questions in the q/a task should take. @xcite show that encoder models are sensitive to different formulations of a question in q/a tasks. they behave quite differently when answering questions that are semantically equivalent given the input context, as we can see by comparing org-acc and mod-acc in ## datasets and models to probe a model's grasp of predicate argument structure in more detail, we develop several synthetic datasets of increasing complexity. the original dataset of @xcite consists of 5 templates, each containing two objects of different color. for each template, there were two semantically equivalent questions: original question of the type "was the obj col1?", and modified question of the type "was there a col1 obj?" where col1 and obj refer to color and object respectively. all the 5 templates have the objects and the corresponding color next to each other (e.g. "the red car was in front of the blue house"). as a result of this, we observed that when a model is trained on one of the templates, it learns to generalize to other templates as well. to counteract this, we extend the original dataset to 25 templates containing more complex templates with several long distance predicate argument structures as in (3) but also red was not the color of the car but of the house. we refer to this dataset as d 1,1 . we list down all the 25 templates along with their fol translation in along with our synthetic datasets, we also work with the folio dataset @xcite . this dataset is an nli dataset but also provides the first-order logic form for premises and hypotheses. we make use of these fol forms along with a portion of our synthetic dataset to finetune llms to generate first order logic from simple sentences. we experiment with four llms, namely, llama-2-7b, llama-2-13b @xcite , mistral-7b @xcite , and llama-3-8b @xcite . for finetuning these models, we use the qlora method @xcite . all the models are finetuned for 10 epochs. we provide details of computing infrastructure and hyperparameters in ## conclusions in this paper, we investigate smaller encoder models and moderate sized llm's grasp of predicate argument structure for simple sentences. we use two types of methods for finding predicate argument structure: q/a and first order logic (fol) translation and examined their behavior on our synthetic datasets. the results show that neither of the two approaches succeed in mastering this fundamental aspect of meaning. after finetuning, encoder models still could not generalize from their training to find predicate argument structure of more complex sentences. however, llms does manage to show considerable generalization ability with finetuning on the fol translation task. overall, we find that finetuning on the translation task gave the best results for learning predicate argument structure. our results also show that llms (especially llama-2-13b, and llama-3-8b) tend to hallucinate when finetuned for fol translation. recent work has shown that a rag-based approach can help mitigate hallucination @xcite . this could be a possible avenue for future work, where a rag-based approach limits the predicates a model can use in its translation into fol. we have discussed prompting vs. finetuning on models of the same size. however, for much larger models, or models that are not open, finetuning is not an option. @xcite show that the gpt-instruct models @xcite , namely, text-davinci-002, and text-davinci-003; achieve near-perfect accuracy on their basic predicate-argument dataset. we plan to test the latest gpt models on our more complex datasets in the future.