This project explores the capabilities of Large Language Models (LLMs) in understanding, translating, and reasoning with predicate logic.
The repository contains experiments analyzing how LLMs perform in translating natural language sentences into formal first-order logic (FOL) notation. The analysis includes both Chain of Thought (CoT) and In-Context Learning (ICL) approaches.
-
Notebooks:
LLM_Predicate_Logic_Project.ipynb
: Natural language to logic translationLLM_Predicate_Logic_CoT.ipynb
: Chain of Thought experimentsLLM_Predicate_Logic_ICL.ipynb
: In-Context Learning experimentsanalysis_cot.ipynb
: Analysis of CoT resultsanalysis_icl.ipynb
: Analysis of ICL resultsanalysis.ipynb
: General analysisdata_visualization.ipynb
: Visualizations of results
-
Data:
dataset/data.csv
: Source datasetresults_cot.csv
: Results from Chain of Thought experimentsresults_icl.csv
: Results from In-Context Learning experimentsresults.csv
: Aggregated resultsllm_text2log_outputs.csv
: Model outputs translating text to logic
The project investigates the performance of LLMs in understanding and translating natural language sentences (like "Some men are wolves") into first-order logic expressions (such as "exists x1.(_man(x1) & exists x2.(_wolf(x2) & (x1 = x2)))").
Two main approaches are explored:
- Chain of Thought (CoT): Prompting the model to explain its reasoning process step by step
- In-Context Learning (ICL): Providing examples to guide the model's translations
The notebooks contain detailed analysis of model performance, including:
- Accuracy metrics for different types of logical statements
- Comparison between CoT and ICL appro
- Clone this repository
- Install the required dependencies (see requirements in notebooks)
- Run the notebooks in your preferred environment
- Python 3.x
- Pandas
- Jupyter
- LLM API access (specifics in notebooks)