Skip to main content

Lightweight evaluation metrics for RAG (Hit@k, Recall@k, Precision@k, MRR, nDCG, and more)

Project description

Structure

Three dataclasses + one evaluator class:

  • QueryResult — your input. Pass query_id, retrieved_chunks (ordered list), relevant_chunks (set)
  • QueryScore — per-query scores + a failures list with human-readable diagnostics
  • EvalReport — mean scores across all queries + failed_queries list
  • RAGEvaluator — the main class, just call .evaluate() then .report()

The Failure Diagnostics Logic

Each query gets diagnosed in priority order:

Failure Meaning Suggestion printed
MISS No relevant chunk in top-k at all Shows what was retrieved vs what was expected
LOW MRR First relevant chunk ranked too low Shows exact rank, suggests re-ranking
INCOMPLETE RECALL Some relevant chunks never retrieved Shows exactly which chunk IDs were missed
LOW PRECISION Too many irrelevant chunks in results Shows the noisy chunk IDs
LOW NDCG Relevant chunks not near the top Suggests re-ranking

Usage in your package

from rag_eval import RAGEvaluator, QueryResult

evaluator = RAGEvaluator(k=5)

results = [
    QueryResult("q1", retrieved_chunks=[...], relevant_chunks={...}),
    QueryResult("q2", retrieved_chunks=[...], relevant_chunks={...}),
]

report = evaluator.evaluate(results)
evaluator.report(report)               # full verbose output
evaluator.report(report, verbose=False) # just the summary table

You can also access report.per_query and report.failed_queries programmatically if you want to log them to MLflow or W&B Weave.

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_eval_lite-0.1.3.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

rag_eval_lite-0.1.3-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file rag_eval_lite-0.1.3.tar.gz.

File metadata

  • Download URL: rag_eval_lite-0.1.3.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for rag_eval_lite-0.1.3.tar.gz
Algorithm Hash digest
SHA256 93497a7258751133d5351e4b5fa52ce821c7b3cd12c2416d98abed36cee4033f
MD5 d9ae23b13609d630934477e41a3afaf0
BLAKE2b-256 aadffd1fa63df9bca609d1e4a12ac3fa401dab7178abff04f35dc0c9e1386115

See more details on using hashes here.

File details

Details for the file rag_eval_lite-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: rag_eval_lite-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for rag_eval_lite-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f132007191faf5a05cbf4eed95287e15383880524425afe594602d21e422f75f
MD5 3bac930aa3ad43eed4ff6dd7c64f4813
BLAKE2b-256 57352f8db416b745500118b386ea2069cbd06e3f0bcf13395792ee3b68115ccb

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