Skip to main content
QUICK REVIEW

[논문 리뷰] Accelerating Inference of Retrieval-Augmented Generation via Sparse Context Selection

Yun Zhu, Jia-Chen Gu|arXiv (Cornell University)|2024. 05. 25.
Domain Adaptation and Few-Shot LearningComputer Science인용 수 3
한 줄 요약

이 논문은 추론 중에 디코딩 동안 유의미한 문서만 선택적으로 참조함으로써 검색 증강 생성을 가속화하는 Sparse RAG를 제안한다. LLM을 사용해 제어 토큰을 통해 문서의 관련성을 평가하고 높은 품질의 키-밸류 캐시만 로드함으로써, 성능을 훼손하지 않은 채 지연 시간을 줄이고 생성 품질을 향상시킨다. 이로써 짧고 긴 형식의 작업 전반에서 최신 기술 수준의 효율성과 효과성을 달성한다.

ABSTRACT

Large language models (LLMs) augmented with retrieval exhibit robust performance and extensive versatility by incorporating external contexts. However, the input length grows linearly in the number of retrieved documents, causing a dramatic increase in latency. In this paper, we propose a novel paradigm named Sparse RAG, which seeks to cut computation costs through sparsity. Specifically, Sparse RAG encodes retrieved documents in parallel, which eliminates latency introduced by long-range attention of retrieved documents. Then, LLMs selectively decode the output by only attending to highly relevant caches auto-regressively, which are chosen via prompting LLMs with special control tokens. It is notable that Sparse RAG combines the assessment of each individual document and the generation of the response into a single process. The designed sparse mechanism in a RAG system can facilitate the reduction of the number of documents loaded during decoding for accelerating the inference of the RAG system. Additionally, filtering out undesirable contexts enhances the model's focus on relevant context, inherently improving its generation quality. Evaluation results of two datasets show that Sparse RAG can strike an optimal balance between generation quality and computational efficiency, demonstrating its generalizability across both short- and long-form generation tasks.

연구 동기 및 목표

  • 다수의 검색된 문서에서 유래한 긴 입력 시퀀스로 인해 검색 증강 생성(RAG)에서 발생하는 높은 추론 지연을 해결하기 위해.
  • 짧고 긴 형식의 생성 작업 모두에서 생성 품질을 떨어뜨리지 않고 계산 효율성을 향상시키기 위해.
  • 외부 분류기나 별도의 검색 순위 모델이 필요 없도록, 컨텍스트 평가와 생성을 하나의 통합된 과정으로 통합하기 위해.
  • 디코딩 중 키-밸류 캐시 로딩을 줄임으로써 자원 제약이 있는 장치에서 효율적이고 저지연 추론을 가능하게 하기 위해.

제안 방법

  • Sparse RAG는 두 단계 과정을 사용한다: 모든 검색된 문서를 동시에 인코딩하여 전체 키-밸류 캐시를 생성하는 대량 프리필링 단계와, 관련성이 있는 문서들만 참조하는 선택적 디코딩 단계.
  • 특수 제어 토큰을 사용해 LLM이 각 검색된 문서의 관련성을 평가하고 디코딩 단계에 포함할지 여부를 결정하도록 유도한다.
  • 모델은 디코딩 중에 저품질이거나 관련성이 없는 문서를 동적으로 제거함으로써 키-밸류 캐시 로드 수를 줄이고 메모리 및 계산 오버헤드를 낮춘다.
  • 문서 관련성 평가와 응답 생성을 하나의 순차적 생성 과정에 통합함으로써 별도의 순위 모델이 필요 없도록 한다.
  • 기존의 디코더 전용 LLM 아키텍처를 그대로 활용하므로 현대 LLM과의 호환성을 유지하며 아키텍처 수정 없이 적용 가능하다.
  • 기초 모델 크기에 관계없이 적용 가능하도록 설계되어, 소형 모델(예: Gemini XS)과 대형 모델(예: Gemini XXS) 모두를 지원한다.
Figure 1 : An overview of Sparse RAG at inference. Each of the retrieved documents will be assessed by LLMs to decide whether to keep or drop by estimating a relevance score. Then, load the documents that are considered to keep for generation.
Figure 1 : An overview of Sparse RAG at inference. Each of the retrieved documents will be assessed by LLMs to decide whether to keep or drop by estimating a relevance score. Then, load the documents that are considered to keep for generation.

실험 결과

연구 질문

  • RQ1RAG에서 희소 어텐션 메커니즘이 디코딩 지연을 줄이면서도 생성 품질을 유지하거나 향상시킬 수 있는가?
  • RQ2관련성 평가와 생성을 하나의 과정에 통합함으로써 추론 효율성과 출력 품질에 어떤 영향을 미치는가?
  • RQ3다양한 모델 크기에서 성능 저하 없이 Sparse RAG가 키-밸류 캐시 로딩을 얼마나 줄일 수 있는가?
  • RQ4각 컨텍스트별 정답 관련성 레이블이 제공될 경우, Sparse RAG의 최고 성능 상한선은 어느 정도인가?
  • RQ5다양한 생성 작업에서 Sparse RAG는 밀도 있는 RAG와 PCW-RAG에 비해 지연 시간과 생성 품질 측면에서 어떻게 비교되는가?

주요 결과

  • 다양한 길이의 응답을 생성할 때, 기준 밀도 RAG 대비 Sparse RAG는 종단 간 지연 시간을 52%에서 55% 이상 감소시켰다.
  • PopQA 데이터셋에서, Gemini XS 모델을 사용해 Sparse RAG는 6.27회의 키-밸류 캐시 로드로 68.26 EM과 72.26 F1을 기록했으며, 품질과 효율성 모두에서 RAG와 PCW-RAG를 능가했다.
  • Biography 데이터셋에서, Gemini XXS 모델을 사용해 Sparse RAG는 67.17 EM과 71.16 F1을 기록했으며, 다양한 모델 크기에서 일관된 성능 향상을 보였다.
  • 황금 표준 컨텍스트별 레이블이 제공된 경우, Sparse RAG는 26.76 F1과 21.16 DS로 향상되었으며, 이상적인 평가 조건에서 강력한 잠재력을 보였다.
  • 계산 오버헤드를 크게 줄였으며, 특히 더 큰 컨텍스트 창을 사용할 경우 토큰당 초(second) 성능(t/s)이 밀도 RAG 대비 크게 향상되었다.
  • 짧고 긴 형식의 생성 작업 전반에서 높은 성능을 유지하여 일반화 능력을 입증했다.
(a) Decoding speed with different number of memories
(a) Decoding speed with different number of memories

이 논문 읽기

누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.

누빈트에서 이 논문 읽기

이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.