Skip to content
/ T2RAG Public

Official code of paper "Beyond Chunks and Graphs: Retrieval-Augmented Generation through Triplet-Driven Thinking"

License

rockcor/T2RAG

Repository files navigation

T2RAG: Triplet-driven Thinking RAG

Retrieval-augmented generation (RAG) is critical for reducing hallucinations and incorporating external knowledge into Large Language Models (LLMs). However, advanced RAG systems face a trade-off between performance and efficiency. Multi-round RAG approaches achieve strong reasoning but incur excessive LLM calls and token costs, while Graph RAG methods suffer from computationally expensive, error-prone graph construction and retrieval redundancy. To address these challenges, we propose T2RAG, a novel framework that operates on a simple, graph-free knowledge base of atomic triplets. T2RAG leverages an LLM to decompose questions into searchable triplets with placeholders, which it then iteratively resolves by retrieving evidence from the triplet database. Empirical results show that T2RAG significantly outperforms state-of-the-art multi-round and Graph RAG methods, achieving an average performance gain of up to 11% across six datasets while reducing retrieval costs by up to 45%.

Environment Setup

Assuming you have an environment with torch>=2.0.

pip install -r requirements.txt

you may need manually download some packages based on your torch version.

API Initialization

export CUDA_VISIBLE_DEVICES=0 # or your preferred device number
export HF_HOME='~/.hf'  # or your preferred path
export OPENAI_API_KEY=<your openai api key>  
export GOOGLE_API_KEY=<your gemini api key>

Quick Start

python main.py --dataset 2wikimultihopqa --method trag

Supporting parameters

--dataset [popqa, 2wikimultihopqa, musique, hotpotqa, story, medical]
--method [trag, standard, hippo]

Results

Final and intermediate results are saved in outputs/<dataset>_<method>.

Updates

[2025.08] Support GPT-OSS

About

Official code of paper "Beyond Chunks and Graphs: Retrieval-Augmented Generation through Triplet-Driven Thinking"

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages