feat: 实现 BM25 稀疏 + 稠密向量混合检索功能
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled
This commit is contained in:
22
tools/download_bm25.py
Normal file
22
tools/download_bm25.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""
|
||||
BM25模型预下载脚本
|
||||
执行后将模型缓存到 ./models/fastembed_cache 目录,打包进Docker镜像
|
||||
"""
|
||||
import os
|
||||
from fastembed.sparse.sparse_text_embedding import SparseTextEmbedding
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 指定缓存目录
|
||||
cache_dir = "./models/fastembed_cache"
|
||||
os.makedirs(cache_dir, exist_ok=True)
|
||||
|
||||
print("正在下载BM25稀疏向量模型...")
|
||||
model = SparseTextEmbedding(
|
||||
model_name="Qdrant/bm25",
|
||||
cache_dir=cache_dir
|
||||
)
|
||||
|
||||
# 触发一次推理,确保模型文件完整下载
|
||||
list(model.embed(["init trigger"]))
|
||||
print(f"✅ BM25模型已成功缓存到: {cache_dir}")
|
||||
print("请将该目录提交到项目仓库,打包进Docker镜像")
|
||||
Reference in New Issue
Block a user