Skip to main content

LASER 语言无关的句子表示嵌入,由Meta AI提供

LASER 是由Meta AI研究团队开发的Python库,用于创建超过147种语言的多语言句子嵌入,截至2024年2月25日

依赖

要在LangChain中使用LaserEmbed,请安装laser_encoders Python包。

%pip install laser_encoders

导入

<!--IMPORTS:[{"imported": "LaserEmbeddings", "source": "langchain_community.embeddings.laser", "docs": "https://python.langchain.com/api_reference/community/embeddings/langchain_community.embeddings.laser.LaserEmbeddings.html", "title": "LASER Language-Agnostic SEntence Representations Embeddings by Meta AI"}]-->
from langchain_community.embeddings.laser import LaserEmbeddings

实例化 LASER

参数

  • lang: 可选[str]

如果为空,将默认为使用多语言 LASER 编码器模型(称为 "laser2")。 您可以在 这里 找到支持的语言和 lang_codes 列表 和 这里 。 。

# Ex Instantiationz
embeddings = LaserEmbeddings(lang="eng_Latn")

用法

生成文档嵌入

document_embeddings = embeddings.embed_documents(
["This is a sentence", "This is some other sentence"]
)

生成查询嵌入

query_embeddings = embeddings.embed_query("This is a query")

相关


Was this page helpful?


You can also leave detailed feedback on GitHub.

扫我,入群扫我,找书