InstructEmbeddings
让我们加载HuggingFace的InstructEmbeddings类。
from langchain.embeddings import HuggingFaceInstructEmbeddings
embeddings = HuggingFaceInstructEmbeddings(
query_instruction="表示用于检索的查询:"
)
load INSTRUCTOR_Transformer
max_seq_length 512
text = "这是一个测试文档。"
query_result = embeddings.embed_query(text)