Lighter And Better: Towards Flexible Context Adaptation For Retrieval Augmented Generation

Zheng Liu, Chenyuan Wu, Ninglu Shao, Shitao Xiao, Chaozhuo Li +1 more
9/24/2024
cs.CL

No official code found. Best implementation: wcyno23/FlexRAG (10 stars, Apache-2.0, last commit 2026-02-06).

Abstract

The existing Retrieval-Augmented Generation (RAG) systems face significant challenges in terms of cost and effectiveness. On one hand, they need to encode the lengthy retrieved contexts before responding to the input tasks, which imposes substantial computational overhead. On the other hand, directly using generic Large Language Models (LLMs) often leads to sub-optimal answers, while task-specific fine-tuning may compromise the LLMs' general capabilities. To address these challenges, we introduce a novel approach called FlexRAG (Flexible Context Adaptation for RAG). In this approach, the retrieved contexts are compressed into compact embeddings before being encoded by the LLMs. Simultaneously, these compressed embeddings are optimized to enhance downstream RAG performance. A key feature of FlexRAG is its flexibility, which enables effective support for diverse compression ratios and selective preservation of important contexts. Thanks to these technical designs, FlexRAG achieves superior generation quality while significantly reducing running costs. Comprehensive experiments on various question-answering datasets validate our approach as a cost-effective and flexible solution for RAG systems.

View on arXivView PDF

Code Implementations(1)

wcyno23/FlexRAGCommunity71%
Apache-2.0

Lighter And Better: Towards Flexible Context Adaptation For Retrieval Augmented Generation (WSDM 2025 Oral)

101Shell, PythonNov 18, 20248 months agoApache-2.0

Similar Papers

Cite this paper

@article{liu2024lighter,
  title  = {Lighter And Better: Towards Flexible Context Adaptation For Retrieval Augmented Generation},
  author = {Zheng Liu and Chenyuan Wu and Ninglu Shao and Shitao Xiao and Chaozhuo Li and Defu Lian},
  year   = {2024},
  eprint = {2409.15699},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2409.15699v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2409.15699.svg)](https://codeofpaper.com/paper/2409.15699)

Discussion