This repo contains the code for the paper Neuro-Symbolic Integration Brings Causal and Reliable Reasoning Proofs
CaRing (Causal and Reliable Reasoning) is a neuro-symbolic integration method for compelx reasoning problems. The main advantage of CaRing is that it produces strictly causal and reliable reasoning proofs along with the answer, allowing humans to understand the reasoning process of the model and verify the correctness and safety of the answer.
conda create -n caring python=3.9
conda activate caring
git clone https://github.com/DAMO-NLP-SG/CaRing.git
cd CaRing
# We use cuda=11.8, you may change it to your cuda version
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118
pip install -r requirements.txt
Here are some problems that you may encounter when installing the environment: [Issue-1].
Note: Below installation steps follow the guide from the SWI-Prolog official page.
-
For Ubuntu Machines:
sudo apt-get update sudo apt-get install software-properties-common sudo apt-add-repository ppa:swi-prolog/stable sudo apt-get update sudo apt-get install swi-prolog pip install git+https://github.com/yuce/pyswip@master#egg=pyswip
-
Other Linux Machines:
See the SWI-Prolog official page.
cd CaRing
mkdir output
export MODE=prolog # Our Method
# export MODE=cot # CoT
sh scripts/run_proofwriter.sh ${MODE}
# sh scripts/run_gsm8k.sh ${MODE}
# sh scripts/run_prontoqa.sh ${MODE}
You may customize the configurations in the corresponding .sh
scripts.
Currently we support Code-LLaMA series as the base LLM.
- ProofWriter
export MODE=prolog # Our Method # export MODE=cot # CoT python evaluate.py \ --gpt_response_path ../output/proofwriter/${MODE}.CodeLlama-34b-hf.num_samples--1.demo-1_2.json \ --dataset_name proofwriter \ --evaluate_proof \ --use_multiprocessing
- GSM8K
export MODE=prolog # Our Method # export MODE=cot # CoT python evaluate.py \ --gpt_response_path ../output/gsm8k/${MODE}.CodeLlama-34b-hf.num_samples--1.demo-1_2_3_4_5.json \ --dataset_name gsm8k \ --evaluate_proof \ --use_multiprocessing
- PrOntoQA
export MODE=prolog # Our Method # export MODE=cot # CoT python evaluate.py \ --gpt_response_path ../output/prontoqa/${MODE}.CodeLlama-34b-hf.num_samples--1.demo-1_2.json \ --dataset_name prontoqa \ --use_multiprocessing
If you find this project useful, please consider citing our work:
@article{yang2023neuro,
title={Neuro-Symbolic Integration Brings Causal and Reliable Reasoning Proofs},
author="Yang, Sen and
Li, Xin and
Cui, Leyang and
Bing, Lidong and
Lam, Wai",
journal={arXiv preprint},
year={2023}
}
This project makes use of the following open-source projects: