[논문 리뷰 - 2] Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks

shanny·2025년 3월 30일

논문 리뷰

목록 보기
3/42

‼️ 개인 학습 내용으로, 오류가 있을 수 있습니다.

논문 URL - https://arxiv.org/abs/2005.11401

Introduction

사전 학습 모델의 한계

  • Pre-trained neural language models have been shown to learn a substantial amount of in-depth knowledge from data.
    -> 사전 학습된 신경망 언어 모델은 상당한 양의 심도 깊은 지식을 학습할 수 있음을 보여줬다.

  • While this development is exciting, such models do have downsides: They cannot easily expand or revise their memory, can’t straightforwardly provide insight into their predictions, and may produce “hallucinations”.
    -> 그러나 이 모델은 단점이 있다. 1) 메모리 확장이나 수정이 어려움 2) 예측에 대한 직접적인 인사이트를 제공하기 어려움 3) 할루시네이션을 일으킴

대안 : 하이브리드 모델

  • Hybrid models that combine parametric memory with non-parametric (i.e., retrieval-based) memories can address some of these issues because knowledge can be directly revised and expanded, and accessed knowledge can be inspected and interpreted.
    -> 하이브리드 모델(매개변수적 + 비매개변수적 메모리가 결합)은 사전 학습된 모델의 문제를 일부 해결할 수 있다. (대표 예시 모델 : REALM, ORQA)

  • but have only explored open-domain extractive question answering. Here, we bring hybrid parametric and non-parametric memory to the “workhorse of NLP,” i.e. sequence-to-sequence (seq2seq) models.
    -> 그러나 오픈 도메인 추출* 질의 응답만 탐구해왔기 때문에, NLP의 '주력 모델'인 시퀀스-투-시퀀스(seq2seq) 모델에 하이브리드 파라메트릭 메모리와 논-파라메트릭 메모리를 결합한 모델을 소개한다.

    * 오픈 도메인 (Open-domain): 특정 주제에 제한되지 않고 광범위한 분야(예: 역사, 과학, 문화 등)에서 답변을 찾는 시스템.

RAG 모델 원리

개념

  • We endow pre-trained, parametric-memory generation models with a non-parametric memory through a general-purpose fine-tuning approach which we refer to as retrieval-augmented generation (RAG).
    -> 사전 학습된 매개변수적 메모리(저장된 지식) 생성 모델에 검색 증강 생성(RAG)이라 부르는 범용적 미세 조정 기법을 통해 비매개변수적 메모리(실시간 검색)를 추가한다.

방식

  • We build RAG models where the parametric memory is a pre-trained seq2seq transformer, and the non-parametric memory is a dense vector index of Wikipedia, accessed with a pre-trained neural retriever. We combine these components in a probabilistic model trained end-to-end (Fig. 1).
    -> 매개변수적 메모리는 사전 학습된 seq2seq transformer를 사용하고, 비매개변수적 메모리는 위키피디아 dense vector index(사전 학습된 신경망 검색기로 접근)를 사용하는 RAG 모델을 구축한다. 이 두 요소를 엔드투엔드(입력부터 출력까지 단일 통합 모델) 학습된 확률적 모델로 통합한다.

Figure 01 설명

  • The retriever (Dense Passage Retriever, henceforth DPR) provides latent documents conditioned on the input, and the seq2seq model (BART) then conditions on these latent documents together with the input to generate the output.
    -> 검색기는 입력 기반 잠재 문서를 생성하며, seq2seq(BART) 모델은 문서와 입력 내용을 함께 활용하여 최종 출력을 생성한다.

  • We marginalize the latent documents with a top-K approximation, either on a per-output basis (assuming the same document is responsible for all tokens) or a per-token basis (where different documents are responsible for different tokens). Like T5 or BART, RAG can be fine-tuned on any seq2seq task, whereby both the generator and retriever are jointly learned.
    -> 상위 연관 k개의 잠재 문서를 2가지 방식*으로 주변화(적분)한다. T5, BART처럼 RAG도 어떠한 seq2seq 작업에 대해 파인튜닝 될 수 있기 때문에 생성기와 검색기가 함께 학습된다.

    * 방식 2가지 
    1) 출력 단위(per-output basis): 하나의 문서가 전체 토큰 생성에 관여 (예: RAG-Sequence)
    2) 토큰 단위(per-token basis): 각 토큰마다 다른 문서가 관여 (예: RAG-Token).

+) Marginalization 수식('Perplexity' 참고)

1. 수식 구조 분석

p(yx)ztop-Kp(zx)검색 확률p(yx,z)생성 확률p(y|x) \approx \sum_{z \in \text{top-K}} \underbrace{p(z|x)}_{\text{검색 확률}} \cdot \underbrace{p(y|x,z)}_{\text{생성 확률}}

1) p(z|x) (검색 단계):

  • 입력 x (예: 질문)가 주어졌을 때 문서 z가 검색될 확률.
  • DPR(Dense Passage Retriever)이 계산하며, 문서 z와 질문 $$ x $$의 벡터 유사도(내적)로 측정.
  • 예시: "월드컵 우승 팀은?" → z="브라질 5회 우승" 문서의 검색 확률.

2) p(y|x,z) (생성 단계):

  • 검색된 문서 z와 입력 x를 조건으로 출력 y(예: 답변)가 생성될 확률.
  • BART/T5 같은 seq2seq 모델이 수행.
  • 예시: z="브라질 5회" 문서를 참조해 "가장 많이 우승한 팀은 브라질입니다" 생성.

3) Top-K 근사:

  • 모든 가능한 문서 대신 유사도 상위 K개 문서만 사용해 계산 효율화.
  • K=5라면, 가장 관련성 높은 5개 문서만 고려.

2. 수식의 물리적 의미

  • 주변화(Marginalization): 검색된 모든 문서(K개)에 대해 생성 확률의 가중평균을 계산.
    • 가중치: 각 문서의 검색 확률 p(z|x).
    • 목적: 단일 문서에 의존할 때의 편향을 줄이고, 다중 문서 정보를 통합.

3. 실제 시스템 동작 예시

  1. 검색 단계:
    • 질문 x = "팥빙수 유래?" → DPR이 위키백과에서 상위 3개 문서 검색 (z_1, z_2, z_3 ).
  2. 생성 단계:
    • 각 문서별 생성 확률 계산:
      • z_1: "한국 전통 디저트" → p(y|x,z_1) = 0.6
      • z_2: "일본 영향설" → p(y|x,z_2) = 0.3
      • z_3: "1940년대 기록" → p(y|x,z_3) = 0.1
    • 최종 출력 y : 0.6 ⋅ {한국} + 0.3 ⋅ {"일본 영향"} + 0.1 ⋅ {"1940년대"}

4. 기술적 의의

  • 신뢰성 향상: 외부 지식(위키백과 등)을 참조해 환각(hallucination) 감소.
  • 동적 지식 통합: 모델 재학습 없이 문서 DB 갱신만으로 최신 정보 반영 가능.

메모리 증강 시스템 비교 분석: 사전 학습 vs. 작업 특화 접근법

  • There has been extensive previous work proposing architectures to enrich systems with non-parametric memory which are trained from scratch for specific tasks, e.g. memory networks, stackaugmented networks and memory layers. In contrast, we explore a setting where both parametric and non-parametric memory components are pre-trained and pre-loaded with extensive knowledge. Crucially, by using pre-trained access mechanisms, the ability to access knowledge is
    present without additional training.
    -> 기존 방식 vs. 본 연구 방식

    특성기존 작업 특화 시스템본 연구 방식
    메모리 유형비매개변수적 메모리 전용매개변수적+비매개변수적 혼합
    학습 방식작업별 처음부터 학습사전 학습된 메모리 구성요소 활용
    지식 로딩작업 수행 시점에 초기화방대한 사전 지식 구축 상태로 사전 로드
    지식 접근추가 학습 필요사전 학습된 접근 메커니즘이 즉시 활용 가능

연구 성과

1. 매개변수적-비매개변수적 메모리 통합의 혁신성

  • Our results highlight the benefits of combining parametric and non-parametric memory with generation for knowledge-intensive tasks—tasks that humans could not reasonably be expected to perform without access to an external knowledge source.
    -> 인간 수준의 지식 집약적 작업(예: 전문가 수준 QA) 수행 가능성 입증

2. 성능

  • Our RAG models achieve state-of-the-art results on open Natural Questions, WebQuestions and CuratedTrec and strongly outperform recent approaches that use specialised pre-training objectives on TriviaQA. Despite these being extractive tasks, we find that unconstrained generation outperforms previous extractive approaches.

    평가 지표주요 성과
    정확도Natural Questions, WebQuestions, CuratedTrec에서 SOTA 달성
    방법론 비교TriviaQA 대상 특화 사전학습 모델을 큰 차이로 제치고 우수성 입증
    생성 방식추출적 접근보다 자유형식 생성이 더 높은 성능 보임
  • For knowledge-intensive generation, we experiment with MS-MARCO and Jeopardy question generation, and we find that our models generate responses that are more factual, specific, and diverse than a BART baseline. For FEVER fact verification, we achieve results within 4.3% of state-of-the-art pipeline models which use strong retrieval supervision. Finally, we demonstrate that
    the non-parametric memory can be replaced to update the models’ knowledge as the world changes.
    -> MS-MARCO, Jeopardy 질문 생성 실험 결과, BART 모델보다 사실적이고, 구체적이며, 다양한 응답을 생성하는 성과를 거두었다.
    모델의 비매개변수적 메모리(외부 지식 저장소)를 교체함으로써, 변화에 따른 지식 업데이트가 가능함을 실험적으로 입증하였다.

Conclusion

⚠️Discussion으로 대체

  • In this work, we presented hybrid generation models with access to parametric and non-parametric memory. We showed that our RAG models obtain state of the art results on open-domain QA. We found that people prefer RAG’s generation over purely parametric BART, finding RAG more factual and specific.
    -> 매개변수적 메모리(사전학습 모델)와 비매개변수적 메모리(외부 지식 검색)를 결합한 RAG 아키텍처를 제시했다. (SOTA 성능 입증)

  • We conducted an thorough investigation of the learned retrieval component, validating its effectiveness, and we illustrated how the retrieval index can be hot-swapped to update the model without requiring any retraining.
    -> 학습된 검색(retrieval) 구성 요소에 대한 효과성을 입증했으며, 재학습 없이도 검색 인덱스를 핫스왑(실시간 교체)하여 모델을 업데이트할 수 있는 방법을 구체적으로 보였다.

  • In future work, it may be fruitful to investigate if the two components can be jointly pre-trained from scratch, either with a denoising objective similar to BART or some another objective. Our work opens up new research directions on how parametric and non-parametric memories interact and how to most effectively combine them, showing promise in being applied to a wide variety of NLP tasks.
    -> 향후 연구에서는 BART의 노이즈 제거 목표(denoising objective) 또는 다른 목표 함수를 활용해 두 구성 요소(매개변수적 메모리/비매개변수적 메모리)를 처음부터 공동 사전 학습(jointly pre-trained)할 수 있는지 탐구하는 것이 유의미할 것이다.
    본 연구는 매개변수적 메모리와 비매개변수적 메모리의 상호작용 방식과 이를 최적으로 결합하는 방법에 대한 새로운 연구 방향을 제시하며, 다양한 NLP 과제에 적용할 수 있는 가능성을 입증했다.

Figures

01. 접근 방식 개요

  • 검색기(Retriever) -> 비매개변수적(외부 문서 인덱스를 검색하여 정보 탐색)
    • 입력(x)에 대해 가장 관련성이 높은 상위 K개의 문서 탐색(MIPS)
  • 생성기(Generator) -> 매개변수적(검색된 문서에 기반하여 최종 출력 생성)
    • seq2seq(BART) 모델은 문서와 입력 내용을 함께 활용하여 최종 출력을 생성한다.
    • 상위 연관 k개의 잠재 문서를 주변화(적분)한다.
구분검색기 (Retriever)생성기 (Generator)
모델 유형비파라메트릭 (Non-Parametric)파라메트릭 (Parametric)
학습 방식문서 인덱스를 활용하여 검색훈련된 뉴럴 네트워크를 기반으로 생성
정보 출처외부 문서 데이터베이스 (검색 기반)내부 학습된 가중치 (딥러닝 모델)
변경 가능성문서 인덱스가 변경되면 즉시 업데이트 가능학습된 파라미터를 변경해야 함

02. RAG-Token 모델의 문서 사후 확률 활용 방식

  • p(zi|x, yi, y-i) : x, yi, y-i가 주어졌을 때 zi가 발생할 확률
    • y-i는 i를 제외한 나머지 토큰

03. 모델 성능 비교

  • (left)

    • RAG-Seq 모델은 문서 개수가 증가할 수록 QA 정확도 지속 상승
    • RAG-Tok 모델은 문서 10개에서 가장 높은 최적점 성능을 보임
  • (center)

    • RAG 모델이 다른 모델에 배해 재현율 성과가 높음
  • (right)

    • RAG-Token은 더 많은 문서를 검색할수록 문장 완성도(Rouge-L)는 높아지지만, 정확도(Bleu-1)는 떨어지는 "Trade-off" 관계를 가짐.

      모델 유형Rouge-L (응답 포괄성)Bleu-1 (표현 정확성)
      RAG-Token문서 수 ↑ → 증가문서 수 ↑ → 감소
      RAG-Sequence변동 미미안정적 유지

profile
데이터 분석가

0개의 댓글