MCPcopy Index your code
hub / github.com/CraftJarvis/RAT

github.com/CraftJarvis/RAT @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
23 symbols 57 edges 1 files 4 documented · 17%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Horizon Generation

[Website] [Paper] [Demo]

Abstract

We explore how iterative revising a chain of thoughts with the help of information retrieval significantly improves large language models' reasoning and generation ability in long-horizon generation tasks, while hugely mitigating hallucination. In particular, the proposed method — retrieval-augmented thoughts (RAT) — revises each thought step one by one with retrieved information relevant to the task query, the current and the past thought steps, after the initial zero-shot CoT is generated.

Prerequisites

  • Python packages can be installed with pip install -r requirements.txt

  • OpenAI_API_key is required for the language model. You can get it from OpenAI.

export OPENAI_API_KEY="sk-******"
  • You can also use the Huggingface API key for the language model. You can get it from Huggingface.

  • You also need to prepare the GOOGLE_API_KEY for Google Search API. You can get it from Google Cloud Platform.

export GOOGLE_API_KEY="********"

Getting Started

You can run the ipython notebook named creative.ipynb to generate open-ended creative text with RAT.

You can also use the following code to start a Gradio interface to interact with RAT:

python app/gradio_app.py

Experimental Results

Applying RAT to various base models substantially improves their performances on various long-horizon generation tasks; on average of relatively increasing rating scores by 13.63% on code generation, 16.96% on mathematical reasoning, 19.2% on creative writing, and 42.78% on embodied task planning.

Check out our paper!

Our paper is available on Arxiv. Please cite our paper if you find RAT useful for your research:

@article{wang2024rat,
    author    = {Zihao, Wang and Anji, Liu and Haowei, Lin and Jiaqi, Li and Xiaojian, Ma and Yitao, Liang},
    title     = {RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Horizon Generation},
    journal   = {arXiv preprint arXiv: 2403.05313},
    year      = {2024},
}

Core symbols most depended-on inside this repo

num_tokens_from_string
called by 4
app/gradio_app.py
run_with_timeout
called by 4
app/gradio_app.py
get_search
called by 1
app/gradio_app.py
get_page_content
called by 1
app/gradio_app.py
chunk_texts
called by 1
app/gradio_app.py
get_draft
called by 1
app/gradio_app.py
split_draft
called by 1
app/gradio_app.py
split_draft_openai
called by 1
app/gradio_app.py

Shape

Function 23

Languages

Python100%

Modules by API surface

app/gradio_app.py23 symbols

For agents

$ claude mcp add RAT \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact