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

dataset = [
    {
        "question": "What is the significance of Apple's manufacturing...",
        "relevent_chunks": ["pdf_chunk_94", "pdf_chunk_17", "pdf_chunk_107"],
        "retrieved_chunks": ["pdf_chunk_94", "pdf_chunk_91", "pdf_chunk_95"]
    },
    ...
]

report = RAGEvaluator.from_dict_list(dataset, k=5)
RAGEvaluator(k=5).report(report)

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.4.tar.gz (4.8 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.4-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rag_eval_lite-0.1.4.tar.gz
  • Upload date:
  • Size: 4.8 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.4.tar.gz
Algorithm Hash digest
SHA256 f3d7399d2895a9654a20e34f1aa82ed24998d9c8660b9d428093a3a76fe3cf44
MD5 4eb1b906d27469eb59c2589e990759e6
BLAKE2b-256 f8d819d6b9fce647c0173f5aa6ce84a304386a64468f17c3d55a7c6f56af3a5d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rag_eval_lite-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.2 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 667c3bce77043bbc2a097639009e9393427a738becc265c4e232f5666a3495f3
MD5 7542d59fae9be4b80fb7848e485d3b28
BLAKE2b-256 fdc9ebf3772d31fb61a6bf6bb2ac21ebe22ccc161f1caed341704e7150a8a9db

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