跳到主要内容
Open In ColabOpen on GitHub

Hugging Face 上的 Instruct 嵌入

Hugging Face sentence-transformers 是一个用于最先进的句子、文本和图像嵌入的 Python 框架。其中一个指令嵌入模型在 HuggingFaceInstructEmbeddings 类中使用。

from langchain_community.embeddings import HuggingFaceInstructEmbeddings
embeddings = HuggingFaceInstructEmbeddings(
query_instruction="Represent the query for retrieval: "
)
load INSTRUCTOR_Transformer
max_seq_length 512
text = "This is a test document."
query_result = embeddings.embed_query(text)
© . This site is unofficial and not affiliated with LangChain, Inc.
这些文档随着 LangChain v1.0 在 2025 年 10 月的发布而弃用,并且不再维护。 请访问 v1.0 文档