# MilvusRAG **Repository Path**: captainwilson/milvus-rag ## Basic Information - **Project Name**: MilvusRAG - **Description**: 使用Milvus构建的RAG检索系统 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-28 - **Last Updated**: 2025-10-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 帮我构造一个RAG检索系统,系统包括以下组件: 1 - 索引构建模块:该模块负责将原始数据存储为索引,并建立索引之间的关联关系。 2 - 检索模块:该模块负责接收用户查询,并返回与查询最匹配的文档。 3 - 存储模块:该模块负责将索引存储在数据库中,并支持查询。 4 - 可以支持excel,pdf,word数据转化为milvus向量知识库 5 - 支持重排序,即根据查询结果的相关性对文档进行排序。 ## 持久化与部署说明 - 安装依赖:`pip install -r d:\code\python\rag_system\requirements.txt` - Milvus 服务持久化(Windows 容器示例): - `docker run -d --name milvus-standalone -p 19530:19530 -p 9091:9091 -v C:\milvus_data:/var/lib/milvus milvusdb/milvus:latest` - 持久化数据路径:`C:\milvus_data`(容器内映射为 `/var/lib/milvus`)。 - 连接配置:在 `rag_system/config.py` 中设置 `MILVUS_HOST` 和 `MILVUS_PORT`。 - 快照与恢复: - 索引构建完成后自动生成 JSONL 快照:`d:\code\python\rag_system\snapshots\{collection}_{timestamp}.jsonl` - 从快照恢复:`python d:\code\python\rag_system\rag_system\tools\restore_from_snapshot.py d:\code\python\rag_system\snapshots\.jsonl --batch 1000` - 示例运行: - 构建索引:`python d:\code\python\rag_system\examples\build_index_example.py` - 检索与重排序:`python d:\code\python\rag_system\examples\search_and_rerank_example.py` ## 模块清单 - 索引构建:`rag_system/indexing/index_builder.py`(含快照保存) - 加载器:`rag_system/indexing/loaders.py`(Excel/PDF/Word) - 嵌入:`rag_system/indexing/embedding.py` - 检索:`rag_system/retrieval/retriever.py` - 重排序:`rag_system/reranker/reranker.py` - 存储(Milvus):`rag_system/storage/milvus_store.py` - 快照工具:`rag_system/utils/snapshots.py` 与 `rag_system/tools/restore_from_snapshot.py` ## CLI 用法 - 构建索引(文件或目录): - `python d:\code\python\rag_system\rag_system\cli.py build --paths d:\data\a.pdf d:\data\b.docx` - `python d:\code\python\rag_system\rag_system\cli.py build --dir d:\code\python\rag_system\data` - 指定集合:`--collection my_collection` - 检索(支持可选重排序): - `python d:\code\python\rag_system\rag_system\cli.py search --query "如何按季度汇总销售数据并生成报表?" --top-k 15` - 启用重排序:`--rerank --rerank-top-k 8` - 从快照恢复: - `python d:\code\python\rag_system\rag_system\cli.py restore d:\code\python\rag_system\snapshots\rag_docs_YYYYMMDD_HHMMSS.jsonl --batch 1000` - 指定集合:`--collection my_collection`