Large Language Models (LLMs) have been widely found to struggle with logical reasoning, where even fine-tuned models fail dramatically on out-of-distribution problems. However, existing work has focused on relatively complex "many-hop" reasoning problems. In this work, we analyse the performance of fine-tuned LLMs on simple reasoning problems, all of which can be solved in at most three inference steps. Due to the simplicity of these problems, the model cannot encounter test problems that are fundamentally different from those it has seen during training. Unfortunately, however, we find that the models remain highly brittle, being susceptible to seemingly innocent perturbations, such as the addition of duplicates to the set of premises and shuffling the order in which the premises are presented.
This repository provides code implementation and generated dataset for reproducing simple reasoning entailments. We populate all train, validation, and test sets needed in dataset/ directory, thus generating data from scratch is optional. This directory contains SAT parts as follows:
- Use
default_train.rarto fine-tune the models on SAT distribution. dataset/default_testcontains test scenarios needed to reproduce results in Table 1.- To evaluate the impact of duplicate premises on the fine-tuned models or reproduce Figure 2 and Figure 4, use test sets in
dataset/impact_of_duplicates. - Test the fine-tuned models using scenarios in
dataset/impact_of_orderto obtain Figure 3 and Figure 5. dataset/impact_of_duplicates_ordercontains both duplicates and shuffled literals. Use this test to reproduce result in Table 4.- As Table 5 shows the impact of verbalization, test the models using
dataset/verbalization_test.
Dataset Distribution
To conduct out-of-distribution test, we implemented two others different dataset distributions: Rule Priority (RP) and Label Priority (LP). Please note that we populated the RP and LP test following SimpleLogic in this repository: Zhang et al., 2022
These instructions are optional. Only follow these if you wish to generate the SAT simple propositional entailments from scratch.
- Download and install SAT4J library from sat4j.org to your java IDE.
- Run
main.javato generate propositional entailments in dimacs format.
The following .py files are needed for further data preprocessing starts from dimacs:
calculate_depth.pyto calculate the reasoning depth, number of literals, steps, and ratio of new clauses.data_sampling.pyto uniform sampling based on number of examples and reasoning depth. The bash script below is used to sample 10K instances from previous dimacs file with the same number of population per group. Also note that we will have 8 groups ranging from depth 0 to 3 with a balance positive and negative labels.#!/bin/bash python data_sampling.py \ --dataset_name [dimacs_filename] --samples_per_group 1250 --max_hop 3sat_to_sentences.pyto translate dimacs formulas into natural sentences. By default, the referredSATConverter_Alice.pyusessr/vocab_500.txtin df_predicate_list to translate each literal into default list of predicates. Alternatively, we need to modify this source later for setting the verbalization tests.src/baby-names.txtto randomize subject names with others,src/colors_500.txtto convert default predicates into the list of color names.