Meta AI 的 LASER 语言无关的 SEntence 表示 Embeddings
LASER 是由 Meta AI 研究团队开发的 Python 库,截至 2024 年 2 月 25 日,用于为超过 147 种语言创建多语言句子嵌入
依赖
要将 LaserEmbed 与 LangChain 一起使用,请安装laser_encodersPython 包。
%pip install laser_encoders
进口
from langchain_community.embeddings.laser import LaserEmbeddings
API 参考:LaserEmbeddings
实例化激光
参数
# 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")