6大核心模块(Modules)
示例
指令嵌入(Instruct Embeddings)

LangChain

InstructEmbeddings#

让我们加载HuggingFace instruct嵌入类。

from langchain.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)