LLMOps · Module 01
Evaluation Toolkit - Ragas
Measure a RAG system instead of guessing: the Ragas metrics for retrieval and generation, the Python API, LLM-as-judge and its biases, and offline against online evaluation.
Học xong bạn làm được
- Compute faithfulness and answer relevancy
- Compute context precision and context recall
- Run an evaluation with the Ragas Python API
- Use an LLM as a judge and watch for its biases
- Separate offline from online evaluation
Bài học
- Evaluation Toolkit - Ragas: the generation metrics
Ragas is an automated evaluation framework for RAG systems that uses a frontier LLM as the judge instead of human-written ground truth. It scores each part of the system with its own metric; this lesson covers the two that judge the generator - faithfulness and answer relevancy.
- Ragas: the retrieval metrics and the quick reference
Context precision checks that relevant chunks are ranked near the top; context recall checks that the retrieved chunks contain everything the reference answer needs. With faithfulness and answer relevancy they form a 2x2 - two metrics for the generator, two for the retriever - and a healthy system targets 0.85 or more on all four.
- Beyond RAGAS: The Evaluation Ecosystem in 2026
RAGAS is the de facto standard for RAG metrics, but production teams combine it with DeepEval (50+ metrics, pytest and CI/CD), Arize Phoenix (OpenTelemetry observability plus evaluation) and MLflow (one API over several frameworks, with experiment tracking), and practise eval-driven development - evals written before changes ship.
- Ragas Python API
Install Ragas, score samples with the class-based async metrics built on llm_factory, plug in a LangChain chat model with LangchainLLMWrapper, keep using the legacy batch evaluate() where needed, and know the newer metrics - AnswerAccuracy, ResponseGroundedness and DiscreteMetric.
- LLM-as-Judge: When and How
Use an LLM as the judge when ground-truth labels do not exist at scale, when the output is open-ended, or when the quality has no deterministic function. Pick a judge stronger than the generator, and watch for position bias, length bias and self-preference.
- Offline vs Online Evaluation
Offline evaluation runs the full eval suite on a frozen test set before every release and catches regressions; online evaluation samples 1-5% of production traffic and catches drift from changing user behaviour. Both layers are necessary.
- Assignment: RAGAS Evaluation Metrics
RAGAS Evaluation Metrics for RAG Systems