Sitemap

RAG-Evaluation

Jun 20, 2024

LLM selection

to align with the SFT model, now using microsoft/Phi-3-mini-4k-instruct

RAG triad

context relevance, groundness, answer relevance.

Press enter or click to view image in full size

Satisfactory evaluation on each provide us confidence that the APP is free from hallucination.

Get Yufei’s stories in your inbox

Join Medium for free to get updates from this writer.

Data format for eval

The data format is expected to be the following:

Press enter or click to view image in full size

Download file from google drive

gdown "https://drive.google.com/uc?id={file_id}" -O {save_name}.csv

to get file_id, click “share” -> “copy link”

Get RAG outputs, prepare data for eval

Eval with Ragas

from ragas.metrics import (
answer_relevancy,
faithfulness,
context_recall,
context_precision,
)

from ragas import evaluate
from datasets import load_dataset

# loading the V2 dataset
amnesty_qa = load_dataset("explodinggradients/amnesty_qa", "english_v2")
amnesty_qa

result = evaluate(
amnesty_qa["eval"],
metrics=[
context_precision,
faithfulness,
answer_relevancy,
context_recall,
],
)

need to get an OpenAI token or replace own model to use ragas…

--

--

Yufei
Yufei

Written by Yufei

A student, dreaming being en engineer.