跳转到主要内容

Haystack 2.x组件,用于使用fastembed嵌入模型嵌入字符串和文档

项目描述

fastembed-haystack

PyPI - Version PyPI - Python Version


目录

安装

pip install fastembed-haystack

用法

您可以通过导入以下方式使用FastembedTextEmbedderFastembedDocumentEmbedder

from haystack_integrations.components.embedders.fastembed import FastembedTextEmbedder

text = "fastembed is supported by and maintained by Qdrant."
text_embedder = FastembedTextEmbedder(
    model="BAAI/bge-small-en-v1.5"
)
text_embedder.warm_up()
embedding = text_embedder.run(text)["embedding"]
from haystack_integrations.components.embedders.fastembed import FastembedDocumentEmbedder
from haystack.dataclasses import Document

embedder = FastembedDocumentEmbedder(
    model="BAAI/bge-small-en-v1.5",
)
embedder.warm_up()
doc = Document(content="fastembed is supported by and maintained by Qdrant.", meta={"long_answer": "no",})
result = embedder.run(documents=[doc])

您可以通过导入以下方式使用FastembedSparseTextEmbedderFastembedSparseDocumentEmbedder

from haystack_integrations.components.embedders.fastembed import FastembedSparseTextEmbedder

text = "fastembed is supported by and maintained by Qdrant."
text_embedder = FastembedSparseTextEmbedder(
    model="prithvida/Splade_PP_en_v1"
)
text_embedder.warm_up()
embedding = text_embedder.run(text)["embedding"]
from haystack_integrations.components.embedders.fastembed import FastembedSparseDocumentEmbedder
from haystack.dataclasses import Document

embedder = FastembedSparseDocumentEmbedder(
    model="prithvida/Splade_PP_en_v1",
)
embedder.warm_up()
doc = Document(content="fastembed is supported by and maintained by Qdrant.", meta={"long_answer": "no",})
result = embedder.run(documents=[doc])

许可

fastembed-haystack是根据Apache-2.0许可协议发布的。

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

fastembed_haystack-1.2.0.tar.gz (15.6 kB 查看哈希值)

上传时间:

构建分布

fastembed_haystack-1.2.0-py3-none-any.whl (16.4 kB 查看哈希值)

上传于 Python 3

由以下支持