Antfly分布式搜索引擎如何结合全文、向量与图搜索实现多模态检索?
AI Summary (BLUF)
Antfly is a distributed search engine that combines full-text search, vector similarity, and graph traversal over multimodal data (text, images, audio, video) with built-in RAG agents for retrieval-au
Antfly is a distributed search engine built on etcd's raft library. It combines full-text search (BM25), vector similarity, and graph traversal over multimodal data — text, images, audio, and video. Embeddings, chunking, and graph edges are generated automatically as you write data. Built-in RAG agents tie it all together with retrieval-augmented generation.
Antfly 是一个基于 etcd 的 raft 库 构建的分布式搜索引擎。它融合了全文搜索(BM25)、向量相似度和图遍历,支持对文本、图像、音频和视频等多模态数据进行检索。在写入数据时,系统会自动生成嵌入向量、文本分块和图关系边。内置的 RAG(检索增强生成)智能体通过检索增强生成技术将所有这些功能整合在一起。

快速开始
Quick Start
# Start a single-node cluster with built-in ML inference
go run ./cmd/antfly swarm
# Or run with Docker
docker run -p 8080:8080 ghcr.io/antflydb/antfly:omni
这将启动一个单节点集群,并内置机器学习推理功能。或者,你也可以使用 Docker 运行。启动后,你可以通过
http://localhost:8080访问 Antfarm 仪表盘,其中包含用于搜索、RAG、知识图谱、嵌入向量、重排序等多种功能的交互式演示。
有关完整指南,请参阅 快速入门指南。
核心特性
Features
Antfly 提供了一系列强大的功能,旨在构建现代化的搜索和 AI 应用。
| 特性 | 描述 | 关键点 |
|---|---|---|
| 混合搜索 | 在单一查询中同时支持全文(BM25)、稠密向量和稀疏向量(SPLADE)搜索。 | All in one query |
| RAG 智能体 | 内置检索增强生成,支持流式输出、多轮对话、工具调用(网络搜索、图遍历)和置信度评分。 | Streaming, tool calling |
| 图索引 | 自动关系提取,并支持对数据进行图遍历查询。 | Automatic extraction |
| 多模态 | 使用 CLIP、CLAP 和视觉语言模型对图像、音频和视频进行索引和搜索。 | Images, audio, video |
| 重排序 | 使用交叉编码器进行重排序,并通过基于分数的剪枝来减少噪声。 | Cross-encoder, pruning |
| 聚合分析 | 支持统计(求和/最小值/最大值/平均值)和词项分面分析。 | Stats & terms facets |
| 事务 | 在分片级别提供 ACID 事务,并支持分布式协调。 | ACID at shard level |
| 文档 TTL | 自动文档过期,无需手动清理。 | Automatic expiration |
| S3 存储 | 可将数据存储在 S3/MinIO/R2 中,以大幅降低成本并加速分片拆分。 | Cost savings, faster splits |
| SIMD/SME 加速 | 向量操作通过 go-highway 库在 x86 和 ARM 架构上使用硬件指令集进行加速。 | Hardware intrinsics |
| 分布式架构 | 基于 Raft 共识协议,支持自动分片、复制和水平扩展。 | Raft, auto-sharding |
| 数据增强管道 | 每个索引可配置独立的管道,用于生成嵌入向量、摘要、图边和自定义计算字段。 | Per-index pipelines |
| 模型集成 | 支持 Ollama、OpenAI、Bedrock、Google 等外部模型,或使用 Termite 本地运行模型。 | Bring your own models |
| 身份验证 | 内置用户管理,支持 API 密钥、基础认证和 Bearer Token。 | API keys, basic auth |
| 备份与恢复 | 支持备份到本地磁盘或 S3。 | Local disk or S3 |
| Kubernetes Operator | 通过 Operator 部署和管理集群。 | Deploy & manage clusters |
| MCP 服务器 | 支持 模型上下文协议,使 LLM 可以将 Antfly 作为工具使用。 | LLMs as a tool |
| A2A 协议 | 支持 Google 的 Agent-to-Agent 标准。 | Google's A2A standard |
| Antfarm 仪表盘 | 提供功能丰富的 Web 仪表盘,包含搜索、RAG、知识图谱、嵌入向量、重排序、分块、NER、OCR 和转录等交互式演示。 | Web dashboard with playgrounds |
文档与 SDK
Documentation & SDKs
完整的文档可在 antfly.io/docs 找到。
Antfly 为多种语言和平台提供了官方 SDK 和客户端库。
| 语言/平台 | 包/模块 | 源代码 |
|---|---|---|
| Go | github.com/antflydb/antfly/pkg/client |
pkg/client |
| TypeScript | @antfly/sdk |
ts/packages/sdk |
| Python | antfly |
py/ |
| React | @antfly/components |
ts/packages/components |
| PostgreSQL | pgaf extension |
rs/pgaf |
pgaf — PostgreSQL 扩展
pgaf — PostgreSQL Extension
pgaf 将 Antfly 的搜索能力引入到 PostgreSQL 中。创建一个索引,使用 @@@ 操作符,即可完成搜索。
pgaf brings Antfly search into Postgres. Create an index, use the
@@@operator, and you're done.
CREATE INDEX idx_content ON docs USING antfly (content)
WITH (url = 'http://localhost:8080/api/v1/', collection = 'my_docs');
SELECT * FROM docs WHERE content @@@ 'fix my computer';
React 组件
React Components
@antfly/components 提供了一系列开箱即用的 React 组件,用于构建搜索界面,包括 SearchBox、Autosuggest、Facet、Results、RAGBox、AnswerBox,以及流式钩子如 useAnswerStream 和 useCitations。
@antfly/componentsgives you drop-in React components for search UIs —SearchBox,Autosuggest,Facet,Results,RAGBox,AnswerBox, plus streaming hooks likeuseAnswerStreamanduseCitations.
Termite — 机器学习推理
Termite — ML Inference
Termite 负责处理机器学习相关任务:嵌入向量生成、文本分块、重排序、分类、命名实体识别(NER)、光学字符识别(OCR)、转录、生成等。它作为一个内置模块(pkg/termite)提供,并在集群的 swarm 模式下自动运行,无需单独设置。
Termite handles the ML side: embeddings, chunking, reranking, classification, NER, OCR, transcription, generation, and more. It ships as an in-tree module (
pkg/termite) and runs automatically in swarm mode — you don't need to set it up separately.
辅助库与工具
Libraries & Tools
除了核心引擎,Antfly 生态系统还包含一些实用的库和工具。
| 包/工具 | 功能描述 | 源代码 |
|---|---|---|
| docsaf | 从文件系统、网络爬虫、Git 仓库和 S3 中摄取内容。 | pkg/docsaf |
| evalaf | LLM/RAG/智能体评估(“Go 版的 promptfoo”)。 | pkg/evalaf |
| Genkit 插件 | 用于检索和文档存储的 Firebase Genkit 集成。 | pkg/genkit/antfly |
系统架构
Architecture
Antfly 采用多 Raft 组设计,包含独立的共识组:
Antfly uses a multi-raft design with separate consensus groups:
- 元数据 Raft 组 — 管理表模式、分片分配和集群拓扑。
Metadata raft — table schemas, shard assignments, cluster topology.
- 存储 Raft 组 — 每个数据分片一个,处理数据、索引和查询。
Storage rafts — one per shard, handling data, indexes, and queries.
系统进行了端到端的混沌测试,灵感来源于 Jepsen。这些测试覆盖了节点崩溃、领导者失效、负载下的分片拆分和集群扩缩容等场景,通过注入故障来验证 Raft 共识、事务和复制在故障下的正确行为。
End-to-end chaos tests — inspired by Jepsen — cover node crashes, leader failures, shard splits under load, and cluster scaling. These tests run real multi-node clusters and inject faults to verify that Raft consensus, transactions, and replication behave correctly under failure.
关键的分布式协议使用 TLA+ 进行了形式化规范和模型检验:
Critical distributed protocols are formally specified and model-checked with TLA+:
- AntflyTransaction — 分布式事务协议。
AntflyTransaction — distributed transaction protocol.
- occ-2pc — 基于乐观并发控制的两阶段提交。
occ-2pc — optimistic concurrency control with two-phase commit.
- AntflySnapshotTransfer — Raft 快照传输。
AntflySnapshotTransfer — Raft snapshot transfer.
- AntflyShardSplit — 分片拆分协调。
AntflyShardSplit — shard split coordination.
社区与许可
Community & License
欢迎加入 Discord 社区获取支持、参与讨论并了解最新动态。
Join the Discord for support, discussion, and updates.
有兴趣贡献代码?请参阅 CONTRIBUTING.md。
Interested in contributing? See CONTRIBUTING.md.
核心服务器采用 Elastic License 2.0 (ELv2)。这意味着你可以使用、修改、自托管它,并基于它构建产品,但不能将 Antfly 本身作为托管服务提供。其他所有组件 — SDKs、React 组件、Termite、pgaf、docsaf、evalaf — 均采用 Apache 2.0 许可。我们尽可能地将更多组件置于宽松的许可之下。
The core server is Elastic License 2.0 (ELv2). That means you can use it, modify it, self-host it, and build products on top of it — you just can't offer Antfly itself as a managed service. Everything else — the SDKs, React components, Termite, pgaf, docsaf, evalaf — is Apache 2.0. We tried to keep as much as possible under a permissive license.
常见问题(FAQ)
Antfly的RAG智能体具体能做什么?
Antfly内置的RAG智能体支持检索增强生成,可实现流式输出、多轮对话、工具调用(如网络搜索和图遍历),并为结果提供置信度评分,将混合搜索能力与生成式AI紧密结合。
如何快速开始使用Antfly进行RAG开发?
可通过运行go run ./cmd/antfly swarm启动单节点集群,或使用Docker命令docker run -p 8080:8080 ghcr.io/antflydb/antfly:omni。启动后即可访问Antfarm仪表盘,其中包含RAG等功能的交互演示。
Antfly支持哪些类型的数据进行检索?
Antfly是一个多模态搜索引擎,支持对文本、图像、音频和视频数据进行索引与检索。它结合全文搜索、向量相似度和图遍历,并能自动为这些数据生成嵌入向量和图关系边。
版权与免责声明:本文仅用于信息分享与交流,不构成任何形式的法律、投资、医疗或其他专业建议,也不构成对任何结果的承诺或保证。
文中提及的商标、品牌、Logo、产品名称及相关图片/素材,其权利归各自合法权利人所有。本站内容可能基于公开资料整理,亦可能使用 AI 辅助生成或润色;我们尽力确保准确与合规,但不保证完整性、时效性与适用性,请读者自行甄别并以官方信息为准。
若本文内容或素材涉嫌侵权、隐私不当或存在错误,请相关权利人/当事人联系本站,我们将及时核实并采取删除、修正或下架等处理措施。 也请勿在评论或联系信息中提交身份证号、手机号、住址等个人敏感信息。