Don't Do RAG: When Cache-Augmented Generation is All You Need for Knowledge Tasks

Brian J Chan, Chao-Ting Chen, Jui-Hung Cheng, Hen-Hsen Huang
12/20/2024
cs.CL

No official code found. Best implementation: hhhuang/CAG (1,502 stars, MIT, last commit 2025-05-26).

Abstract

Retrieval-augmented generation (RAG) has gained traction as a powerful approach for enhancing language models by integrating external knowledge sources. However, RAG introduces challenges such as retrieval latency, potential errors in document selection, and increased system complexity. With the advent of large language models (LLMs) featuring significantly extended context windows, this paper proposes an alternative paradigm, cache-augmented generation (CAG) that bypasses real-time retrieval. Our method involves preloading all relevant resources, especially when the documents or knowledge for retrieval are of a limited and manageable size, into the LLM's extended context and caching its runtime parameters. During inference, the model utilizes these preloaded parameters to answer queries without additional retrieval steps. Comparative analyses reveal that CAG eliminates retrieval latency and minimizes retrieval errors while maintaining context relevance. Performance evaluations across multiple benchmarks highlight scenarios where long-context LLMs either outperform or complement traditional RAG pipelines. These findings suggest that, for certain applications, particularly those with a constrained knowledge base, CAG provide a streamlined and efficient alternative to RAG, achieving comparable or superior results with reduced complexity.

View on arXivView PDF

Code Implementations(1)

hhhuang/CAGCommunity100%
MIT

Cache-Augmented Generation: A Simple, Efficient Alternative to RAG

1,502220Shell, PythonDec 11, 20241 years agoMIT
cagllmrag

Similar Papers

Cite this paper

@article{chan2024dont,
  title  = {Don't Do RAG: When Cache-Augmented Generation is All You Need for Knowledge Tasks},
  author = {Brian J Chan and Chao-Ting Chen and Jui-Hung Cheng and Hen-Hsen Huang},
  year   = {2024},
  eprint = {2412.15605},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2412.15605v2}
}

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/2412.15605.svg)](https://codeofpaper.com/paper/2412.15605)

Discussion