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

依赖项

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

导入

from langchain_community.embeddings.laser import LaserEmbeddings

实例化 Laser

参数

  • lang: 可选[str]
    如果为空,将默认使用多语言 LASER 编码器模型(称为“laser2”)。您可以在此处此处找到支持的语言和语言代码列表。
# 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")

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.