Home

Awesome

RATT: A Thought Structure for Coherent and Correct LLM Reasoning

Introduction

Welcome to the GitHub repository for the paper "RATT: A Thought Structure for Coherent and Correct LLM Reasoning."

Large Language Models (LLMs) gain substantial reasoning and decision-making capabilities from thought structures. However, existing methods such as Tree of Thought and Retrieval Augmented Thoughts often fall short in complex tasks due to the limitations of insufficient local retrieval of factual knowledge and inadequate global selection of strategies. These limitations make it challenging for these methods to balance factual accuracy and comprehensive logical optimization effectively. To address these limitations, we introduce the Retrieval Augmented Thought Tree (RATT), a novel thought structure that considers both overall logical soundness and factual correctness at each step of the thinking process. Specifically, at every point of a thought branch, RATT performs planning and lookahead to explore and evaluate multiple potential reasoning steps, and integrate the fact-checking ability of Retrieval-Augmented Generation (RAG) with LLM's ability to assess overall strategy. Through this combination of factual knowledge and strategic feasibility, the RATT adjusts and integrates the thought tree structure to search for the most promising branches within the search space. This thought structure significantly enhances the model's coherence in logical inference and efficiency in decision-making, and thus increases the limit of the capacity of LLM to generate reliable inferences and decisions based on thought structures. A broad range of experiments on different types of tasks showcases that the RATT structure significantly outperforms existing methods in factual correctness and logical coherence.

Prerequisites

Please obtain the following part or all API keys according to your needs.

os.environ["OPENAI_API_KEY"] = "" # Your Openai API key
os.environ["GOOGLE_API_KEY"] = "" # Your Google API Key
os.environ["GOOGLE_CSE_ID"] = "" # Your Google CSE ID

Getting Started

We have released two versions of RATT, each corresponding to a RAG library based on web content and local documents.

The example_creative_writing_offline.ipynb notebook demonstrates an example of generating creative text by using a local file llama2.pdf as the library for retrieval.

The example_creative_writing.py script demonstrates an example of generating creative text by using English Wikipedia page content from Google Search as the library for retrieval.

Citation

@misc{zhang2024rattthoughtstructurecoherent,
      title={RATT: A Thought Structure for Coherent and Correct LLM Reasoning}, 
      author={Jinghan Zhang and Xiting Wang and Weijieying Ren and Lu Jiang and Dongjie Wang and Kunpeng Liu},
      year={2024},
      eprint={2406.02746},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2406.02746}, 
}