The Crisis of Subjective Evaluation

Prompt engineering often degrades into "vibe testing" where engineers manually test 3 queries and assume the system works. In enterprise environments, every prompt tweak or retrieval change must be regression-tested against hundreds of curated gold-standard questions.

The Core Ragas Metrics

  • Faithfulness: Measures whether every fact asserted in the generated answer can be mathematically grounded in the retrieved context chunks (zero hallucinations).
  • Answer Relevance: Measures whether the generated answer directly addresses the user's intent without superfluous filler text.
  • Context Precision: Evaluates whether the retrieval engine positioned ground-truth chunks at the top ranks.
from ragas import evaluate
from ragas.metrics import faithfulness, answer_relevancy, context_precision

results = evaluate(
    dataset=eval_dataset,
    metrics=[faithfulness, answer_relevancy, context_precision]
)
print(results.to_pandas())