RAGScore

io.github.HZYAI由 GitHub 帳號 HZYAI 發布v0.8.6更新於 Oct 24, 2026

Generate QA datasets & evaluate RAG systems with failure diagnosis. Any LLM.

已驗證STDIO僅桌面資料與分析AI 與機器學習

概覽

AI 產生的概覽

RAGScore 是本地 MCP 伺服器,可從文件產生問答資料集並評估 RAG 端點,給予評分並診斷失敗原因。

可以做什麼
從文件產生問答對,可依目標讀者與用途調整,輸出問題、答案、理由與支撐片段為 JSONL。以這些標準問答評估 RAG 端點,取得準確率、平均分數與錯誤問答清單。進行多指標詳細評分,涵蓋正確性、完整性、相關性、簡潔性與忠實度。診斷失敗類型,例如檢索遺漏、生成幻覺、回答不完整或理解錯誤。透過 Python API 以資料表檢視結果並繪製圖表。
適用情境
適合維護 RAG 或問答服務、希望用自有文件產生測試問題並穩定衡量回答品質的情境。也適合排查回答失敗的原因,或用本機模型對機密文件做私密評估。
執行需求
以 pip 安裝的 Python 套件在本機執行,MCP 模式透過 serve 指令啟動。需要 LLM:本機 Ollama(免金鑰)或雲端服務商,使用後者時需設定 OPENAI_API_KEY 或 ANTHROPIC_API_KEY。被評估的 RAG 系統需提供查詢端點。選用設定包括 RAGSCORE_CHUNK_SIZE、RAGSCORE_QUESTIONS_PER_CHUNK 與 RAGSCORE_WORK_DIR。
安裝前請注意
使用雲端模型時,文件文字片段會傳送給所選 LLM 服務商;只有本機 Ollama 能讓資料完全留在本機。僅在 MCP 伺服器模式下收集遙測,可用 RAGSCORE_NO_TELEMETRY 關閉。評估會向所設定的 RAG 端點送出問題,請只指向你有權測試的系統。API 金鑰從環境變數讀取。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 RAGScore,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[RAGScore Logo]

[PyPI version] [PyPI Downloads] [Python 3.9+] [License] [Ollama] [Open In Colab] [MCP]

Generate QA datasets & evaluate RAG systems in 2 commands

🔒 Privacy-First • ⚡ Lightning Fast • 🤖 Any LLM • 🏠 Local or Cloud • 🌍 Multilingual

English | 中文 | 日本語 | Deutsch


⚡ 2-Line RAG Evaluation

bash
# Step 1: Generate QA pairs from your docsragscore generate docs/
# Step 2: Evaluate your RAG systemragscore evaluate http://localhost:8000/query

That's it. Get accuracy scores and incorrect QA pairs instantly.

============================================================✅ EXCELLENT: 85/100 correct (85.0%)Average Score: 4.20/5.0============================================================
❌ 15 Incorrect Pairs:
  1. Q: "What is RAG?"     Score: 2/5 - Factually incorrect
  2. Q: "How does retrieval work?"     Score: 3/5 - Incomplete answer

🚀 Quick Start

Install

bash
pip install ragscore              # Core (works with Ollama)pip install "ragscore[openai]"    # + OpenAI supportpip install "ragscore[notebook]"  # + Jupyter/Colab supportpip install "ragscore[all]"       # + All providers

Already installed? Keep up to date — new versions add features like failure diagnosis and retrieved context capture:

bash
pip install --upgrade ragscore

Option 1: Python API (Notebook-Friendly)

Perfect for Jupyter, Colab, and rapid iteration. Get instant visualizations.

python
from ragscore import quick_test
# 1. Audit your RAG in one lineresult = quick_test(    endpoint="http://localhost:8000/query",  # Your RAG API    docs="docs/",                            # Your documents    n=10,                                    # Number of test questions)
# 1b. Tailored QA — target specific audiencesresult = quick_test(    endpoint="http://localhost:8000/query",    docs="docs/",    audience="developers",                   # Who asks the questions?    purpose="api-integration",               # What's the document for?)
# 2. See the reportresult.plot()
# 3. Inspect failuresbad_rows = result.df[result.df['score'] < 3]display(bad_rows[['question', 'rag_answer', 'reason']])

Rich Object API:

  • result.accuracy - Accuracy score
  • result.df - Pandas DataFrame of all results
  • result.plot() - 3-panel visualization (4-panel with detailed=True)
  • result.corrections - List of items to fix

Option 2: CLI (Production)

Generate QA Pairs

bash
# Set API key (or use local Ollama - no key needed!)export OPENAI_API_KEY="sk-..."
# Generate from any documentragscore generate paper.pdfragscore generate docs/*.pdf --concurrency 10
# Tailored QA generation — target specific audiencesragscore generate docs/ --audience developers --purpose faqragscore generate docs/ --audience customers --purpose "pre-sales"ragscore generate docs/ --audience "compliance auditors" --purpose "security audit"

Evaluate Your RAG

bash
# Point to your RAG endpointragscore evaluate http://localhost:8000/query
# Custom optionsragscore evaluate http://api/ask --model gpt-4o --output results.json

🔬 Detailed Multi-Metric Evaluation

Go beyond a single score. Add detailed=True to get 5 diagnostic dimensions per answer — in the same single LLM call.

python
result = quick_test(    endpoint=my_rag,    docs="docs/",    n=10,    detailed=True,  # ⭐ Enable multi-metric evaluation)
# Inspect per-question metricsdisplay(result.df[[    "question", "score", "correctness", "completeness",    "relevance", "conciseness", "faithfulness"]])
# Radar chart + 4-panel visualizationresult.plot()
==================================================✅ PASSED: 9/10 correct (90%)Average Score: 4.3/5.0Threshold: 70%──────────────────────────────────────────────────  Correctness: 4.5/5.0  Completeness: 4.2/5.0  Relevance: 4.8/5.0  Conciseness: 4.1/5.0  Faithfulness: 4.6/5.0==================================================
MetricWhat it measuresScale
CorrectnessSemantic match to golden answer5 = fully correct
CompletenessCovers all key points5 = fully covered
RelevanceAddresses the question asked5 = perfectly on-topic
ConcisenessFocused, no filler5 = concise and precise
FaithfulnessNo fabricated claims5 = fully faithful

CLI:

bash
ragscore evaluate http://localhost:8000/query --detailed

🔍 Failure Diagnosis (--diagnose)

When answers fail, --diagnose tells you why — retriever miss, generator hallucination, incomplete answer, or wrong interpretation:

bash
ragscore evaluate http://localhost:8000/query --diagnose
🔍 Failure Diagnosis:  Retriever Miss: 3 (42.9%)  Generator Hallucination: 2 (28.6%)  Incomplete Answer: 1 (14.3%)  Wrong Interpretation: 1 (14.3%)

Uses the support_span already generated with each QA pair to give the judge grounding context. Combine with --detailed for full diagnostics:

bash
ragscore evaluate http://localhost:8000/query --diagnose --detailed -o results.json
CategoryMeaning
Retriever MissRAG didn't retrieve the chunk containing the evidence
Generator HallucinationRetrieved correctly but fabricated information
Incomplete AnswerRetrieved correctly but answer is partial
Wrong InterpretationRetrieved correctly but misunderstood the content

📓 Full demo notebook — build a mini RAG and test it with detailed metrics.

🎯 Audience & Purpose demo — generate tailored QA for developers, customers, auditors, and more.

🏠 Ollama local demo — 100% private RAG evaluation with no API keys.


🏠 100% Private with Local LLMs

bash
# Use Ollama - no API keys, no cloud, 100% privateollama pull llama3.1ragscore generate confidential_docs/*.pdfragscore evaluate http://localhost:8000/query

Perfect for: Healthcare 🏥 • Legal ⚖️ • Finance 🏦 • Research 🔬

Ollama Model Recommendations

RAGScore generates complex structured QA pairs (question + answer + rationale + support span) in JSON format. This requires models with strong instruction-following and JSON output capabilities.

ModelSizeMin RAMQA QualityRecommended
llama3.1:70b40GB48GB VRAMExcellentGPU server (A100, L40)
qwen2.5:32b18GB24GB VRAMExcellentGPU server (A10, L20)
llama3.1:8b4.7GB8GB VRAMGoodBest local choice
qwen2.5:7b4.4GB8GB VRAMGoodGood local alternative
mistral:7b4.1GB8GB VRAMGoodGood local alternative
llama3.2:3b2.0GB4GB RAMFairCPU-only / testing
qwen2.5:1.5b1.0GB2GB RAMPoorNot recommended

Minimum recommended: 8B+ models. Smaller models (1.5B–3B) produce lower quality support spans and may timeout on longer chunks.

Ollama Performance Guide

bash
# Recommended: 8B model with concurrency 2 for local machinesollama pull llama3.1:8bragscore generate docs/ --provider ollama --model llama3.1:8b
# GPU server (A10/L20): larger model with higher concurrencyollama pull qwen2.5:32bragscore generate docs/ --provider ollama --model qwen2.5:32b --concurrency 5

Expected performance (28 chunks, 5 QA pairs per chunk):

HardwareModelTimeConcurrency
MacBook (CPU)llama3.2:3b~45 min2
MacBook (CPU)llama3.1:8b~25 min2
A10 (24GB)llama3.1:8b~3–5 min5
L20/L40 (48GB)qwen2.5:32b~3–5 min5
OpenAI APIgpt-4o-mini~2 min10

RAGScore auto-reduces concurrency to 2 for local Ollama to avoid GPU/CPU contention.


🔌 Supported LLMs

ProviderSetupNotes
Ollamaollama serveLocal, free, private
OpenAIexport OPENAI_API_KEY="sk-..."Best quality
Anthropicexport ANTHROPIC_API_KEY="..."Long context
DashScopeexport DASHSCOPE_API_KEY="..."Qwen models
vLLMexport LLM_BASE_URL="..."Production-grade
Any OpenAI-compatibleexport LLM_BASE_URL="..."Groq, Together, etc.

📊 Output Formats

Generated QA Pairs (output/generated_qas.jsonl)

json
{  "id": "abc123",  "question": "What is RAG?",  "answer": "RAG (Retrieval-Augmented Generation) combines...",  "rationale": "This is explicitly stated in the introduction...",  "support_span": "RAG systems retrieve relevant documents...",  "difficulty": "medium",  "source_path": "docs/rag_intro.pdf"}

Evaluation Results (--output results.json)

json
{  "summary": {    "total": 100,    "correct": 85,    "incorrect": 15,    "accuracy": 0.85,    "avg_score": 4.2  },  "incorrect_pairs": [    {      "question": "What is RAG?",      "golden_answer": "RAG combines retrieval with generation...",      "rag_answer": "RAG is a database system.",      "score": 2,      "reason": "Factually incorrect - RAG is not a database"    }  ]}

🧪 Python API

python
from ragscore import run_pipeline, run_evaluation
# Generate QA pairsrun_pipeline(paths=["docs/"], concurrency=10)
# Generate tailored QA pairs for specific audiencesrun_pipeline(    paths=["docs/"],    audience="support engineers",    purpose="fine-tuning a support chatbot",)
# Evaluate RAGresults = run_evaluation(    endpoint="http://localhost:8000/query",    model="gpt-4o",  # LLM for judging)print(f"Accuracy: {results.accuracy:.1%}")

🤖 AI Agent Integration

RAGScore is designed for AI agents and automation:

bash
# Structured CLI with predictable outputragscore generate docs/ --concurrency 5ragscore evaluate http://api/query --output results.json
# Exit codes: 0 = success, 1 = error# JSON output for programmatic parsing

CLI Reference:

CommandDescription
ragscore generate <paths>Generate QA pairs from documents
ragscore generate <paths> --audience <who>Tailored QA for specific audience
ragscore generate <paths> --purpose <why>Focus QA on document purpose
ragscore evaluate <endpoint>Evaluate RAG against golden QAs
ragscore evaluate <endpoint> --detailedMulti-metric evaluation
ragscore evaluate <endpoint> --diagnoseFailure root-cause classification
ragscore --helpShow all commands and options
ragscore generate --helpShow generate options
ragscore evaluate --helpShow evaluate options

⚙️ Configuration

Zero config required. Optional environment variables:

bash
export RAGSCORE_CHUNK_SIZE=512          # Chunk size for documentsexport RAGSCORE_QUESTIONS_PER_CHUNK=5   # QAs per chunkexport RAGSCORE_WORK_DIR=/path/to/dir   # Working directory

🔐 Privacy & Security

DataCloud LLMLocal LLM
Documents✅ Local✅ Local
Text chunks⚠️ Sent to LLM✅ Local
Generated QAs✅ Local✅ Local
Evaluation results✅ Local✅ Local

Compliance: GDPR ✅ • HIPAA ✅ (with local LLMs) • SOC 2 ✅


🧪 Development

bash
git clone https://github.com/HZYAI/RagScore.gitcd RagScorepip install -e ".[dev,all]"pytest

📡 Telemetry

RAGScore collects telemetry only in MCP server mode (ragscore serve). Standard CLI and Python API usage do not send telemetry.

We collect limited anonymous operational metrics to understand feature usage and improve reliability. No document content, prompts, QA text, model outputs, API keys, endpoint URLs, or file paths are collected.

Collected in MCP mode:

  • MCP tool invoked
  • LLM provider and model name
  • ragscore version, Python version, OS type
  • Success/failure status
  • Random anonymous installation ID

Opt out:

bash
export RAGSCORE_NO_TELEMETRY=1

�� Links


⭐ Star us on GitHub if RAGScore helps you!
Made with ❤️ for the RAG community

來源:README.md,提交 3fbc6e8

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.8.6最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分