RAGAS tutorial: evaluate RAG answers in Python

Learn four RAGAS evaluation metrics through five Python examples, using AsyncOpenAI, embeddings and reference answers to inspect RAG responses.

Player not loading? Watch on YouTube

This English summary uses the supplied English captions for Yash Jain’s tutorial. This tutorial walks through RAGAS evaluation in Python using manually prepared samples rather than a working retrieval pipeline. Each sample contains a question, retrieved context, a response and a reference answer. The code uses AsyncOpenAI, an LLM factory and OpenAI embeddings to score the examples. This demonstration relies on OpenAI calls; it does not show how to run models locally.

The walkthrough covers faithfulness, context recall, factual correctness and answer relevancy. Five examples separate different failures: an answer adds a population claim absent from its context, retrieval misses part of an Einstein reference answer, a telephone invention date conflicts with the supplied reference, and a Python programming question receives an answer about a snake. A final machine learning example supplies consistent context, response and reference text.

The speaker then initializes the metrics, runs an asynchronous evaluation loop and interprets the scores. In the demonstrated results, the machine learning sample scores 1 for faithfulness, context recall and factual correctness, while answer relevancy is about 90%.

The closing discussion describes offline evaluation as testing prepared data with expected answers, rather than operation without internet access. The speaker contrasts this workflow with TruLens for live production queries. These comments are the presenter’s interpretation, rather than verified restrictions on either framework; no package version is named.