Skip to main content

RAG Evaluator

Overview

RAG Evaluator is a Python library for evaluating Retrieval-Augmented Generation (RAG) systems. It provides various metrics to evaluate the quality of generated text against reference text.

Installation

You can install the library using pip:

pip install evaluatorspk

Usage

Here's how to use the RAG Evaluator library:

from evaluatorspk import RAGEvaluator

# Initialize the evaluator
evaluator = RAGEvaluator()

# Input data
question = "What are the causes of climate change?"
response = "Climate change is caused by human activities."
reference = "Human activities such as burning fossil fuels cause climate change."

# Evaluate the response
metrics = evaluator.evaluate_all(question, response, reference)

# Print the results
print(metrics)

Streamlit Web App

To run the web app:

  • cd into streamlit app folder.
  • Create a virtual env
  • Activate
  • Install all dependencies
  • and run
streamlit run app.py

Metrics

The following metrics are provided by the library:

  • BLEU: Measures the overlap between the generated output and reference text based on n-grams.
  • ROUGE-1: Measures the overlap of unigrams between the generated output and reference text.
  • BERT Score: Evaluates the semantic similarity between the generated output and reference text using BERT embeddings.
  • Perplexity: Measures how well a language model predicts the text.
  • Diversity: Measures the uniqueness of bigrams in the generated output.
  • Racial Bias: Detects the presence of biased language in the generated output.

Testing

To run the tests, use the following command:

python -m unittest discover -s rag_evaluator -p "test_*.py"

Metadata

Release files for evaluatorspk 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for evaluatorspk 0.0.1
File Size Uploaded
evaluatorspk-0.0.1.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for evaluatorspk 0.0.1
File Interpreter ABI Platform
evaluatorspk-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.5 kB

Release files / evaluatorspk-0.0.1.tar.gz

Download URL evaluatorspk-0.0.1.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f8c149543751e0736f3f714833221a3ea1aa7aeb26f0dc6f9674930021c78c9f
BLAKE2b-256 checksum
How to use checksums
ce7134d8f027076b1eaad613f1ac2656d445e9fc9d7a38a18b3ae1665350a1de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Release files / evaluatorspk-0.0.1-py3-none-any.whl

Download URL evaluatorspk-0.0.1-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
961b967582e168b2ebb64491f0e7076efc8087994ace78a212852b97ff45cb0c
BLAKE2b-256 checksum
How to use checksums
c8c32a939696dc15ef4bdae3eb3f0431a4b75bbe751603c01fe971234ec87af2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page