Skip to main content

RagaliQ: The Ultimate LLM & RAG Evaluation Testing Framework

Python 3.14+ License: MIT PyPI version CI Docs

RagaliQ (RAG + Quality) is an open-source LLM/RAG testing toolkit that brings software testing discipline to Retrieval-Augmented Generation pipelines. It provides automated hallucination detection, faithfulness metrics, answer relevance scoring, context precision, and context recall evaluation — all powered by an LLM-as-Judge architecture. Write quality tests for your AI responses as naturally as you write unit tests with pytest.


Why RagaliQ?

When you deploy a RAG system, how do you know the answers are accurate? How do you catch hallucinations before your users do? How do you ensure your retrieval pipeline returns the right documents?

Traditional keyword-matching approaches miss semantic errors. RagaliQ solves this with LLM-as-Judge evaluation: Claude assesses response quality with deep semantic understanding, scoring each response across multiple evaluation metrics. This is the same approach used in academic LLM benchmarking — now available as a developer-friendly testing framework.

v0.1.0: Claude is the supported judge. OpenAI judge support is planned — track it at GitHub Issues.


Key Features

Capability What It Does How It Helps
Hallucination Detection Identifies claims not supported by retrieved context Catches fabricated facts before users see them
Faithfulness Metrics Multi-step claim extraction and verification against source documents Ensures responses stay grounded in your data
Answer Relevance Scoring Evaluates whether the response actually answers the user's query Prevents off-topic or evasive answers
Context Precision Measures whether retrieved documents are relevant to the query Audits your vector database retrieval quality
Context Recall Verifies that context covers all expected facts Validates your embedding similarity and retrieval coverage
Pytest Plugin Native fixtures, markers, and assert helpers RAG tests run alongside your existing unit tests
CLI & CI/CD Command-line interface with GitHub Actions integration Automated quality gates in your deployment pipeline
Async-First Concurrent evaluations with configurable parallelism Fast evaluation even with large test datasets
Rich Reports Console, HTML, and JSON output formats Actionable results for developers and stakeholders

Installation

pip install ragaliq

Set your API key:

export ANTHROPIC_API_KEY=your-key-here

Quick Start

Python API

from ragaliq import RagaliQ, RAGTestCase

tester = RagaliQ(judge="claude")

test = RAGTestCase(
    id="test-1",
    name="Capital of France",
    query="What is the capital of France?",
    context=["France is a country in Western Europe. Its capital city is Paris."],
    response="The capital of France is Paris, known for the Eiffel Tower.",
)

result = tester.evaluate(test)
print(f"Faithfulness: {result.scores['faithfulness']:.2f}")
print(f"Relevance:    {result.scores['relevance']:.2f}")
print(f"Status:       {'PASSED' if result.passed else 'FAILED'}")

Sync vs async: evaluate() and evaluate_batch() use asyncio.run() internally — they work great in scripts and CLI tools, but cannot be called from inside a running event loop (FastAPI handlers, Jupyter notebooks, async test functions). Use evaluate_async() / evaluate_batch_async() in those contexts.

Pytest Integration

The pytest plugin loads automatically when RagaliQ is installed. No configuration needed.

# test_rag_quality.py
import pytest
from ragaliq import RAGTestCase
from ragaliq.integrations.pytest_plugin import assert_rag_quality


@pytest.mark.rag_test
def test_faithful_answer(rag_tester):
    test_case = RAGTestCase(
        id="t1",
        name="Capital of France",
        query="What is the capital of France?",
        context=["France is a country in Western Europe. Its capital city is Paris."],
        response="The capital of France is Paris.",
    )
    result = rag_tester.evaluate(test_case)
    assert result.passed, f"Quality check failed: {result.scores}"


@pytest.mark.rag_test
def test_with_helper(ragaliq_judge):
    test_case = RAGTestCase(
        id="t2",
        name="ML definition",
        query="What is machine learning?",
        context=["Machine learning is a subset of AI that enables systems to learn from data."],
        response="Machine learning is an AI technique that allows systems to improve from data.",
    )
    assert_rag_quality(test_case, judge=ragaliq_judge)

Run with:

ANTHROPIC_API_KEY=sk-ant-... pytest tests/ -v

CLI

# Run evaluations against a dataset
ragaliq run dataset.json --evaluator faithfulness --evaluator relevance --threshold 0.8

# Generate a test dataset from documents
ragaliq generate ./docs/ --num 20 --output test_cases.json

# Validate a dataset file without running evaluations
ragaliq validate dataset.json

# List all available evaluators
ragaliq list-evaluators

Evaluation Metrics

RagaliQ ships with five built-in evaluators for comprehensive RAG pipeline testing:

Evaluator Measures Default Threshold
faithfulness Response grounded only in provided context 0.7
relevance Response actually answers the query 0.7
hallucination Response free from unsupported claims 0.8
context_precision Retrieved documents are relevant to the query 0.7
context_recall Context covers all expected facts (requires expected_facts) 0.7

faithfulness scores supported claims / total claims. At 0.7, a response with K claims passes when at most floor(0.3 × K) of them are unsupported. K comes from the judge's claim extraction and can change with the judge model or prompt, so one unsupported claim in three fails (0.67) while one in four passes (0.75). For zero tolerance, use FaithfulnessEvaluator(threshold=1.0); the runner and the CLI apply one threshold to every evaluator.

The Default Threshold column gives each evaluator class's own default, which applies when you build the evaluator yourself, for example HallucinationEvaluator(). RagaliQ, ragaliq run and assert_rag_quality judge every evaluator at one threshold: 0.7 unless you set default_threshold, --threshold or threshold. Through them, hallucination is judged at that threshold, not at 0.8.

Custom Evaluators

Extend RagaliQ with your own evaluation metrics using the evaluator registry:

from ragaliq.evaluators import register_evaluator
from ragaliq.core.evaluator import Evaluator, EvaluationResult
from ragaliq.core.test_case import RAGTestCase
from ragaliq.judges.base import LLMJudge


@register_evaluator("conciseness")
class ConcisenessEvaluator(Evaluator):
    name = "conciseness"
    description = "Measures whether the response is appropriately concise"
    threshold = 0.7

    async def evaluate(self, test_case: RAGTestCase, judge: LLMJudge) -> EvaluationResult:
        result = await judge.evaluate_relevance(
            query=test_case.query,
            response=test_case.response,
        )
        return EvaluationResult(
            evaluator_name=self.name,
            score=result.score,
            passed=self.is_passing(result.score),
            reasoning=result.reasoning,
            tokens_used=result.tokens_used,
        )

Dataset Formats

RagaliQ accepts JSON, YAML, and CSV test datasets:

{
  "version": "1.0",
  "test_cases": [
    {
      "id": "tc-1",
      "name": "Capital query",
      "query": "What is the capital of France?",
      "context": ["France is a country in Western Europe. Its capital is Paris."],
      "response": "The capital of France is Paris.",
      "expected_answer": "Paris",
      "expected_facts": ["capital is Paris"],
      "tags": ["geography"]
    }
  ]
}

Generate a test dataset from your own documents:

ragaliq generate ./docs/ --num 50 --output dataset.json

Reports

Console

from ragaliq.reports import ConsoleReporter

ConsoleReporter(threshold=0.7).report(results)

JSON

from ragaliq.reports import JSONReporter

json_str = JSONReporter(threshold=0.7).export(results)

HTML

from ragaliq.reports import HTMLReporter

html_str = HTMLReporter(threshold=0.7).export(results)

Via CLI:

ragaliq run dataset.json --output html --output-file report.html
ragaliq run dataset.json --output json --output-file report.json

GitHub Actions Integration

RagaliQ auto-detects GitHub Actions and enables:

  • Step summaries — Markdown results table in the Actions run UI
  • PR annotations — ::error:: annotations on failing test cases
  • Step outputs — total, passed, failed, pass_rate for downstream steps
  • Clean logs — Rich spinner disabled, plain text output
# .github/workflows/ragaliq-ci.yml
- name: Run RAG evaluations
  env:
    ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
  run: ragaliq run dataset.json --output json --output-file report.json

- name: Upload report
  if: always()
  uses: actions/upload-artifact@v4
  with:
    name: ragaliq-report
    path: report.json

See examples/ci_cd_example/ragaliq-ci.yml for a complete workflow.


Pytest Plugin Reference

Fixtures

Fixture Scope Description
rag_tester function Pre-configured RagaliQ runner using the session judge
ragaliq_judge session Shared LLMJudge instance configured from CLI options
ragaliq_runner function Alias for rag_tester
ragaliq_trace_collector session Tracks token usage and cost across the session

assert_rag_quality Helper

from ragaliq.integrations.pytest_plugin import assert_rag_quality

assert_rag_quality(
    test_case,
    judge=ragaliq_judge,  # optional — creates default ClaudeJudge if omitted
    evaluators=["faithfulness"],  # optional — defaults to ["faithfulness", "relevance"]
    threshold=0.8,  # optional — defaults to 0.7
)

Raises AssertionError with failing metric names and scores if any metric falls below the threshold.

Markers

@pytest.mark.rag_test     # Mark as RAG quality test
@pytest.mark.rag_slow     # Skip with: pytest -m "not rag_slow"

CLI Options

pytest --ragaliq-judge claude \
       --ragaliq-model claude-sonnet-5-5 \
       --ragaliq-api-key sk-ant-... \
       --ragaliq-cost-limit 5.00 \
       --ragaliq-latency-ms 100

For complex multi-step or gold-standard judging flows, use --ragaliq-model claude-opus-5-5.


Architecture

src/ragaliq/
├── core/           # RAGTestCase, Evaluator base, RagaliQ runner
├── evaluators/     # Faithfulness, Relevance, Hallucination, ContextPrecision, ContextRecall
├── judges/         # ClaudeJudge, LLMJudge ABC, JudgeConfig, TraceCollector
├── datasets/       # DatasetLoader (JSON/YAML/CSV), TestCaseGenerator
├── reports/        # ConsoleReporter, HTMLReporter, JSONReporter
├── integrations/   # Pytest plugin, GitHub Actions helpers
└── cli/            # Typer CLI (run, generate, validate, list-evaluators)

Development

git clone https://github.com/dariero/RagaliQ.git
cd RagaliQ

# requires uv (see CONTRIBUTING.md)
uv venv --python 3.14
uv pip sync pylock.toml
uv pip install -e . --no-deps

.venv/bin/ruff check src/ tests/ scripts/ && .venv/bin/mypy src/ scripts/ && .venv/bin/pytest
.venv/bin/coverage run --source=src/ragaliq -m pytest tests/unit/ tests/meta/test_meta_metrics.py -o addopts="" -q && .venv/bin/coverage report

Documentation


Comparison with Alternatives

Feature RagaliQ RAGAS DeepEval
Pytest-native integration Yes No Partial
LLM-as-Judge (Claude) Yes No Yes
CLI with dataset generation Yes No Yes
GitHub Actions integration Yes No No
Async-first architecture Yes Partial No
Custom evaluator registry Yes Yes Yes
HTML/JSON reporting Yes No Yes
Open source (MIT) Yes Yes Partial

Why "RagaliQ"?

RAG (Retrieval-Augmented Generation) + Quality = RagaliQ

Because answer correctness matters when building AI systems that people rely on. RagaliQ helps you audit your retrieval pipeline, detect hallucinations, and ship with confidence.


License

MIT License — see LICENSE for details.

Metadata

Release files for ragaliq 0.3.0

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

Source distribution (sdist)

Source distribution for ragaliq 0.3.0
File Size Uploaded Provenance Actions
ragaliq-0.3.0.tar.gz 253.7 kB With provenance Details for ragaliq-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 325.5 kB

Release files / ragaliq-0.3.0.tar.gz

Download URL ragaliq-0.3.0.tar.gz
Size 253.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9f1368ead5a1e3d5306548186fd100ed00052c75bcfcba861cef1cd3b5028110
BLAKE2b-256 checksum
How to use checksums
1487a3b968a685e115d2b5ea0ba3122d36b3fa1df896a59843bb21f3c32dda12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / ragaliq-0.3.0-py3-none-any.whl

Download URL ragaliq-0.3.0-py3-none-any.whl
Size 71.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
88c0aefea19a42c9b29a736c150e0f575ce0c38e717824a764da85b13648c814
BLAKE2b-256 checksum
How to use checksums
c84e47a499f479c82a5ed56ec048d6e04f39225308bf4fbbb087d8a793de47d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for ragaliq 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ragaliq-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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