Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
集成 Hugging Face 上的 Instructor-style 嵌入模型,使用 LangChain Python。
The hkunlp/instructor-* 家族引入了指令调优的句子嵌入。它们已被现代指令感知模型广泛取代,但原始模型仍在Hugging Face上提供,可通过 HuggingFaceInstructEmbeddings 类别使用。
hkunlp/instructor-*
HuggingFaceInstructEmbeddings
HuggingFaceEmbeddings
langchain-huggingface
intfloat/e5-large-v2
Qwen/Qwen3-Embedding-0.6B
BAAI/bge-m3
encode_kwargs
query_encode_kwargs
from langchain_huggingface import HuggingFaceEmbeddings embeddings = HuggingFaceEmbeddings( model_name="intfloat/e5-large-v2", encode_kwargs={"prompt": "passage: "}, query_encode_kwargs={"prompt": "query: "}, )
pip install -qU langchain-community InstructorEmbedding sentence-transformers
langchain-community
langchain_community
from langchain_community.embeddings import HuggingFaceInstructEmbeddings embeddings = HuggingFaceInstructEmbeddings( query_instruction="Represent the query for retrieval: " ) query_result = embeddings.embed_query("This is a test document.")
官方原文:src/oss/python/integrations/embeddings/instruct_embeddings.mdx · 非官方翻译,译文由 AI 生成,以英文原文为准。