ragcheck (pip install retrievalcheck)
Measure any RAG or AI search system in one command, and prove that a change made it better.
Most AI search gets tuned by vibes: someone tries a few questions, changes the chunk size, tries again. ragcheck replaces that with numbers. Give it real questions and the documents that should be found; it runs them against your system and reports:
- Retrieval quality: recall@k, precision@k, hit@k, MRR, nDCG@k
- Answer accuracy: checks whether answers contain the facts they must contain (optional)
- Latency: p50 / p95 / max, measured honestly (sequential by default)
- Per-category breakdown: tag questions ("billing", "account"…) and see where the system fails, worst first
- Before/after diffs: which questions a change fixed, and which it broke
- CI gate: exit code 1 when quality drops below your bar
Zero dependencies (Python standard library only). On PyPI as retrievalcheck; the command is ragcheck. Works with any system: an HTTP endpoint, a Python function, or the built-in keyword baseline.
Try it in 10 seconds
pip install retrievalcheck
git clone https://github.com/nadaboulaares/ragcheck && cd ragcheck
ragcheck run --config examples/acme-docs/ragcheck.toml --out runs/before.json
cd examples/acme-docs
ragcheck run --cases questions.jsonl --python better_search:search -k 3 --out ../../runs/after.json
cd ../..
ragcheck compare runs/before.json runs/after.json
The demo is a fictional note-taking app's help center. Plain keyword search misses questions phrased the way users actually talk ("I want to stop paying" vs. a doc titled Cancelling your subscription); the "improved" retriever expands queries, and compare shows exactly what that bought.
Your own system
1. Write questions (questions.jsonl, one per line):
{"id": "refund", "query": "Can I get my money back?", "relevant": ["billing/refunds"], "answer_contains": ["30 days"], "tags": ["billing"]}
relevant holds the ids your system returns for the right documents. answer_contains is optional and only checked when the system returns an answer. tags is optional; with it, every report adds a By category table:
| Category | Questions | Recall@3 | Hit@3 | MRR |
|----------|----------:|---------:|------:|------:|
| features | 6 | 83.3% | 83.3% | 58.3% | ← look here first
| billing | 6 | 83.3% | 83.3% | 83.3% |
| account | 3 | 100.0% | 100.0%| 100.0%|
2. Point ragcheck at it.
HTTP (anything that takes a query and returns hits):
ragcheck run --cases questions.jsonl --http http://localhost:8000/search
or with a config file for custom request bodies, response shapes and auth headers:
cases = "questions.jsonl"
k = 5
[retriever]
type = "http"
url = "https://api.example.com/search"
body = '{"query": "{query}", "top_k": {k}}'
results_path = "data.hits" # dotted path to the list of hits
id_field = "document.id" # id inside each hit ('' if hits are plain ids)
answer_path = "answer" # optional: generated answer to check
headers = { Authorization = "Bearer ${SEARCH_API_KEY}" } # env vars expanded
[fail_under]
recall = 0.8
latency_p95_ms = 1500 # latency thresholds are maximums
Python (call your retriever directly):
# my_search.py
def search(query: str, k: int):
return [hit.id for hit in my_index.query(query, top_k=k)]
# or: return {"ids": [...], "answer": "..."}
ragcheck run --cases questions.jsonl --python my_search:search
3. Save, change, compare.
ragcheck run --config ragcheck.toml --out runs/before.json --html report.html
# ... change chunking / embeddings / reranker ...
ragcheck run --config ragcheck.toml --out runs/after.json
ragcheck compare runs/before.json runs/after.json --fail-on-regression
In CI
- run: pip install retrievalcheck
- run: ragcheck run --config ragcheck.toml --fail-under recall=0.85 --fail-under mrr=0.7
As a library
from ragcheck import load_cases, run, HttpRetriever
result = run(load_cases("questions.jsonl"), HttpRetriever("http://localhost:8000/search"), k=5)
print(result.summary) # {'recall@5': 0.87, 'mrr': 0.74, 'latency_p95_ms': 412.0, ...}
for case in result.cases:
if case.missed:
print(case.query, "missed", case.missed)
Metrics, briefly
| Metric | Meaning |
|---|---|
| recall@k | Share of the relevant documents that appear in the top k |
| precision@k | Share of the top k that is relevant |
| hit@k | Share of questions with at least one relevant document in the top k |
| MRR | Average of 1 / rank of the first relevant document; rewards putting the right doc first |
| nDCG@k | Rank-aware quality, 1.0 = all relevant docs at the very top |
Need help with the numbers?
I offer a fixed-price RAG Audit: I build your evaluation set, find why retrieval misses, and fix it with before/after numbers. Contact: nada.boulaares@gmail.com
License
MIT
Metadata
Release files for retrievalcheck 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| retrievalcheck-0.2.0.tar.gz | 22.3 kB | With provenance | Details for retrievalcheck-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| retrievalcheck-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for retrievalcheck-0.2.0-py3-none-any.whl |
Total release size: 40.0 kB
Release files / retrievalcheck-0.2.0.tar.gz
| Download URL | retrievalcheck-0.2.0.tar.gz |
|---|---|
| Size | 22.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
464cf295b8504effd6f652b12d97186d19d51e72b4cca4b101418b98ca9b55b1
|
|
BLAKE2b-256 checksum How to use checksums |
76ebdb722c25472477cc1546f3b888b93a2fa9d67921eebf746d67ca96fee6ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / retrievalcheck-0.2.0-py3-none-any.whl
| Download URL | retrievalcheck-0.2.0-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c73d6fc8a6d3b6ea3049a09185ee29a37628539bf650915d41fd5c68f1891a0
|
|
BLAKE2b-256 checksum How to use checksums |
9861b7abdd4acbaa6cbcae8b848e5d69521be8f501e9b0d98f4d7b4f58ee934d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logSecurity for retrievalcheck 0.2.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for retrievalcheck-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logA 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.