Skip to main content
Open In ColabOpen on GitHub

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

LASER is a Python library developed by the Meta AI Research team and used for creating multilingual sentence embeddings for over 147 languages as of 2/25/2024

依赖项

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

%pip install laser_encoders

导入

from langchain_community.embeddings.laser import LaserEmbeddings
API 参考:LaserEmbeddings

实例化激光

参数

  • lang: Optional[str]

    If empty will default to using a multilingual LASER encoder model (called "laser2"). You can find the list of supported languages and lang_codes here and here .

# 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")