File size: 326 Bytes
5f3b20a
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
from langchain_huggingface import HuggingFaceEmbeddings

class E5Embeddings(HuggingFaceEmbeddings):
    def embed_documents(self, texts):
        texts = [f"passage: {text}" for text in texts]
        return super().embed_documents(texts)

    def embed_query(self, text):
        return super().embed_query(f"query: {text}")