Memory

rag-eval

Try it

Score a RAG answer against its retrieved contexts with Ragas metrics and a configurable judge.

What it does

Evaluates a single RAG answer or a JSONL batch by feeding question, answer, and retrieved contexts to a Ragas-based scorer. Pick OpenAI, Anthropic, or a local Ollama judge via environment variables; raw inputs stay on disk only when --save is passed. Returns faithfulness, answer_relevancy, context_precision, an overall score, and a PASS/REVIEW/FAIL verdict against fixed thresholds.

When to use it

  • Spot-checking a single response before shipping a RAG change
  • Auditing a JSONL of past RAG traces in batch
  • Comparing retrieval quality after changing chunking or embeddings
  • Investigating low-faithfulness answers with sentence-level explanations

The skill document

RAG Eval — Quality Testing for Your RAG Pipeline

Test and monitor your RAG pipeline's output quality.

🛠️ Installation

Tell OpenClaw: "Install @jonathanjing/rag-eval."

2. Manual Installation (CLI)

If you prefer the terminal, run:

openclaw skills install @jonathanjing/rag-eval

⚠️ Prerequisites

  1. Your OpenClaw must have a RAG system (vector DB + retrieval pipeline). This skill evaluates the output quality of that pipeline — it does not provide RAG functionality itself.
  2. Configure one judge:
    • OPENAI_API_KEY (default, uses GPT-4o)
    • ANTHROPIC_API_KEY (uses Claude Haiku)
    • RAGAS_LLM=ollama/llama3 (for local/offline evaluation)

For a cloud judge, also set RAGAS_ALLOW_CLOUD=1 after confirming the input may leave the machine.

Setup (first run only)

bash "{baseDir}/scripts/setup.sh"

This script intentionally refuses global installation. Activate a virtual environment first, then run it.

Single Response Evaluation

When user asks to evaluate an answer, collect:

  1. question — the original user question
  2. answer — the LLM output to evaluate
  3. contexts — list of text chunks used to generate the answer (retrieved docs)

⚠️ SECURITY: Never interpolate user content directly into shell commands. Write the input to a temp JSON file first, then pipe it to the evaluator:

# Step 1: Write input to a temp file (agent should use the write/edit tool, NOT echo)
# Write this JSON to /tmp/rag-eval-input.json using the file write tool:
# {"question": "...", "answer": "...", "contexts": ["chunk1", "chunk2"]}

# Step 2: Run the evaluator. Raw content is not saved by default.
python3 "{baseDir}/scripts/run_eval.py" --input-file /tmp/rag-eval-input.json

# Step 3: Delete the temporary input with the available file tool.

Alternatively, use --input-file:

python3 "{baseDir}/scripts/run_eval.py" --input-file /tmp/rag-eval-input.json

Output JSON:

{
  "faithfulness": 0.92,
  "answer_relevancy": 0.87,
  "context_precision": 0.79,
  "overall_score": 0.86,
  "verdict": "PASS",
  "flags": []
}

Post results to user with human-readable summary:

🧪 Eval Results
• Faithfulness: 0.92 ✅ (no hallucination detected)
• Answer Relevancy: 0.87 ✅
• Context Precision: 0.79 ⚠️ (some irrelevant context retrieved)
• Overall: 0.86 — PASS

Persist only when the user explicitly requests it by adding --save. The saved record contains the raw question, answer, and contexts.

Batch Evaluation

For a JSONL dataset file (each line: {"question":..., "answer":..., "contexts":[...]}):

python3 "{baseDir}/scripts/batch_eval.py" --input ./dataset.jsonl --output ./batch-eval.json

Score Interpretation

ScoreVerdictMeaning
0.85+✅ PASSProduction-ready quality
0.70-0.84⚠️ REVIEWNeeds improvement
< 0.70❌ FAILSignificant quality issues

Faithfulness Deep-Dive

If faithfulness < 0.80, run:

python3 "{baseDir}/scripts/run_eval.py" --explain --metric faithfulness

This outputs which sentences in the answer are NOT supported by context.

Notes

  • OpenAI and Anthropic judges transmit the question, answer, and contexts to that provider. Obtain explicit approval for confidential data or use a local RAGAS_LLM.
  • The evaluator does not persist raw inputs by default.
  • Evaluation costs ~$0.01-0.05 per response depending on length
  • For offline use, set RAGAS_LLM=ollama/llama3 in environment

Questions people ask

Does it run the RAG pipeline itself?
No. It evaluates output from an existing RAG system; you provide the question, answer, and retrieved contexts.
Where do inputs go?
They stay on the local machine by default. Cloud judges (OpenAI, Anthropic) transmit the question, answer, and contexts to that provider, so set RAGAS_LLM=ollama/llama3 for fully offline runs.
Does it save my data?
Only if you pass --save. Otherwise the temporary input file should be deleted after the run.

Related skills

Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.

by Iván559 installs18 stars

Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.

by johnpatternai22 installs8 stars

Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.

by Iván855 installs69 stars

Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.

by nssa.io1.0k installs47 stars

Fetch raw ad creative, app, ranking, and revenue data from AdMapix as structured JSON.

by fly0pants4.3k installs296 stars

Run Git operations — commits, branches, merges, rebases, conflict resolution, and recovery — with safety rules enforced.

by Iván535 installs31 stars

More from Jonathan Jing

Browse all skills

Use when a user asks to build, optimize, backtest, rebalance, or analyze a stock portfolio with Mean-CVaR, Mean-Variance/SOCP variance caps, efficient frontiers, scenario generation, or NVIDIA cuOpt.

by Tang Weigang

Write and migrate code with DALI's imperative API

by nvidia3 installs

Host setup for TAO GPU backends. Checks and, after user approval, installs minimum-compatible NVIDIA driver, CUDA Toolkit, and NVIDIA Container Toolkit versions for Docker/local-Docker and Kubernetes GPU worker hosts. TAO-wide defaults can be overridden by the selected model's runtime profile. The `--check-only` path works on any Linux distribution; `--install` automates debian-family (Ubuntu/Debian/Pop!_OS/Mint/Zorin/Raspbian), rhel-family (Fedora/RHEL/Rocky/AlmaLinux), and suse-family (openSUSE/SLES) hosts, and prints actionable manual-install steps for everything else. Use when the user asks to "set up an NVIDIA GPU host", "check TAO Docker GPU runtime", or prepare a Kubernetes GPU worker for TAO.

by nvidia1 installs1 stars

LP, MILP, QP — concepts, problem-text parsing, and formulation patterns (parameters, constraints, decisions, objective). Concepts only; no API.

by nvidia2 installs

Vehicle routing (VRP, TSP, PDP) with cuOpt — Python API only. Use when the user is building or solving routing in Python.

by nvidia2 installs

Guide for selecting and configuring distributed training strategies in NeMo AutoModel, including FSDP2, Megatron FSDP, DDP, and parallelism settings.

by nvidia2 installs