Command Palette

Search for a command to run...

Назад к скиллам
скилл № 52455

RAG Evaluation

Comprehensive guide to evaluating Retrieval-Augmented Generation systems including retrieval metrics, generation quality, faithfulness, and end-to-end…

БесплатноБез исполняемых скриптов
majiayu000от majiayu000★ 31 звезда на GitHub

Установить RAG Evaluation в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

RAG Evaluation

What is RAG Evaluation?

Definition: Measuring quality of both retrieval and generation components in RAG systems.

Components

RAG System = Retrieval + Generation

Retrieval: Query → Relevant documents
Generation: Documents + Query → Answer

Both need evaluation!

Evaluation Levels

1. Component-level: Retrieval quality, generation quality
2. End-to-end: Overall answer quality
3. User-level: User satisfaction, task success

Why RAG Evaluation Matters

RAG Quality Varies Widely

Example:

Query: "What is the capital of France?"

Bad RAG:
- Retrieves: Document about French cuisine
- Generates: "France is known for its wine" (irrelevant)

Good RAG:
- Retrieves: Document about Paris
- Generates: "The capital of France is Paris" (correct)

Retrieval Errors → Wrong Context → Bad Answers

Error Cascade:

Poor retrieval (irrelevant docs)
→ Wrong context for LLM
→ LLM generates answer from wrong info
→ Hallucination or incorrect answer

Need Metrics to Improve Systematically

Without Metrics:

"This answer seems wrong" → Unclear what to fix

With Metrics:

Context Precision: 0.3 (low) → Improve retrieval
Faithfulness: 0.6 (low) → Improve prompt to reduce hallucination

RAG Components to Evaluate

1. Retrieval: Are Relevant Docs Retrieved?

Metrics:

  • Precision@k
  • Recall@k
  • MRR (Mean Reciprocal Rank)
  • NDCG

2. Context: Is Context Sufficient for Answer?

Metrics:

  • Context relevance
  • Context precision
  • Context recall

3. Generation: Is Answer Correct, Relevant, Safe?

Metrics:

  • Faithfulness (no hallucination)
  • Answer relevance
  • Correctness
  • Completeness
  • Safety

Retrieval Evaluation Metrics

Precision@k: % of Top-k Results Relevant

Formula:

Precision@k = (# relevant docs in top-k) / k

Example:

Query: "Python list methods"
Top 5 results:
1. Python list.append() ✓ (relevant)
2. Python list.extend() ✓ (relevant)
3. Java ArrayList ✗ (not relevant)
4. Python list.pop() ✓ (relevant)
5. Python dictionaries ✗ (not relevant)

Precision@5 = 3/5 = 0.6

Recall@k: % of Relevant Docs in Top-k

Formula:

Recall@k = (# relevant docs in top-k) / (total # relevant docs)

Example:

Total relevant docs: 10
Relevant docs in top-5: 3

Recall@5 = 3/10 = 0.3

MRR (Mean Reciprocal Rank): Position of First Relevant Doc

Formula:

RR = 1 / (rank of first relevant doc)
MRR = average RR across queries

Example:

Query 1: First relevant at position 1 → RR = 1/1 = 1.0
Query 2: First relevant at position 3 → RR = 1/3 = 0.33
Query 3: First relevant at position 2 → RR = 1/2 = 0.5

MRR = (1.0 + 0.33 + 0.5) / 3 = 0.61

NDCG (Normalized Discounted Cumulative Gain)

Purpose: Considers both relevance and position

Formula:

DCG@k = Σ (relevance_i / log2(i+1))
NDCG@k = DCG@k / IDCG@k (normalized)

Example:

Top 3 results with relevance scores (0-3):
Position 1: relevance = 3
Position 2: relevance = 2
Position 3: relevance = 1

DCG@3 = 3/log2(2) + 2/log2(3) + 1/log2(4)
      = 3/1 + 2/1.58 + 1/2
      = 3 + 1.26 + 0.5 = 4.76

Context Relevance Score

LLM-as-Judge:

def evaluate_context_relevance(query, context):
    prompt = f"""
    Query: {query}
    Context: {context}
    
    Rate the relevance of the context to the query on a scale of 1-5:
    1 = Not relevant at all
    5 = Highly relevant
    
    Score:
    """
    
    score = llm.generate(prompt)
    return int(score)

Generation Evaluation Metrics

Faithfulness: Answer Grounded in Context (No Hallucination)

Definition: All claims in answer are supported by context

Example:

Context: "Paris is the capital of France. It has a population of 2.1 million."
Question: "What is the capital of France?"

Faithful answer: "Paris is the capital of France."
Unfaithful answer: "Paris is the capital of France with 10 million people." (hallucination)

Answer Relevance: Answer Addresses the Question

Definition: Answer is on-topic and addresses what was asked

Example:

Question: "What is the capital of France?"

Relevant answer: "The capital of France is Paris."
Irrelevant answer: "France is a country in Europe." (true but doesn't answer)

Correctness: Answer is Factually Correct

Definition: Answer matches ground truth

Example:

Question: "What is 2+2?"
Ground truth: "4"

Correct answer: "4"
Incorrect answer: "5"

Completeness: Answer Covers All Aspects

Definition: Answer addresses all parts of question

Example:

Question: "What are the capital and population of France?"

Complete answer: "The capital of France is Paris, with a population of about 67 million."
Incomplete answer: "The capital is Paris." (missing population)

Faithfulness Evaluation

Method 1: LLM-as-Judge (Does Answer Match Context?)

Prompt:

d
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • metadata.json

FAQ

Что делает скилл RAG Evaluation?

Comprehensive guide to evaluating Retrieval-Augmented Generation systems including retrieval metrics, generation quality, faithfulness, and end-to-end evaluation frameworks

Как установить скилл RAG Evaluation?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл RAG Evaluation запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить RAG Evaluation с