Skip to main content

Evaluation engine: RAGAS, DeepEval, LLM-as-Judge, and audit report generation

Project description

rag-forge-evaluator

RAG pipeline evaluation engine for the RAG-Forge toolkit: RAGAS, DeepEval, LLM-as-Judge, and the RAG Maturity Model.

Installation

pip install rag-forge-evaluator

Usage

from rag_forge_evaluator.assess import RMMAssessor

assessor = RMMAssessor()
result = assessor.assess(config={
    "retrieval_strategy": "hybrid",
    "input_guard_configured": True,
    "output_guard_configured": True,
})
print(result.badge)  # e.g., "RMM-3 Better Trust"

Features

  • RMM (RAG Maturity Model) scoring (levels 0-5)
  • RAGAS, DeepEval, and LLM-as-Judge evaluators
  • Golden set management with traffic sampling
  • Cost estimation
  • HTML and PDF report generation

Bring your own judge provider

rag-forge-evaluator ships with Claude and OpenAI judges out of the box, but the JudgeProvider protocol is intentionally minimal so you can plug in any LLM — Gemini, Cohere, Bedrock, Ollama, vLLM, or a private model behind your own gateway. Implementing one is ~20 lines:

# my_gemini_judge.py
import os
import google.generativeai as genai


class GeminiJudge:
    """Minimal judge implementation backed by Google Gemini."""

    def __init__(self, model: str = "gemini-2.5-pro", api_key: str | None = None) -> None:
        key = api_key or os.environ.get("GOOGLE_API_KEY")
        if not key:
            raise ValueError("GOOGLE_API_KEY not set")
        genai.configure(api_key=key)
        self._model_name = model
        self._client = genai.GenerativeModel(model)

    def judge(self, system_prompt: str, user_prompt: str) -> str:
        response = self._client.generate_content(
            [system_prompt, user_prompt],
            generation_config={"max_output_tokens": 4096},
        )
        return response.text or ""

    def model_name(self) -> str:
        return self._model_name

Wire it into an audit by passing the instance directly to LLMJudgeEvaluator:

from my_gemini_judge import GeminiJudge
from rag_forge_evaluator.metrics.llm_judge import LLMJudgeEvaluator

judge = GeminiJudge(model="gemini-2.5-pro")
evaluator = LLMJudgeEvaluator(judge=judge)
result = evaluator.evaluate(samples)

The protocol contract:

class JudgeProvider(Protocol):
    def judge(self, system_prompt: str, user_prompt: str) -> str: ...
    def model_name(self) -> str: ...

That's it. Anything that responds to those two methods works. Implementation hints:

  • Always set max_tokens >= 4096 for faithfulness/hallucination metrics. Long responses produce 30-50 enumerated claims; smaller budgets truncate the JSON mid-array and the metric ends up skipped.
  • Wrap your client with retry logic for transient 429/5xx. The Anthropic and OpenAI SDKs honor a max_retries constructor arg with built-in exponential backoff — most provider SDKs offer something similar.
  • Return the raw response text, including any prose around the JSON. The shared response parser handles code fences, leading prose, trailing prose, and truncated output, so you don't need to clean anything up.

First-party Gemini, Bedrock, and Ollama judges are tracked for v0.1.2.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rag_forge_evaluator-0.2.3.tar.gz (117.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rag_forge_evaluator-0.2.3-py3-none-any.whl (85.0 kB view details)

Uploaded Python 3

File details

Details for the file rag_forge_evaluator-0.2.3.tar.gz.

File metadata

  • Download URL: rag_forge_evaluator-0.2.3.tar.gz
  • Upload date:
  • Size: 117.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rag_forge_evaluator-0.2.3.tar.gz
Algorithm Hash digest
SHA256 e6be4f5d3047312c852dd5f789364a20823721d4c186d67adbe7da7ec434c1a5
MD5 2145ababb60a87fca7bcb740c8bb37bf
BLAKE2b-256 c7ca1043d0ed47e8d083d1d7a58610cbb1280f60b472f83413257ddf0a47a976

See more details on using hashes here.

Provenance

The following attestation bundles were made for rag_forge_evaluator-0.2.3.tar.gz:

Publisher: publish.yml on hallengray/rag-forge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rag_forge_evaluator-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for rag_forge_evaluator-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d959d8beb9e99636004945b920adeeea67ba8f647cb514cd95d1678e9d21c701
MD5 33b5f1b763cfc7fe3ed39b7d07312631
BLAKE2b-256 59efca8452605571ba8f3df8e78d9daab532509332af3ff1a5fe25c57414af4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for rag_forge_evaluator-0.2.3-py3-none-any.whl:

Publisher: publish.yml on hallengray/rag-forge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page