Catalog / retrieval-metrics
Retrieval metrics (trec_eval): nDCG, MAP, MRR, recall@k
Scores how good a search or RAG ranking is against known relevant documents, the way the standard trec_eval tool does.
Benched Security-tested against the seller traps of our Agent Benchmark Exam.
Buy $1.00What it does
Scores a ranking against graded relevance judgments (qrels) as trec_eval 9.0.8 does: map, recip_rank (MRR), Rprec, ndcg, and at each k P_k, recall_k and ndcg_cut_k (gain = grade, discount log2(rank+1), ideal ranking from the qrels), plus num_rel_ret; per query and over all queries (trec_eval's 'all' line: means, with num_ret, num_rel and num_rel_ret as sums). Ranking: score descending, with scores compared as 32-bit floats as trec_eval stores them (23.456782 and 23.456781, or 16777217 and 16777216, are a tie), ties by docid descending in code point order, as trec_eval; scores beyond float32 range (about 3.4e38) compare as infinite, as in trec_eval. Run queries without judgments are skipped and listed; complete=true averages over every qrels query, counting those with no retrieved documents as 0 (trec_eval -c; all.num_rel then counts every grade above 0 regardless of relevance_level, as trec_eval does). Grades below relevance_level (default 1) are not relevant for map, MRR, Rprec, P and recall; ndcg and ndcg_cut use every grade above 0 as gain, as trec_eval does. qrels: JSON {qid:{docid:grade}} or TREC lines 'qid 0 docid grade' (integer grades; 1.0 reads as 1). run: JSON {qid:[{docid,score}]} or {qid:[docid,...]} best first, or TREC lines 'qid Q0 docid rank score tag' (the rank column is ignored, as in trec_eval). Chains after bm25-rank and rank-fusion: their rankings, written as a run, are scored here against the judgments. Limits: 50,000 characters per field, 1,000 queries, 2,000 run entries per query, 5,000 run lines or entries and 5,000 qrels lines or judgments (duplicates included). Deliberate differences from trec_eval, each listed in problems with trec_eval_equivalent then false: where trec_eval stops with an error (duplicate docids in a query, duplicate judgments, lines with the wrong number of fields, a scored query whose judgments are all negative), this tool keeps the higher-scored duplicate, keeps the first judgment, skips the line, and scores that query 0; trec_eval reads numbers leniently with atof and atol (score 1.5abc as 1.5, 0x10 as 16, inf, nan and 1e400 as they parse; grade 1.5 as 1), while this tool refuses any score that is not a finite decimal number (so 1.5abc, 0x10, inf, nan and 1e400 are skipped) and any grade that is not integer-valued; ids with control characters are skipped too. Repeated JSON keys keep the first, also reported. Values are rounded to 6 decimals.
- Example input
{"qrels":"q1 0 d1 2\nq1 0 d2 1\nq1 0 d3 0\nq2 0 d9 1","run":"q1 Q0 d3 1 9.1 bm25\nq1 Q0 d1 2 8.4 bm25\nq1 Q0 d7 3 7.0 bm25\nq1 Q0 d2 4 6.2 bm25\nq2 Q0 d9 1 3.3 bm25","k":"1,3,5"}- Answer
{"ok":true,"result":{"valid":true,"reason":null,"trec_eval_equivalent":true,"settings":{"k":[1,3,5],"relevance_level":1,"complete":false,"tie_rule":"score descending, compared as 32-bit floats, then docid descending by code point (trec_eval: float sim, then strcmp on docno)"},"queries":{"in_run":2,"in_qrels":2,"evaluated":2,"averaged_over":2,"run_only_count":0,"run_only":[],"qrels_only_count":0,"qrels_only":[],"empty_in_run":0},"all":{"map":0.75,"recip_rank":0.75,"Rprec":0.75,"ndcg":0.821661,"P_1":0.5,"P_3":0.333333,"P_5":0.3,"recall_1":0.5,"recall_3":0.75,"recall_5":1,"ndcg_cut_1":0.5,"ndcg_cut_3":0.739812,"ndcg_cut_5":0.821661,"num_ret":5,"num_rel":3,"num_rel_ret":3},"per_query_total":2,"per_query_offset":0,"per_query_returned":2,"per_query_truncated":false,"per_query":[{"qid":"q1","num_ret":4,"num_rel":2,"num_rel_ret":2,"map":0.5,"recip_rank":0.5,"Rprec":0.5,"ndcg":0.643322,"P_1":0,"P_3":0.333333,"P_5":0.4,"recall_1":0,"recall_3":0.5,"recall_5":1,"ndcg_cut_1":0,"ndcg_cut_3":0.479625,"ndcg_cut_5":0.643322},{"qid":"q2","num_ret":1,"num_rel":1,"num_rel_ret":1,"map":1,"recip_rank":1,"Rprec":1,"ndcg":1,"P_1":1,"P_3":0.333333,"P_5":0.2,"recall_1":1,"recall_3":1,"recall_5":1,"ndcg_cut_1":1,"ndcg_cut_3":1,"ndcg_cut_5":1}],"problem_count":0,"problem_counts":{},"problems_truncated":false,"problems":[],"standard":"trec_eval 9.0.8 (NIST): map, recip_rank, Rprec, ndcg, P, recall, ndcg_cut, num_rel_ret"},"warnings":[]}- Try it free
- /try/retrieval-metrics
Buy
Price $1.00, once. One buyer only: the first one owns the tool, we stop selling it and list your copy, and every paid call to it goes to your wallet. Comes with a licence: run it, change it and earn from it; the code itself is not passed on or resold.
- Pay with an x402 walletThe buy link is
https://forge.fizzl.eu/forge/packages/retrieval-metrics?format=zip. It answers with a payment request (HTTP 402) that an x402 wallet pays in USDC on Base. From Claude, ChatGPT or Grok with the Fizzl Agent Wallet: ask “buy https://forge.fizzl.eu/forge/packages/retrieval-metrics?format=zip”. From code:const pay = wrapFetchWithPayment(fetch, client); // see /llms.txt const zip = await pay("https://forge.fizzl.eu/forge/packages/retrieval-metrics?format=zip"); - Start it with your walletUnzip,
npm install, thenPAY_TO=0xYourWallet PUBLIC_URL=https://your-host npm starton any Node host. - We list it for youYour copy tells us where it runs; we check it and add it to the x402 Trust Index and the Bazaar under your wallet.
Bought it, and something is wrong?
Paste the receipt you got with the purchase (the X-Forge-Receipt token; a bundle receipt works too) and say what is wrong. Free. We pick it up within the hour; a real fault is fixed, passes the same checks, and you download the new version free at /forge/packages/retrieval-metrics/update with your receipt. No money back through this form.
Missing a tool?
Tell us in one sentence what it should do: what goes in, what comes out. Free, no wallet. Our agents read every suggestion and build the useful ones in the next shift. Want it for sure? Order it for $1.