RAGAS(Retrieval Augmented Generation Assessment)

Open-source framework designed to evaluate Retrieval-Augmented Generation (RAG) pipelines. RAGAS uses an LLM-based approach to score different stages of the RAG workflow, helping you understand where your pipeline is succeeding or failing

Metrics of RAGAS

- We have RAG pipeline in which documents are feed and embeddings are calculated and stored in vector DB
- Now embedding is calculated for actual User's Query and nearness is calculated to document embeddings stored in vector DB
- Now question is how close the LLM's response is to expected response, ie the response which actually should be generated
- Below metrics are measurement of same

1. ResponseRelevancy()

- Response from LLM is fed to another Evaluator LLM that generates several new Sample Prompts, that could have lead this response
- Embeddings is calculated for the Original User Prompt and these Sample Prompts and Cosine Similarity is calculated.
- Average of All these Similarity Scores is the Response Relevancy

2. Faithfulness()

- RAG system provides response to User's query. There are some factual claims made within the response.
- More LLM calls are made to find claims within the response are factually correct or not. Percent of correct Cliams is the faithfulness

RAGAS breaks down evaluation into components that address the two main stages of a RAG pipeline: Retrieval (finding the right data) and Generation (creating the answer).

Metrics Name Stage Explanation
1. Context Precision Retrieval Measures if the most relevant information is ranked highly in the search results.
2 . Context Recall Retrieval Measures if the system retrieved all the information required to answer the query.
3. Faithfulness Generation Measures if the generated answer is derived only from the retrieved context (prevents hallucinations).