LASER 语言无关句子表示嵌入 (Meta AI)
LASER 是由 Meta AI 研究团队开发的 Python 库,用于创建多语言句子嵌入,截至 2024 年 2 月 25 日已支持超过 147 种语言。
依赖项
要在 LangChain 中使用 LaserEmbed,请安装 laser_encoders
Python 包。
%pip install laser_encoders
导入
from langchain_community.embeddings.laser import LaserEmbeddings
API 参考:LaserEmbeddings
实例化 Laser
参数
# 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")