由 deepset 维护
集成:Weaviate
将 Weaviate 数据库与 Haystack 结合使用
目录
概述
安装
使用 pip 安装 Weaviate
pip install weaviate-haystack
使用
安装完成后,初始化您的 Weaviate 数据库以便与 Haystack 一起使用。
在此示例中,为简化起见,我们使用了临时的嵌入式版本。要使用自托管的 Docker 容器或 Weaviate Cloud Service,请查看 文档。
from haystack_integrations.document_stores.weaviate import WeaviateDocumentStore
from weaviate.embedded import EmbeddedOptions
document_store = WeaviateDocumentStore(embedded_options=EmbeddedOptions())
# document_store = WeaviateDocumentStore(url="https://:8080")
将文档写入 WeaviateDocumentStore
要将文档写入 WeaviateDocumentStore,请创建一个索引管道。
from haystack.components.file_converters import TextFileToDocument
from haystack.components.writers import DocumentWriter
indexing = Pipeline()
indexing.add_component("converter", TextFileToDocument())
indexing.add_component("writer", DocumentWriter(document_store))
indexing.connect("converter", "writer")
indexing.run({"converter": {"paths": file_paths}})
检索
该集成通过不同的检索器组件支持不同的检索类型
-
WeaviateBM25Retriever:一个基于关键字的检索器,用于从文档存储中获取与查询匹配的文档。 -
WeaviateEmbeddingRetriever:比较查询和文档的嵌入,并获取与查询最相关的文档。 -
WeaviateHybridRetriever:一个使用混合搜索的检索器,用于根据查询的嵌入查找相似的文档。
许可证
weaviate-haystack 是根据 Apache-2.0 许可证分发的。
