Skip to main content

在 Hugging Face 上的指令嵌入

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

<!--IMPORTS:[{"imported": "HuggingFaceInstructEmbeddings", "source": "langchain_community.embeddings", "docs": "https://python.langchain.com/api_reference/community/embeddings/langchain_community.embeddings.huggingface.HuggingFaceInstructEmbeddings.html", "title": "Instruct Embeddings on Hugging Face"}]-->
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)

相关


Was this page helpful?


You can also leave detailed feedback on GitHub.

扫我,入群扫我,找书