Skip to main content

Framework-agnostic RAG evaluation library — fully local, no LLM API required

Project description

Lupa

RAG evaluation that actually tells you what's wrong.

Python 3.10+ MIT License PyPI


Most developers evaluate RAG by eyeballing outputs. When something breaks, they don't know if it's retrieval or generation. Lupa tells you exactly where.


Install

pip install rageval

Quick Start

import rageval

def my_pipeline(query: str) -> tuple[list[str], str]:
    # Wrap your existing RAG pipeline — any framework works.
    chunks = retriever.search(query)
    answer = llm.generate(query, chunks)
    return chunks, answer

results = rageval.evaluate(
    my_pipeline,
    dataset="rageval-financialqa-mini",
    metrics=["retrieval_precision", "faithfulness", "answer_relevance", "latency"],
)

results.report()       # prints markdown table to console
results.save("report.md")
results.to_json("results.json")

Metrics

Metric What it measures API required?
retrieval_precision Fraction of retrieved chunks that are semantically relevant (not distractors) No
faithfulness Fraction of answer sentences entailed by the retrieved context No
answer_relevance How well the answer addresses the query (BERTScore F1) No
latency Wall-clock time per query — reports p50, p90, p99 No

All metrics run fully locally using sentence-transformers and BERTScore. No evaluation API calls. No per-query cost.


Real Benchmark Results

Pipeline: GPT-4o-mini + text-embedding-3-small + Chroma
Dataset: rageval-financialqa-mini (10 financial QA examples)

Metric Score
Retrieval Precision 0.300
Faithfulness 0.300
Answer Relevance 0.883
Latency p50 1.58s
Latency p90 2.33s
Latency p99 3.20s

Retrieval precision of 0.30 revealed the pipeline was retrieving wrong-quarter documents (e.g. Q1 2024 instead of Q1 2023) — exactly the distractor failure mode the dataset is designed to catch. Answer relevance stayed high at 0.88, showing the LLM answered well given its context, but that context was often wrong.


Why Lupa?

  • Framework agnostic — one function signature works with LangChain, LlamaIndex, raw API calls, or anything else. Lupa never touches your pipeline internals.
  • Fully local — all four metrics run on-device. No LLM API calls for evaluation, no per-query cost, no data leaving your machine.
  • Diagnostic — every metric returns a per-example breakdown. See exactly which queries failed retrieval and which answers were hallucinated.
  • Comparablecompare() diffs two result files and flags regressions automatically. Safe to run in CI before merging a prompt change.

Comparing Pipeline Versions

# Evaluate baseline
baseline = rageval.evaluate(baseline_pipeline, dataset, metrics)
baseline.to_json("baseline.json")

# Evaluate new version
new = rageval.evaluate(new_pipeline, dataset, metrics)
new.to_json("new.json")

# Compare — flags any metric that dropped more than 3%
report = rageval.compare("baseline.json", "new.json")
report.report()
Lupa — Pipeline Comparison Report
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                  baseline  new       delta
Retrieval Prec.   0.740     0.810     ↑ +9.5%
Faithfulness      0.680     0.710     ↑ +4.4%
Answer Relevance  0.830     0.800     ↓ -3.6%  ⚠ regression
Latency p50       1.40s     1.10s     ↑ faster

⚠ Regression detected: Answer Relevance dropped 3.6% (threshold: 3%)

Generating Your Own Dataset

Build an evaluation dataset from your own documents:

dataset = rageval.generate_dataset(
    documents=my_docs,    # list of document strings from your corpus
    n_questions=50,
    llm="openai",         # or "anthropic"
    output_path="my_dataset.json",
)

Requires pip install openai or pip install anthropic. The LLM generates questions, ground-truth answers, and distractor documents automatically.


Links


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

lupa_rageval-0.1.0.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

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

lupa_rageval-0.1.0-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file lupa_rageval-0.1.0.tar.gz.

File metadata

  • Download URL: lupa_rageval-0.1.0.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for lupa_rageval-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bf2deaa3872abb44955251dc3ac6fab09a7884b46708452874da60336a360b50
MD5 ef2d85a81d2a3875d0059ce82540c3ea
BLAKE2b-256 9e073b1ec531d91f0ac8f8967231be7024990c8ba7fc9e432e5298b98b1fced4

See more details on using hashes here.

File details

Details for the file lupa_rageval-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lupa_rageval-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for lupa_rageval-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29c39089f165e52371e2d775ec9bd4ba5ccf5c23140af5171f7c03f5dc664fe6
MD5 55af0246866251b50d12f458528421f7
BLAKE2b-256 4786913f6339247fe280359cde670a1c0431ed2023448bf1cd2e435a4157c05d

See more details on using hashes here.

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