Skip to main content

ragvet

ci license: MIT python 3.10+

Evaluation and retrieval-benchmark harness for RAG systems. Prove retrieval and answer quality with numbers instead of vibes.

Live: a monthly leaderboard of the most-downloaded small embedding models on Hugging Face, each new revision scored on BEIR/scifact by a scheduled GitHub Action.

Why evals

Most RAG failures are retrieval failures, not generation failures: the model answers badly because the wrong chunks were fetched, not because it reasoned poorly. Most teams shipping LLM apps have no evals at all, so a retrieval regression ships silently and shows up as "the bot got worse" three weeks later with no way to diagnose it. ragvet scores retrieval (hit@k, MRR, nDCG, recall), scores the generated answer (faithfulness, relevance), tracks cost, and detects query drift, so you catch regressions before your users do.

Install

Install from a clone of this repository. This project is not published on PyPI. It was renamed from ragproof because a ragproof package there is an unrelated project by another author, so pip install ragproof will not install this code; the package, CLI and imports are ragvet, and the GitHub repo keeps its old name.

git clone https://github.com/tarang-tj/ragproof.git
cd ragproof
pip install -e .                    # core (offline demo + CLI)
pip install -e ".[benchmark]"       # + model2vec for keyless BEIR benchmarks
pip install -e ".[embeddings]"      # + sentence-transformers for real dense/rerank
pip install -e ".[judge]"           # + anthropic for LLM-as-judge faithfulness
pip install -e ".[dashboard]"       # + streamlit for the drift dashboard

CLI

ragvet demo                                  # offline retrieval demo, no downloads
ragvet benchmark scifact                     # BEIR benchmark, model2vec dense (keyless)
ragvet benchmark scifact --embeddings st --rerank   # bge-small + cross-encoder
ragvet suite scifact nfcorpus                # robustness table across datasets
ragvet leaderboard                           # monthly embedding leaderboard
ragvet version

Retrieval quality (offline demo)

ragvet demo loads a baked-in 40-document corpus and 24 labeled queries and evaluates three retrievers, no keys or downloads:

retriever          hit@3  mrr    ndcg@3  recall@5
-------------------------------------------------
sparse (bm25)      0.917  0.849  0.860  0.958
dense (tfidf+svd)  0.958  0.861  0.886  0.958
hybrid (+rerank)   1.000  0.882  0.912  1.000

Hybrid wins because sparse and dense retrieval have complementary failure modes: BM25 misses paraphrased queries, dense misses exact-keyword ones, and score fusion recovers both. tests/test_eval_runner.py::test_hybrid_beats_single_methods_on_demo_dataset locks the claim in.

Answer quality: faithfulness and relevance

Retrieval metrics say the right context was fetched. They say nothing about the answer the LLM then wrote. ragvet.generation scores that:

  • Faithfulness — the fraction of the answer's sentences supported by the retrieved context. Low = hallucination.
  • Answer relevance — how on-topic the answer is to the question.

Two backends: a keyless embedding heuristic (default) and a Claude LLM-as-judge ([judge] extra) for fine-grained factual entailment.

from ragvet.generation import evaluate_answer
from ragvet.benchmarks.beir import model2vec_embedder
embed = model2vec_embedder()
evaluate_answer(question, answer, retrieved_contexts, embed)
# -> {"faithfulness": 1.0, "answer_relevance": 0.71}

Benchmarks on real data

BEIR/scifact (model2vec dense, keyless, reproduces on a laptop)

BEIR/scifact -- 5183 docs, 300 test queries, real qrels
retriever             hit@3  mrr@10  ndcg@10  recall@10
--------------------------------------------------------
bm25                  0.590   0.524    0.560      0.686
dense (model2vec)     0.520   0.467    0.506      0.662
hybrid                0.633   0.576    0.609      0.731

Hybrid fusion lifts NDCG@10 from 0.560 (BM25) to 0.609. Honest caveat: BM25 here is untuned rank_bm25 (a tuned Anserini BM25 scores ~0.66), and model2vec static embeddings trade quality for CPU speed — the point is the relative hybrid gain and full reproducibility without a GPU.

Stronger embeddings (bge-small + cross-encoder rerank)

ragvet benchmark scifact --embeddings st --rerank swaps in a real sentence-transformer (BAAI/bge-small-en-v1.5) and a cross-encoder reranker (ms-marco-MiniLM-L-6-v2):

retriever               hit@3  mrr@10  ndcg@10  recall@10
----------------------------------------------------------
bm25                    0.590   0.524    0.560      0.686
dense (bge-small)       0.727   0.684    0.720      0.845
hybrid                  0.687   0.627    0.660      0.788
hybrid + rerank         0.717   0.654    0.681      0.795

A real embedder lifts dense NDCG@10 from 0.506 (model2vec) to 0.720 — the single biggest quality jump in this repo. The honest surprise: on scifact, dense alone beats hybrid and hybrid+rerank, because naive score fusion dilutes a strong dense retriever with a weaker BM25 signal. Fusion helps when the two retrievers are comparably strong (see scifact with model2vec, and the SyllabusAI set below); it hurts when one dominates. That is exactly the kind of thing an eval harness is for.

Monthly embedding leaderboard

ragvet leaderboard asks the Hugging Face Hub for today's most-downloaded small embedding models and scores every new revision on scifact. A GitHub Action reruns it on the 15th of each month and commits the result (full table: leaderboard/LEADERBOARD.md).

Dense retrieval on BEIR/scifact (5,183 docs, 300 test queries), no instruction prefixes, so models trained with query prefixes (e5, bge) score below their model cards. Candidates: the 8 most-downloaded sentence-transformers models on Hugging Face under 150M parameters without custom code, re-checked monthly (last check 2026-11). Each score is pinned to the linked revision. BM25 on the same set: 0.560.

# model nDCG@10 recall@10 params downloads rank
1 intfloat/multilingual-e5-small 0.669 0.805 118M 4
2 sentence-transformers/all-mpnet-base-v2 0.656 0.790 109M 3
3 sentence-transformers/all-MiniLM-L6-v2 0.645 0.783 23M 1
4 sentence-transformers/all-MiniLM-L12-v2 0.626 0.782 33M 7
5 sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 0.484 0.616 118M 2
- thenlper/gte-small too slow for a CPU runner - 33M 5
- datasocietyco/bge-base-en-v1.5-course-recommender-v5 too slow for a CPU runner - 109M 6
- sentence-transformers/all-distilroberta-v1 too slow for a CPU runner - 82M 8

Robustness across datasets

ragvet suite scifact nfcorpus — hybrid wins on both:

Robustness -- NDCG@10 across datasets (dense = model2vec)
retriever                  scifact    nfcorpus
----------------------------------------------
bm25                         0.560       0.267
dense (model2vec)            0.506       0.244
hybrid                       0.609       0.293

SyllabusAI domain (representative Q&A)

ragvet.benchmarks.syllabus evaluates on the actual problem behind SyllabusAI — answering student questions from course syllabi — using a hand-labeled representative set (the live corpus has no ground-truth labels; point a pgvector retriever at it to run on real data):

SyllabusAI domain eval -- 12 syllabus sections, 16 labeled questions
retriever             hit@3  mrr@5  ndcg@5  recall@5
----------------------------------------------------
bm25                  0.625  0.622   0.653     0.750
dense (model2vec)     0.875  0.830   0.872     1.000
hybrid                0.875  0.762   0.805     0.938

Answer faithfulness (context = CS 250 grading section):
  grounded answer     -> 1.00
  hallucinated answer -> 0.00

Note the flip from scifact: on paraphrased student questions, dense retrieval beats BM25 because the questions rarely share vocabulary with the syllabus text. The faithfulness check cleanly separates a grounded answer from a hallucinated one.

Drift dashboard

streamlit run ragvet/dashboard.py

Paste a baseline window of queries and a current window; the dashboard embeds both and runs drift detection (PSI + centroid distance) so you can see when production traffic has wandered away from your eval set and your metrics have gone stale.

Wire your own stack (pgvector + Claude)

ragvet/retrievers_pgvector_claude.py is a clearly-marked integration stub showing the production seam: Supabase pgvector for retrieval, Claude for generation, behind the same Retriever interface every retriever here uses. Point eval_runner.evaluate_retriever() at it once you fill in your keys.

What's real vs stand-in

  • SparseRetriever — real BM25 (rank_bm25).
  • DenseRetriever — TF-IDF+SVD stand-in for the offline demo; use ragvet.embeddings.sentence_transformer_embedder ([embeddings]) for real semantic vectors, or model2vec ([benchmark]) for a keyless middle ground.
  • Reranker — a lexical/dense blend in the demo; ragvet.embeddings.cross_encoder_reranker is a real cross-encoder.
  • generation.faithfulness — real embedding-support heuristic; ClaudeJudge for entailment-grade scoring.
  • drift.py, cost.py — real math (PSI + centroid cosine; token/$ against a configurable rate table).

Project layout

ragvet/
  metrics.py          hit@k, recall@k, precision@k, mrr, ndcg@k
  cost.py             token + $ estimator
  retrievers.py       Sparse (BM25), Dense (stand-in), Hybrid (+rerank)
  embeddings.py       real sentence-transformer embedder + cross-encoder reranker
  generation.py       faithfulness + answer relevance (+ Claude judge)
  eval_runner.py      run / compare retrievers
  drift.py            centroid cosine + PSI drift detection
  dashboard.py        Streamlit drift dashboard
  cli.py              ragvet CLI
  benchmarks/
    beir.py           generalized BEIR engine (any dataset, pluggable embedder)
    scifact.py        scifact entrypoint
    syllabus.py       SyllabusAI-domain retrieval + faithfulness eval
  retrievers_pgvector_claude.py   integration stub
tests/                metrics, eval_runner, cost, drift, retrievers, generation, cli

Roadmap

  • More BEIR datasets in the suite (fiqa, trec-covid).
  • Live Claude-generated-answer eval end to end (retrieve -> generate -> score) in one command.
  • Ship the drift dashboard on a rolling production-query window with alerting.

Tests

pip install -e ".[dev]" && pytest -q      # 54 tests, no mocks, no network

License

MIT

Metadata

Release files for ragvet 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 ragvet 0.3.0
File Size Uploaded Provenance Actions
ragvet-0.3.0.tar.gz 44.9 kB Without provenance Details for ragvet-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 84.1 kB

Release files / ragvet-0.3.0.tar.gz

Download URL ragvet-0.3.0.tar.gz
Size 44.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b3b7bd0ff085d4052d10c7ee4f92b1f679f0d630c19cd5d4d74092d88e7cc749
BLAKE2b-256 checksum
How to use checksums
35d6fb31e4b8534a2b3833e447e2c69b2a43143d7c7f213955d8195020309460
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

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

Download URL ragvet-0.3.0-py3-none-any.whl
Size 39.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71a2407bd08871d69dec146e47ff89a7fefd4aeadc6786f7a0ea8f644ef4dc1a
BLAKE2b-256 checksum
How to use checksums
67b7cc8a801ef1cdae07ac96e84edb8be70e616082a0dfdea9df369fdee10dac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Security for ragvet 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.

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.3.0 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