Token导航 LogoToken导航TokenDH.com
Nova Rag Benchmark logo
搜索检索stdio官方级别未说明来源级核验

Nova Rag Benchmark

MCP Server

rag-bench是一个用于测量代码检索增强生成(RAG)服务器性能的基准测试工具,支持多种查询类型和A/B对比测试。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
Python开发工具搜索

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Miro96

提供方

Miro96

最后核验

2026/5/17 20:21

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python3 -m venv .venv

详细介绍

抹布长凳

代码RAG MCP服务器基准测试 --衡量RAG如何帮助AI找到正确的代码。

没有现有基准涵盖以下交叉点 代码搜索+MCP协议+A/B比较抹布长凳填补了这个空白。

它衡量什么

ragbench索引真实的开源存储库(Flask、FastAPI、Express),并运行105个已知正确答案的代码搜索查询。它衡量:

度量它告诉你什么
Hit@1 / Hit@5RAG在顶部结果中找到了正确的文件吗?
符号Hit@5它是否找到了正确的函数/类?
平均倒数排名第一个正确结果的排名有多高?
潜伏期p50/p95查询速度有多快?
摄入速度索引代码库的速度有多快?
RAM/索引大小资源消耗
综合得分所有指标的加权组合

查询类型

  • locate --“X在哪里定义?”(最常见的开发人员问题)
  • callers --“什么叫X?”
  • explain --“X是如何工作的?”(需要多个相关文件)
  • impact --“如果我改变X,会发生什么?”
  • multi_hop --“通过多个文件跟踪X到Y”(传递性推理)
  • cross_package --“模块A如何与模块B交互?”
  • architecture --“项目的结构和层次是怎样的?”
  • dead_code --“函数X真的在任何地方被调用吗?”
  • conditional_path --“当条件C为真时,存在哪些代码路径?”
  • test_traceability --“哪些测试涵盖了函数X?”

A/B模式

比较RAG与grep/glob基线,以衡量RAG提供的实际改善:

  • 工具调用减少了多少?
  • 找到正确的代码要快多少?
  • RAG真的有帮助吗?或者grep足够吗?

快速开始

# Clone
git clone https://github.com/Miro96/nova-rag-benchmark.git
cd nova-rag-benchmark

# Install
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

# Run benchmark on your RAG MCP server
rag-bench run --command "python -m your_server" --transport stdio

# Or use a preset
rag-bench run --preset mcp-local-rag

# Run tests (325 tests)
pytest tests/ -v

用法

对单个服务器进行基准测试

# With a preset
rag-bench run --preset nova-rag

# With a custom command
rag-bench run --command "npx -y mcp-local-rag" --transport stdio

# With a config file
rag-bench run --config my-server.json

# Only test on one repo
rag-bench run --preset nova-rag --repo flask

# A/B comparison vs grep baseline
rag-bench run --preset nova-rag --ab-baseline

比较多台服务器

rag-bench compare --presets nova-rag,mcp-local-rag,chroma-mcp

运输方式

rag bench支持三种客户端传输模式 BaseClient 接口:

模式标志描述
MCP 标准--transport stdioJSON-RPC通过子进程stdin/stdout(默认)
CLI子流程--transport cli带有CLI参数的子进程,stdout捕获
过程中的--transport inprocess直接导入Python(仅预设)
# MCP stdio (default)
rag-bench run --command "python -m my_server" --transport stdio

# CLI subprocess
rag-bench run --command "my-rag search" --transport cli

# In-process (requires Python module)
rag-bench run --preset naive-rag --transport inprocess

排行榜

# Start the web leaderboard
rag-bench serve --port 8080

# Submit results
rag-bench submit results/run_*.json \
  --git-url https://github.com/you/your-rag \
  --git-user yourusername \
  --server-url http://localhost:8080

打开 http://localhost:8080 查看带有排序、过滤和雷达图比较的排行榜。

服务器配置格式

为RAG MCP服务器创建JSON配置:

{
  "name": "my-rag-server",
  "git_url": "https://github.com/you/my-rag",
  "command": "python -m my_rag.server",
  "transport": "stdio",
  "tool_mapping": {
    "ingest": {
      "tool": "index_directory",
      "params": { "path": "{path}" }
    },
    "query": {
      "tool": "search",
      "params": { "query": "{query}", "limit": "{top_k}" }
    }
  }
}

如果 tool_mapping 如果省略,rag bench将通过分析来自的工具名称和模式来自动检测工具 tools/list.

预摄取命令

您可以通过以下方式声明在索引之前运行shell命令 pre_ingest 现场。使用 {repo_path} 作为存储库目录的模板变量,以及 {cwd} 对于基准时间的工作目录:

{
  "name": "my-rag-server",
  "pre_ingest": [
    "pip install -r {repo_path}/requirements.txt",
    "cd {repo_path} && npm install"
  ]
}

索引目录

预设配置可以声明要索引的目录(默认为repo根目录):

{
  "name": "my-rag-server",
  "index_directories": ["src/", "lib/"]
}

默认情况下,所有未被忽略的文件都会被索引; index_directories 限制对特定子目录的索引。

内置预设

预设服务器描述
nova-rag诺瓦拉格混合语义+图形+关键字RAG
naive-rag仅嵌入基线原始嵌入相似性(无代码图)
cocoindex-codeCocoIndex v0.2.33CocoIndex代码检索预设
grep-glob关键字基线纯grep/glob关键字搜索(无嵌入)
mcp-local-ragmcp本地抹布MCP本地RAG服务器
chroma-mcp色度mcpChroma矢量数据库MCP服务器

比较结果(105个查询,3个重复)

Flask+FastAPI+Express上所有内置预设的四向比较:

rag-bench compare --presets nova-rag,naive-rag,cocoindex-code,grep-glob --replicates 3
度量nova-ragnaive ragcocoindex代码grep-glob
Hit@120.0%1.9%4.8%20.0%
Hit@545.7%6.7%16.2%55.2%
Hit@1053.3%7.6%23.8%74.3%
符号Hit@533.3%13.3%0.0%0.0%
平均倒数排名0.3150.0370.0990.340
延迟p5014.6毫秒3.5毫秒447.1毫秒22.3毫秒
延迟p9524.4毫秒4.0毫秒573.5毫秒90.6毫秒
摄入速度2675 f/s206 f/s----
综合得分0.5500.3640.3270.523

关键要点:

  • 诺瓦拉格 是解析符号的唯一预设(33.3%符号Hit@5)--grep/glob和仅嵌入的方法无法识别函数/类名。
  • grep glob 在原始文件召回中获胜(55.2%Hit@5)但不返回符号级结果。
  • 天真的破布 (仅嵌入)在文件召回方面表现最差(6.7%)Hit@5),表明仅凭语义相似性不足以进行代码搜索。
  • cocoindex代码 具有高延迟(~450ms p50),而其他方法的延迟低于25ms。
  • 诺瓦拉格 索引速度比原始rag快13倍(2675比206文件/秒)。

再现性:所有预设在3个重复的复合评分中的CV均小于0.05。

数据集

3个真正的开源存储库,105个查询包含基本事实:

存储库语言大小查询
烧瓶Python约15K LOC35
快速APIPython约40K LOC35
快速JavaScript约15K LOC35

每个查询都有:

  • 预期文件(地面实况)
  • 预期符号(函数/类名)
  • 难度级别(易/中/难)
  • 查询类型(定位/调用者/解释/影响/多操作/交叉包/架构/死代码/条件路径/测试跟踪性)

指标

综合得分公式

Score = 0.30 * Hit@5
      + 0.15 * SymbolHit@5
      + 0.15 * MRR
      + 0.15 * ToolCallEfficiency
      + 0.15 * LatencyScore
      + 0.10 * ResourceScore

建筑

rag_bench/
├── cli.py              # CLI entry point (click)
├── transport/          # Client transport layer
│   ├── base.py         # BaseClient interface
│   ├── mcp_client.py   # MCP JSON-RPC client (stdio)
│   ├── cli_client.py   # Subprocess CLI client
│   └── in_process.py   # In-process (Python import) client
├── adapter.py          # Normalizes different RAG server interfaces
├── runner.py           # Orchestrates: ingest → warmup → benchmark → metrics
├── metrics.py          # Hit@K, MRR, latency percentiles, composite score
├── baseline.py         # Grep/Glob baseline for A/B comparison
├── report.py           # Rich terminal tables
├── submit.py           # HTTP submit to leaderboard
├── presets/            # JSON configs for known servers
└── datasets/           # Repos + 105 queries with ground truth

server/
├── app.py              # FastAPI leaderboard server
├── db.py               # SQLite storage
├── models.py           # Pydantic models
└── static/             # Leaderboard web UI

贡献

  1. 添加查询 --更多的查询提高了基准测试的可靠性。添加 rag_bench/datasets/queries/
  2. 添加预设 --中新RAG MCP服务器的配置文件 rag_bench/presets/
  3. 添加仓库 --中的新测试存储库 rag_bench/datasets/repos.json
  4. 提交结果 --运行基准测试并提交到公共排行榜

为什么存在

现有的基准测试不包括RAG+MCP+代码搜索交集:

CodeRAG工作台GrepRAGMCP工作台抹布长凳
代码RAG
MCP协议
A/B:RAG与无RAG部分
自定义仓库
排行榜拥抱脸自托管

许可证

麻省理工学院

目录标签

目录标签

Python开发工具搜索代码检索本地部署性能评估RAG基准测试

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP