llama_index 使用Qdrant与Fastembed的local_only在LlamaIndex中进行混合搜索

68de4m5k  于 23天前  发布在  其他
关注(0)|答案(3)|浏览(20)

在QdrantVectorStore中使用本地fastembed稀疏模型的方法如下:

  1. 首先,确保你已经将Fastembed库下载到离线环境中。
  2. 然后,从Fastembed库中获取稀疏模型的文件路径。例如,如果你使用的是prithivida/Splade_PP_en_v1,那么文件路径可能是/path/to/your/local/fastembed/models/prithivida/Splade_PP_en_v1
  3. 在创建QdrantClient时,设置SPARSE_MODEL参数为本地稀疏模型的文件路径。

以下是一个示例代码:

from qdrant_client import QdrantClient, models

class HybridQdrantClient:
    DEFAULT_HOST = "[http://localhost:6333](http://localhost:6333)"
    DENSE_MODEL = "BAAI/bge-large-en-v1.5"
    SPARSE_MODEL = "/path/to/your/local/fastembed/models/prithivida/Splade_PP_en_v1"
    CACHE_DIR = "/data/models/fastembed_cache/"

# 创建QdrantClient示例

client = QdrantClient(host=HybridQdrantClient.DEFAULT_HOST)

这样,你就可以在QdrantVectorStore中使用本地Fastembed稀疏模型进行混合Qdrant搜索了。

brtdzjyr

brtdzjyr1#

Just override the sparse functions
llama_index/llama-index-integrations/vector_stores/llama-index-vector-stores-qdrant/llama_index/vector_stores/qdrant/base.py
Line 147 in 1fc48b7
| | sparse_doc_fn: Optional[SparseEncoderCallable] =None, |

lkaoscv7

lkaoscv72#

这是默认的
llama_index/llama-index-integrations/vector_stores/llama-index-vector-stores-qdrant/llama_index/vector_stores/qdrant/utils.py
第67行 in 1fc48b7
| | deffastembed_sparse_encoder( |

pdkcd3nj

pdkcd3nj3#

@logan-markewich ,谢谢,我会采纳你的建议并将结果反馈回来,以便他人受益。

相关问题