본문 바로가기
NLP/NLP - Data & Eval

RAGAS (2023) 논문 리뷰

by 아르카눔 2025. 4. 17.

RAGAS는 RAGAS: Automated Evaluation of Retrieval Augmented Generation에서 제시된 RAG의 평가 방법이다. (링크)

 

저자는 Shahul Es, Jithin James, Luis Espinosa-Anke, Steven Schockaert다. 

 

Github: 링크

Documentation: 링크 

 

LLM as a Judge의 개념으로 RAG 결과를 평가한다.

 

Abstract

RAGAS (Retrieval Augmented Generation Assessment)는 레퍼런스가 없이도 RAG를 평가 가능한 파이프라인이다.

RAG는 retrieval 검색기와 LLM 기반의 생성 모듈로 나뉘는데, 검색기는 LLM에 reference 텍스트 데이터베이스로부터 정보를 주어서 hallucination 환각의 위험성을 줄이는 작업을 수행한다. 하지만 RAG의 평가는 어려웠는데, 기존에는 검색된 context passages 문맥의 relevancy 관련성을 평가하거나, 문맥에만 초점을 맞춰서 LLM이 문맥을 faithful way 충실히 따랐는지 그리고 생성 자체만 평가했기 때문이다. 하지만 RAGAS에서는 ground truth human annotations 없이 평가하는 방법을 소개한다.

 

3. Evaluation Strategies

RAGAS은 핵심적인 세 가지의 퀄리티 평가 지표를 내세운다.

Faithfulness, Answer Relevance, 그리고 Context Relevance다.

 

질문을 $q$, 이에 대한 검색된 문맥을 $c(q)$, 이를 이용한 답변을 $a_s(q)$라고 표기한다.

 

 

Faithfulness

 

Answer 답변은 주어진 문맥에 grounded 기반해야한다. 

 

답변 $a_s(q)$가 $c(q)$에서 inferred 추론된 내용을 기반으로 claim 주장을 한다면  $a_s(q)$는 $c(q)$에 faithful하다고 한다.

 

저자들은 다음의 프롬프트를 이용해서 긴 문장을 쪼개서 statement 서술의 집합 $S(a_s(q))$을 만든다.

 

"Given a question and answer, create one or more statements from each sentence in the given answer.
question: [question] answer: [answer]"

 

그 다음 개별 서술 $s_i \in S$에 대해 개별 $s_i$가 $c(q)$에서 추론된건지 아닌지 판단한다.

이때 verification function 검증 함수 $v(s_i, c(q))$를 사용한다.

 

검증에는 다음의 프롬프트를 이용한다.

 

"Consider the given context and following statements, then determine whether they are supported by the information present in the context. Provide a brief explanation for each statement before arriving at the verdict (Yes/No). Provide a final verdict for each statement in order at the end in the given format. Do not deviate from the specified format.
statement: [statement 1]
...
statement: [statement n]"

 

최종 faithfulness score $F$는 다음과 같이 정의된다.

 

$F = |V| / |S|$고 $|V|$는 faithful한 statements의 개수다.  

 

 

Answer Relevance

 

$a_s(q)$가 질문에 대해서 직접적으로 address 다룬다면 답변 $a_s(q)$를 relevant라고 한다.

 

구체적으로는 factuality 사실에 입각함을 평가하는데 아니라 답변이 incomplete and redundant불완전하거나 쓸모없는 

정보를 담고있으면 이에 대해 패널티를 주는 방식이다.

 

다음의 프롬프트를 통해서 주어진 답변 $a_s(q)$을 기반으로 잠재적인 $n$개의 질문 $q_i$를 생성하고 이를 통해 평가한다.

 

"Generate a question for the given answer.
answer: [answer]"

 

모든 질문에 대한 임베딩은 OpenAI의 API를 통해 text-embedding-ada-002 model 을 활용해서 생성한다.

 

원본 질문 $q$와 생성된 질문 $q_i$의 코사인 유사도 sim$(q, q_i)$를 활용해서 Answer relevance를 측정한다.

 

 

AR = $ \frac{1}{n} \sum_i^n \text{sim} (q, q_i) $

 

 

Context Relevance

 

문맥 $c(q)$가 답변에 필요한 정보를 담고있는지를 평가한다.

쓸모없는 정보를 담고 있으면 이에 대해 패널티를 가하기 위한 목적이다.

 

주어진 질문 $q$와 문맥 $c(q)$를 이용해서 LLM이 $c(q)$로 부터 질문 $q$에 중요하다고 생각하는 문장들을 추출하고 이를 $S_ext$이라고 표기한다.

 

아래의 프롬프트를 사용한다.

 

"Please extract relevant sentences from the provided context that can potentially help answer the following question. If no relevant sentences are found, or if you believe the question cannot be answered from the given context, return the phrase "Insufficient Information". While extracting candidate sentences you’re not allowed to make any changes to sentences from given context."

 

Context relevance 점수는 아래의 식으로 계산한다. 

 

CR = 추출된 문장의 수 / $c(q)$에 있는 총 문장의 수 

 

 

Experiments

 

WikiEval 데이터에 대한 실험 결과는 다음과 같다.

 

 

 

ChatGPT와 비교한 결과다.

 

 

 

 

 

 

References:

https://docs.ragas.io/en/stable/

https://wikidocs.net/259205

https://devocean.sk.com/community/detail.do?ID=166209&boardType=DEVOCEAN_STUDY&page=1

 

 

'NLP > NLP - Data & Eval' 카테고리의 다른 글

LLM as a Judge (2023) 논문 리뷰  (1) 2025.04.17
Pre-train 데이터 정리  (0) 2025.04.11
GLUE, SuperGLUE, KLUE, Huggingface LB  (0) 2024.03.04