Metadata-Version: 2.5
Name: rag-evaluation-framework
Version: 0.1.0
Summary: A modular Python framework for evaluating, benchmarking, and regression-testing Retrieval-Augmented Generation systems.
Project-URL: Homepage, https://github.com/buhozurdo/rag-evaluation-framework
Project-URL: Repository, https://github.com/buhozurdo/rag-evaluation-framework
Project-URL: Issues, https://github.com/buhozurdo/rag-evaluation-framework/issues
Author: BuhoZurdo Team
License-Expression: MIT
License-File: LICENSE
Keywords: benchmarking,evaluation,evaluation-metrics,llm,machine-learning,rag,regression-testing,retrieval
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: pydantic<3,>=2.7
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.30; extra == 'anthropic'
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.9; extra == 'dev'
Requires-Dist: twine>=5.0; extra == 'dev'
Provides-Extra: openai
Requires-Dist: openai>=1.0; extra == 'openai'
Provides-Extra: yaml
Requires-Dist: pyyaml>=6.0; extra == 'yaml'
Description-Content-Type: text/markdown

# RAG Evaluation Framework

[![PyPI](https://img.shields.io/pypi/v/rag-evaluation-framework.svg)](https://pypi.org/project/rag-evaluation-framework/)
[![Python](https://img.shields.io/pypi/pyversions/rag-evaluation-framework.svg)](https://pypi.org/project/rag-evaluation-framework/)
[![CI](https://github.com/buhozurdo/rag-evaluation-framework/actions/workflows/ci.yml/badge.svg)](https://github.com/buhozurdo/rag-evaluation-framework/actions/workflows/ci.yml)
[![License](https://img.shields.io/pypi/l/rag-evaluation-framework.svg)](LICENSE)

**A lightweight, typed Python framework for evaluating, benchmarking,
and regression-testing Retrieval-Augmented Generation (RAG) systems.
Provides deterministic retrieval metrics, LLM-based generation evaluation,
reproducible benchmarks, and configurable CI/CD quality gates — without
locking you into any LLM provider.**

---

## Overview

RAG Evaluation Framework provides a modular evaluation layer for measuring
the quality, reliability, and consistency of Retrieval-Augmented Generation
systems.

It separates evaluation from RAG implementation, allowing different
pipelines, retrieval strategies, embedding models, and LLM providers to be
evaluated through a common set of contracts and metrics.

### Core Capabilities

- **Retrieval Evaluation:** Recall@K, Precision@K, MRR, and NDCG.
- **Generation Evaluation:** Faithfulness and Answer Relevancy.
- **Golden Datasets:** Versionable evaluation datasets with expected results.
- **Regression Testing:** Compare evaluation runs and detect quality degradation.
- **Quality Gates:** Configurable thresholds for automated CI/CD validation.
- **Provider Agnostic:** Integrate different LLM providers through adapters.

---

## Installation

```bash
pip install rag-evaluation-framework
```

Optional extras:

```bash
pip install "rag-evaluation-framework[openai]"
pip install "rag-evaluation-framework[anthropic]"
pip install "rag-evaluation-framework[yaml]"
```

## Quickstart

```python
from rag_evaluation import (
    CallableJudge,
    DatasetCase,
    Evaluator,
    GoldenDataset,
    QualityGate,
    RAGResponse,
    evaluate_gates,
)

dataset = GoldenDataset(
    name="product-docs",
    version="0.1.0",
    cases=[
        DatasetCase(
            id="case-1",
            query="What is the default request timeout?",
            expected_doc_ids=["doc-config"],
        )
    ],
)

responses = [
    RAGResponse(
        case_id="case-1",
        retrieved_doc_ids=["doc-config", "doc-faq"],
        contexts=["The default request timeout is 30 seconds."],
        answer="The default request timeout is 30 seconds.",
    )
]

judge = CallableJudge(lambda _prompt: '{"score": 0.95, "reason": "Grounded and relevant."}')
report = Evaluator(k_values=(2,), judge=judge).evaluate(dataset, responses)

gates = [
    QualityGate(metric="recall@2", min_score=0.8),
    QualityGate(metric="faithfulness", min_score=0.85),
]
result = evaluate_gates(report, gates)
assert result.passed, result.summary_text()
```

See [examples/quickstart.py](examples/quickstart.py) for a runnable example.
