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.1.1.tar.gz (49.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.1.1-py3-none-any.whl (50.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rag_forge_evaluator-0.1.1.tar.gz
  • Upload date:
  • Size: 49.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.1.1.tar.gz
Algorithm Hash digest
SHA256 80efe65c367704809a88a73e0a78acbb18309a6d06fe3c49636b36d690f1b354
MD5 3c4eb9446a4479633bafc53ca3246838
BLAKE2b-256 7d47791a374b141cab015ccd6408f96e0c5c4c1ece8fcaf367ae582e46599c4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for rag_forge_evaluator-0.1.1.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.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for rag_forge_evaluator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a983bfb4f65ccf95e6ac142f2596e8a19aae2206ea7a8b25a3c6daed96326b2c
MD5 313129841bbafa4949e957c6b090371f
BLAKE2b-256 fe12676ffc3861bfd4dba408e68e5092d461e50ce753db9c811898d3cd0892bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for rag_forge_evaluator-0.1.1-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