RAG Evaluation Framework using Ragas metrics and MLflow tracking
Project description
RAGSentinel
RAG Evaluation Framework using Ragas metrics and MLflow tracking.
Installation
1. Create Virtual Environment
# Create project directory
mkdir my-rag-eval
cd my-rag-eval
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
2. Install Package
pip install rag-sentinel
Quick Start
1. Initialize Project
rag-sentinel init
This creates:
.env- LLM/Embeddings API keysconfig.ini- Backend API endpoint and authentication settingstest_dataset.csv- Sample test dataset
Note: The master configuration (rag_eval_config.yaml) is managed internally by the package. You only need to configure .env and config.ini.
2. Configure
A. Edit .env file
Configure your LLM and Embeddings providers:
# LLM Provider (azure, openai, or ollama)
LLM_PROVIDER=azure
# Azure OpenAI LLM Configuration
AZURE_LLM_API_KEY=your-api-key
AZURE_LLM_ENDPOINT=https://your-resource.openai.azure.com
AZURE_LLM_DEPLOYMENT_NAME=gpt-4
AZURE_LLM_MODEL=gpt-4
AZURE_LLM_TEMPERATURE=0.0
AZURE_LLM_API_VERSION=2024-02-15-preview
# Embeddings Provider (azure, openai, or ollama)
EMBEDDINGS_PROVIDER=azure
# Azure OpenAI Embeddings Configuration
AZURE_EMBEDDINGS_API_KEY=your-api-key
AZURE_EMBEDDINGS_ENDPOINT=https://your-resource.openai.azure.com
AZURE_EMBEDDINGS_DEPLOYMENT_NAME=text-embedding-ada-002
AZURE_EMBEDDINGS_API_VERSION=2024-02-15-preview
B. Edit config.ini file
Configure your RAG backend API and evaluation settings:
MLflow Settings:
[mlflow]
tracking_uri = http://127.0.0.1:5000
experiment_name = RAG Evaluation
run_name = RAG Evaluation Run
Backend API Endpoint:
[endpoints]
# Your complete RAG API endpoint
response_api_path = https://your-app.com/api/respond
# HTTP method (POST or GET)
method = POST
# Request headers (comma-separated key:value pairs)
headers = Content-Type:application/json
# Request body fields (use {query} and {chat_id} as placeholders)
body_fields = prompt:{query},chat_id:{chat_id}
# JSON response keys
answer_key = response
contexts_key = context
Authentication:
[auth]
# Options: cookie, bearer, header, or none
type = cookie
cookie_name = session
cookie_value = your-session-cookie-value
Dataset:
[dataset]
path = test_dataset.csv
category = simple # Options: simple (RAGAS) or guardrail (security)
C. Edit test_dataset.csv file
Add your test queries in the format: query,ground_truth,chat_id
Example:
query,ground_truth,chat_id
What is RAG?,RAG stands for Retrieval-Augmented Generation,1
How does vector search work?,Vector search finds similar items using embeddings,2
For detailed configuration help, see the comments in each config file.
3. Validate & Run
# Validate configuration
rag-sentinel validate
# Run evaluation
rag-sentinel run
Results will be available in the MLflow UI at the configured tracking URI.
CLI Commands
# Initialize new project
rag-sentinel init
# Validate configuration
rag-sentinel validate
# Run evaluation (auto-starts MLflow)
rag-sentinel run
# Run without starting MLflow server
rag-sentinel run --no-server
# Overwrite existing config files
rag-sentinel init --force
# Check package version
pip show rag-sentinel
# Upgrade to latest version
pip install --upgrade rag-sentinel
Evaluation Categories
Set category in config.ini to choose evaluation type:
Simple (RAGAS Quality Metrics)
category = simple
- Faithfulness - Factual consistency of answer with context
- Answer Relevancy - How relevant the answer is to the question
- Context Precision - Quality of retrieved context
- Answer Correctness - Comparison against ground truth
Guardrail (Security Metrics)
category = guardrail
- Toxicity Score - Detects toxic content in responses
- Bias Score - Detects biased content in responses
Performance Metrics
Logged for all evaluation categories:
- Avg Response Time - Average API response time (ms)
- P90 Latency - 90th percentile latency (ms)
- Queries Per Second - Throughput (QPS)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rag_sentinel-0.1.10.tar.gz.
File metadata
- Download URL: rag_sentinel-0.1.10.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd69d1f35b8f20cb898e9fc68f2ba2c26df3f9f89a0914e8e9827a9fed95fe88
|
|
| MD5 |
dd635e0e085426756120e297a4faf181
|
|
| BLAKE2b-256 |
d7e0b4262868175afc211e243ec6c3de546a93f348506c287d249268b018703b
|
File details
Details for the file rag_sentinel-0.1.10-py3-none-any.whl.
File metadata
- Download URL: rag_sentinel-0.1.10-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f46ef5a926ef9d7210bc8b32aff54a8278e9ce85386159e3dba7a16adfa0bd5
|
|
| MD5 |
1c8957e29369e6427b6cdb59f6aa5e63
|
|
| BLAKE2b-256 |
52217f71ef2703f290c1bdbb7aad4f8d0c11166c86b1e3bdc1ac9511f83d460d
|