Skip to main content
Open In Colab在 GitHub 上打开

在 Hugging Face 上指示嵌入

Hugging Face sentence-transformers 是一个 Python 框架,用于最先进的句子、文本和图像嵌入。 其中一个 instruct 嵌入模型用于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)