Velocirag

io.github.HaseebKhalid1507由 GitHub 账号 HaseebKhalid1507 发布v0.7.4更新于 Oct 24, 2026

Lightning-fast RAG for AI agents. 4-layer fusion, ONNX Runtime, sub-200ms search.

概览

AI 生成的概览

VelociRAG 让助手在本地对自有文档建立检索增强索引,并提供四层融合搜索与索引工具。

可以做什么
VelociRAG 在本地运行 RAG 引擎,并通过 MCP 暴露五个工具:search、index、add_document、health 和 list_sources。搜索通过倒数排名融合把向量相似度(FAISS)、BM25 关键词匹配(SQLite FTS5)、知识图谱遍历和元数据过滤合并,再用交叉编码器重排。索引是增量的,只重新处理变更文件,删除的文件会在各存储间级联清理。全部在本地 ONNX Runtime 上运行,无需 GPU 或 API 密钥。
适用场景
适合让助手基于本机上的私有文档集合回答问题,尤其是希望在一次查询中同时获得精确关键词匹配、概念匹配和元数据过滤的场景。也适合本地、离线、仅用 CPU 的环境,不希望把文档发送给外部嵌入或搜索服务。
运行要求
需要本地 Python 环境:安装 velocirag 这个 PyPI 包,MCP 服务器还需安装 mcp 附加组件。文档需先建立索引(例如使用 velocirag index 命令)。数据库目录由 VELOCIRAG_DB 环境变量或 --db 参数指定。模型在首次使用时下载,因此初次运行需要网络访问。仅支持桌面端;未声明身份验证。
安装前请注意
index 和 add_document 工具会写入本地数据库目录,索引在源文件变化时可能重建或级联删除条目,请指向你愿意被修改的数据库路径。可选的 NER 附加组件会引入 PyTorch,full-graph 选项据文档说明会额外占用约 2GB 内存。文档默认在本地处理,但首次运行会从互联网下载模型。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Velocirag,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

🦖 VelociRAG

Lightning-fast RAG for AI agents.

Four-layer retrieval fusion powered by ONNX Runtime. No PyTorch. Sub-200ms warm search. Incremental graph updates. MCP-ready.


Most RAG solutions either drag in 2GB+ of PyTorch or limit you to single-layer vector search. VelociRAG gives you four retrieval methods — vector similarity, BM25 keyword matching, knowledge graph traversal, and metadata filtering — fused through reciprocal rank fusion with cross-encoder reranking. All running on ONNX Runtime, no GPU, no API keys. Comes with an MCP server for agent integration, a Unix socket daemon for warm queries, and a CLI that just works.

🚀 Quick Start

MCP Server (Claude, Cursor, Windsurf)

bash
pip install "velocirag[mcp]"velocirag index ./my-docsvelocirag mcp

Claude Code — add to .mcp.json in your project root:

json
{  "mcpServers": {    "velocirag": {      "command": "velocirag",      "args": ["mcp"],      "env": { "VELOCIRAG_DB": "/path/to/data" }    }  }}

Then open /mcp in Claude Code and enable the velocirag server. If using a virtualenv, use the full path to the binary (e.g. .venv/bin/velocirag).

Claude Desktop — add to claude_desktop_config.json:

json
{  "mcpServers": {    "velocirag": {      "command": "velocirag",      "args": ["mcp", "--db", "/path/to/data"]    }  }}

Cursor — add to .cursor/mcp.json:

json
{  "mcpServers": {    "velocirag": {      "command": "velocirag",      "args": ["mcp", "--db", "/path/to/data"]    }  }}

Python API

python
from velocirag import Embedder, VectorStore, Searcher
embedder = Embedder()store = VectorStore('./my-db', embedder)store.add_directory('./my-docs')searcher = Searcher(store, embedder)results = searcher.search('query', limit=5)

CLI

bash
pip install velociragvelocirag index ./my-docsvelocirag search "your query here"

Search Daemon (warm engine for CLI users)

bash
velocirag serve --db ./my-data        # start daemon (background)velocirag search "query"              # auto-routes through daemonvelocirag status                      # check daemon healthvelocirag stop                        # stop daemon

The daemon keeps the ONNX model + FAISS index warm over a Unix socket. First query loads the engine (~1s), subsequent queries return in ~180ms with full 4-layer fusion.

🎯 Why VelociRAG?

  • 4-layer search — vector + BM25 keyword + knowledge graph + metadata, fused with RRF
  • No LLM needed — search runs entirely on local models (MiniLM + TinyBERT, ~80MB total)
  • No GPU needed — pure ONNX inference, runs on any machine
  • ~3ms warm search — daemon keeps models + indices warm over Unix socket
  • Incremental indexing — add files without rebuilding the whole index
  • MCP server — plug into Claude, Cursor, Windsurf, any MCP client

Related Projects

  • Memkoshi — Agent memory system. Uses VelociRAG as its search engine.
  • Stelline — Session intelligence. Crafts memories from conversation logs.
  • Glyph — MCP security scanner and runtime protection.

🏗️ How It Works

The 4-layer pipeline:

Query → expand (acronyms, variants)      → [Vector]   FAISS cosine similarity (384d, MiniLM-L6-v2 via ONNX)      → [Keyword]  BM25 via SQLite FTS5      → [Graph]    Knowledge graph traversal      → [Metadata] Structured SQL filters (tags, status, project)      → RRF Fusion → Cross-encoder rerank → Results

What each layer catches:

Query typeVectorKeywordGraphMetadata
Conceptual ("improve error handling")✅———
Exact match ("ERR_CONNECTION_REFUSED")—✅——
Connected concepts——✅—
Filtered ("#python status:active")———✅
Combined ("React state management")✅✅✅✅

✨ Features

  • ONNX Runtime — 184ms cold start, 3ms cached. No PyTorch, no GPU
  • Four-layer fusion — FAISS vector similarity + SQLite FTS5 (BM25) + knowledge graph + metadata filtering, merged via reciprocal rank fusion
  • Cross-encoder reranking — TinyBERT reranker via ONNX Runtime — included in base install, no PyTorch needed. Downloads ~17MB model on first use
  • Incremental graph updates — file-centric provenance tracking detects what changed and only rebuilds affected nodes/edges. Cascading deletes maintain consistency across all stores (vector, graph, metadata). Multi-source support with isolated provenance per source
  • MCP server — Five tools (search, index, add_document, health, list_sources) for Claude, Cursor, Windsurf
  • Search daemon — Unix socket server keeps ONNX model + FAISS index warm between queries
  • Knowledge graph — Analyzers build entity, temporal, topic, and explicit-link edges from markdown. Optional GLiNER NER. 418 files in 2.1s
  • Smart chunking — Header-aware splitting preserves document structure and parent context
  • Query expansion — Acronym registry, casing/spacing variants, underscore-aware tokenization
  • Runs anywhere — CPU-only, 8GB RAM, no API keys, no external services

🤖 MCP Server

VelociRAG exposes a Model Context Protocol server for seamless agent integration:

Available tools:

  • search — 4-layer fusion search with reranking
  • index — Add documents to the knowledge base
  • add_document — Insert single document
  • health — System diagnostics
  • list_sources — Show indexed document sources

The MCP server process stays alive between queries, so models load once and every subsequent search is warm. Works with any MCP-compatible client.

🐍 Python API

Full 4-layer unified search:

python
from velocirag import (    Embedder, VectorStore, Searcher,    GraphStore, MetadataStore, UnifiedSearch,    GraphPipeline)
# Build the full stackembedder = Embedder()store = VectorStore('./search-db', embedder)graph_store = GraphStore('./search-db/graph.db')metadata_store = MetadataStore('./search-db/metadata.db')
# Index with graph + metadatastore.add_directory('./docs')pipeline = GraphPipeline(graph_store, embedder, metadata_store)pipeline.build('./docs', source_name='my-docs')
# Unified search across all layerssearcher = Searcher(store, embedder)unified = UnifiedSearch(searcher, graph_store, metadata_store)results = unified.search(    'machine learning algorithms',    limit=5,    enrich_graph=True,    filters={'tags': ['python'], 'status': 'active'})

Quick semantic search:

python
from velocirag import Embedder, VectorStore, Searcher
embedder = Embedder()store = VectorStore('./db', embedder)store.add_directory('./docs')searcher = Searcher(store, embedder)results = searcher.search('neural networks', limit=10)

Incremental graph updates:

python
from velocirag import Embedder, GraphStore, GraphPipeline
# First run — full build, populates provenancegs = GraphStore('./db/graph.db')pipeline = GraphPipeline(gs, embedder=Embedder())pipeline.build('./docs', source_name='my-docs')  # full build
# Subsequent runs — only changed files get reprocessedpipeline.build('./docs', source_name='my-docs')  # incremental (automatic)
# Force full rebuildpipeline.build('./docs', source_name='my-docs', force_rebuild=True)
# Multi-source graphspipeline.build('./project-a', source_name='project-a')pipeline.build('./project-b', source_name='project-b')  # isolated provenance
# Deleted files automatically cascade across all stores# (vector, FTS5, graph, metadata) on next build

💻 CLI Reference

bash
# Index documents (graph + metadata built by default)velocirag index <path> [--no-graph] [--no-metadata] [--gliner] [--full-graph] [--force]                       [--source NAME] [--db PATH]
# Search across all layers (auto-routes through daemon if running)velocirag search <query> [--limit N] [--threshold F] [--format text|json]
# Search daemonvelocirag serve [--db PATH] [-f]         # start daemon (-f for foreground)velocirag stop                            # stop daemonvelocirag status                          # check daemon health
# Metadata queriesvelocirag query [--tags TAG] [--status S] [--project P] [--recent N]
# System health and statusvelocirag health [--format text|json]
# Start MCP servervelocirag mcp [--db PATH] [--transport stdio|sse]

Options:

  • --no-graph — Skip knowledge graph build
  • --no-metadata — Skip metadata extraction
  • --full-graph — Build graph WITH semantic similarity edges (~2GB extra RAM)
  • --source NAME — Label for multi-source provenance isolation
  • --force — Clear and rebuild from scratch
  • --gliner — Use GLiNER for entity extraction (requires pip install "velocirag[ner]")

📊 Performance

Real benchmarks on ByteByteGo/system-design-101 (418 files, 1,001 chunks):

MetricValue
Index (418 files)13.6s
Search (warm, 5 results)35–90ms
Graph build (light)2.1s → 2,397 nodes, 8,717 edges
Incremental update (1 file)1.3s
RerankerCross-encoder TinyBERT via ONNX
Install size~80MB (no PyTorch)
RAM usage<1GB with all models loaded

Production deployment (6,300+ chunks, 3 sources, 950 files):

MetricValue
Full search (warm)16ms avg, 2ms min
Full search (first run)22ms avg, 4ms min
Search P50 / P9517ms / 55ms
Hit rate (100-query benchmark)99/100
Graph3,125 nodes, 132,320 edges
RerankerCross-encoder TinyBERT via ONNX
RAM<1GB with all models loaded

⚙️ Configuration

Environment VariableDefaultDescription
VELOCIRAG_DB./.velociragDatabase directory
VELOCIRAG_SOCKET/tmp/velocirag-daemon.sockDaemon socket path
NO_COLOR—Disable colored output

Dependencies (all included in base install):

  • onnxruntime — ONNX inference (embedder + reranker)
  • tokenizers + huggingface-hub — model loading
  • faiss-cpu — vector similarity search
  • networkx + scikit-learn — knowledge graph + topic clustering
  • numpy, click, pyyaml, python-frontmatter

Optional extras:

  • pip install "velocirag[mcp]" — MCP server (adds fastmcp)
  • pip install "velocirag[ner]" — GLiNER entity extraction (adds gliner, requires PyTorch)

📚 References

VelociRAG builds on these foundational works:

Core Fusion & Retrieval

Reciprocal Rank Fusion — Cormack, G. V., Clarke, C. L. A., & Büttcher, S. (2009). "Reciprocal Rank Fusion outperforms Condorcet and individual Rank Learning Methods." SIGIR '09.
Core fusion algorithm for merging results across retrieval layers.

BM25 — Robertson, S. E., Walker, S., Jones, S., Hancock-Beaulieu, M., & Gatford, M. (1994). "Okapi at TREC-3." TREC-3.
Keyword search foundation via SQLite FTS5.

Embeddings & Neural IR

Sentence-BERT — Reimers, N., & Gurevych, I. (2019). "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks." EMNLP 2019. paper
Dense embedding architecture using all-MiniLM-L6-v2.

MiniLM — Wang, W., Wei, F., Dong, L., Bao, H., Yang, N., & Zhou, M. (2020). "MiniLM: Deep Self-Attention Distillation for Task-Agnostic Compression of Pre-Trained Transformers." NeurIPS 2020. paper
Efficient transformer distillation for production embedding models.

Reranking & Neural Models

Cross-Encoder Reranking — Nogueira, R., & Cho, K. (2019). "Passage Re-ranking with BERT." arXiv:1901.04085. paper
Cross-attention reranking with TinyBERT on MS MARCO.

TinyBERT — Jiao, X., et al. (2020). "TinyBERT: Distilling BERT for Natural Language Understanding." Findings of EMNLP 2020. paper
Compressed BERT for fast reranking inference.

Vector Search & Systems

FAISS — Johnson, J., Douze, M., & Jégou, H. (2019). "Billion-scale similarity search with GPUs." IEEE Transactions on Big Data. paper
High-performance vector similarity search engine.

GLiNER — Zaratiana, U., Nzeyimana, A., & Holat, P. (2023). "GLiNER: Generalist Model for Named Entity Recognition using Bidirectional Transformer." arXiv:2311.08526. paper
Generalist NER for knowledge graph entity extraction (optional dependency).

📄 License

MIT — Use it anywhere, build anything.

Need agent integration help? Check AGENTS.md for machine-readable project context.


Built for agents who think fast and remember faster.

来源:README.md,提交 261084a

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

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

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分