跳到主要内容
知仓学习社ZHICANG

rag-evaluation-harness

Evaluate retrieval and citation behavior for RAG pipelines from deterministic JSONL fixtures. Use when an agent needs offline Recall@K, reciprocal r…

执行命令读文件写文件严重 0 · 高危 1davepoon/buildwithclaude

它会碰到什么

扫了多少3 个文本文件,17 KB
它会碰到什么执行命令读文件写文件
命中总数8 处
命中统计严重 0 · 高 1 · 中 7 · 低 0
逐条看命中(1 条严重或高危)
  • scripts/evaluate-rag.test.mjs:6exec-spawn
    import { spawn } from 'node:child_process'

这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。

技能内容

RAG Evaluation Harness

Use this skill to measure a retrieval-and-citation contract without making model calls or network requests. The bundled evaluator compares explicit document IDs, so it is suitable for repeatable local checks and CI gates.

Input Contract

Provide one JSON object per line with a unique string id and three arrays of document IDs:

{"id":"question-1","relevant_document_ids":["doc-a"],"retrieved_document_ids":["doc-b","doc-a"],"cited_document_ids":["doc-a"]}

Blank lines are ignored. Invalid JSON, missing arrays, non-string IDs, and duplicate case IDs fail with the JSONL line number. Keep the fixture's relevance labels and citation IDs explicit; do not infer them from answer text.

Run an Evaluation

Set the installed skill directory and run the standard-library-only evaluator:

SKILL_DIR="<absolute path to the installed rag-evaluation-harness skill>"
node "$SKILL_DIR/scripts/evaluate-rag.mjs" "$SKILL_DIR/examples/sample-evaluation.jsonl" \\
  --k 3 --format markdown

Use --format json for CI or downstream tooling. Add any of these optional thresholds (each must be between 0 and 1):

--min-recall
--min-mrr
--min-context-precision
--min-citation-coverage
--min-citation-validity

The process exits 0 when all requested thresholds pass, 1 when a threshold fails, and 2 for invalid arguments or input. Threshold failures are written to stderr while the complete report remains on stdout.

Interpret the Report

  • Recall@K: relevant IDs found in the first K unique retrieved IDs divided by all relevant IDs.
  • Reciprocal rank: inverse rank of the first relevant retrieved ID, or zero when none is found.
  • Context precision@K: relevant IDs in the first K unique retrieved IDs divided by the number of retrieved IDs considered.
  • Citation coverage: relevant IDs cited divided by all relevant IDs.
  • Citation validity: cited IDs that were retrieved divided by all cited IDs.

The summary is a macro average. Recall and citation coverage are null for cases with no relevant IDs and are excluded from their macro denominators. Other empty denominators are reported as zero. Diagnostics call out empty retrieval, absent relevance labels, duplicate retrieved IDs, citations that were not retrieved, and missing citations.

These are ID-level proxy metrics. They do not establish semantic answer quality, entailment, attribution correctness, or groundedness. Pair them with a separate answer-quality evaluation when those properties matter.

Verification

Run the focused tests and the repository skill validator:

node --test "$SKILL_DIR/scripts/evaluate-rag.test.mjs"
node scripts/validate-skills.js

The evaluator is deterministic and offline. It reads only the supplied JSONL file and never executes retrieved content, calls an MCP server, accesses credentials, or mutates the input.

想直接用这个技能?

本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。

它属于哪个仓库

星标★ 3,470
本站分层T1
该仓技能数381
原文件路径plugins/all-skills/skills/rag-evaluation-harness/SKILL.md

同一个仓库里的其他技能

看这个仓库的全部 381 个技能