Skip to main content

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 lupa-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.
  • Comparable — compare() 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.



License

MIT

Metadata

Release files for lupa-rageval 0.1.1

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

Source distribution (sdist)

Source distribution for lupa-rageval 0.1.1
File Size Uploaded Provenance Actions
lupa_rageval-0.1.1.tar.gz 21.9 kB Without provenance Details for lupa_rageval-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lupa-rageval 0.1.1
File Interpreter ABI Platform Actions
lupa_rageval-0.1.1-py3-none-any.whl Python 3 none any Details for lupa_rageval-0.1.1-py3-none-any.whl

Total release size: 45.0 kB

Release files / lupa_rageval-0.1.1.tar.gz

Download URL lupa_rageval-0.1.1.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
93de09395bffe1635519043d261ba9c85979e966eea5bec23f7cc3354e10f776
BLAKE2b-256 checksum
How to use checksums
f58f6799d8145fcf54ef2f4e191262a571a51d77571976f3ce7788c6260930a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.9

Release files / lupa_rageval-0.1.1-py3-none-any.whl

Download URL lupa_rageval-0.1.1-py3-none-any.whl
Size 23.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bac35bae27e0d00ab8de5d98437185a0ecffa594f4331b7594de92148b00b7d7
BLAKE2b-256 checksum
How to use checksums
f88d05bbb813f592825abef9a65c00051bc2be6528bd9c86a88f4c88414395d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.9

Security for lupa-rageval 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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