liveBook · Manning

Ragas

As explained in Building Reliable AI Systems

RAGAS is an open-source framework for evaluating retrieval-augmented generation systems.

Ragas evaluates retrieval-augmented generation systems by applying selected metrics to a test dataset. A Python pipeline supplies an LLM, embeddings, and a column map connecting dataset fields to evaluation inputs. section 3.6.4

from datasets import load_dataset
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
from ragas import evaluate #1
from ragas.metrics import (
    answer_relevancy,
    faithfulness,
    context_recall,
    context_precision,
)

amnesty_qa = load_dataset("explodinggradients/amnesty_qa", "english_v2")
amnesty_qa

result = evaluate(
    amnesty_qa["eval"],
    metrics=[
        context_precision,
        faithfulness,
        answer_relevancy,
        context_recall,
    ],
    llm=ChatOpenAI(model="gpt-4o-mini"),
    embeddings=OpenAIEmbeddings(),
    column_map={"user_input": "question", "response": "answer",
               "retrieved_contexts": "contexts", "reference": "ground_truth"},
)

print(results)

The implementation loads an Amnesty QA dataset and evaluates context precision, faithfulness, answer relevancy, and context recall using GPT-4o-mini and OpenAI embeddings. section 3.6.4

How Building Reliable AI Systems covers it

How deep it goes
Demonstrates dataset loading and metric configuration, but does not explain metric internals.
Examples
Uses the Amnesty QA dataset with a column map, GPT-4o-mini, and OpenAI embeddings.
What you can do after
Apply Ragas to evaluate a dataset using selected metrics, an LLM, embeddings, and mapped fields.
How it connects
Connects RAG evaluation with context precision, faithfulness, answer relevancy, and context recall.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Reliable AI Systems. The section links point to the parts of the book it draws on.