TeaRAG
The source code for a paper on a token-efficient, agentic retrieval-augmented generation framework that compresses both retrieved content and reasoning steps to answer complex queries with fewer tokens and faster reasoning.
TeaRAG is built on the FlashRAG framework and adds graph-based knowledge retrieval along with a technique the paper calls Iterative Process-aware DPO, aimed at achieving better answers with lower cost in agentic retrieval-augmented generation. The paper, accepted by ACM Transactions on Information Systems, reports exact-match gains of about 4 and 2 percentage points on Llama3-8B-Instruct and Qwen2.5-14B-Instruct respectively, while cutting token usage by roughly 60 percent compared to prior baselines.
The repository includes scripts to prepare data and build a knowledge graph and index, separate training and evaluation pipelines for the two supported base models, and an inference script covering all included datasets, models and baselines; models and the Wikipedia-corpus-based knowledge graph used for training are published on Hugging Face.
It is written in Python and released under the MIT license.