BM25 Rerank Memory Search
调用本地检索脚本 /opt/memory/bm25_rerank_search.py,返回精确的上下文片段。
依赖
- BM25:
rank_bm25 - 向量+重排: SiliconFlow API (BAAI/bge-m3 + BAAI/bge-reranker-v2-m3)
- 安装:
pip install rank-bm25 --break-system-packages
使用方式
搜索记忆
python3 /opt/memory/bm25_rerank_search.py search <查询词>
重建索引(记忆文件变更后需执行)
python3 /opt/memory/bm25_rerank_search.py reindex
检索逻辑
- BM25 关键词匹配 → 候选集 A
- BGE-M3 向量相似度 → 候选集 B
- A ∪ B 合并
- BGE-Reranker-v2-m3 重排 → 最终结果
输出格式
每条结果包含: [score] path:chunk_id + 内容片段 (最多显示前200字符)