Home

Awesome

RR

This is the code repository for the Arxiv paper Rethinking with Retrieval: Faithful Large Language Model Inference. If you use this code for your work, please cite

@article{he2022rethinking,
  title={Rethinking with Retrieval: Faithful Large Language Model Inference},
  author={He, Hangfeng and Zhang, Hongming and Roth, Dan},
  journal={arXiv preprint arXiv:2301.00303},
  year={2022}
}

Installing dependencies

Use virtual environment tools (e.g miniconda) to install packages and run experiments
python==3.7.10
pip install -r requirements.txt

If you couldn't install all dependencies in one virtual environment, you may need three different virtual environments:

Code organization

The code is organized as follows:

Change the working path

Change the /path/to/working/dir to the path to your working directory.

Export OPENAI API KEY

You need to export your own OpenAI API key before running experiments with OpenAI API, i.e., export OPENAI_API_KEY=$YOUR_OPENAI_API_KEY

Data preparation

Download and put StrategyQA dataset under /path/to/working/dir/Commonsense/
Download and put TempQeustions datset (link: http://qa.mpi-inf.mpg.de/TempQuestions.zip) under /path/to/working/dir/Temporal/
Download and put INFOTABS dataset under /path/to/working/dir/Tabular/

Reproducing experiments

To reproduce the experiments for commonsense reasoning:

python commonsense_gpt3.py
python commonsense_wikipedia.py
python commonsense_evidence.py
python commonsense_inference.py

To reproduce the experiments for temporal reasoning:

python temporal_preprocessing.py
python temporal_gpt3.py
python temporal_wikidata.py
python temporal_evidence.py
python temporal_inference.py

To reproduce the experiments for tabular reasoning:

python tabular_preprocessing.py
python tabular_gpt3.py
python tabular_evidence.py
python tabular_inference.py