Skip to main content
Open In ColabOpen on GitHub

Hugging Face上的Instruct Embeddings

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)

这个页面有帮助吗?