langchain_community.embeddings.optimum_intel
.QuantizedBiEncoderEmbeddingsĀ¶
- class langchain_community.embeddings.optimum_intel.QuantizedBiEncoderEmbeddings[source]Ā¶
Bases:
BaseModel
,Embeddings
Quantized bi-encoders embedding models.
Please ensure that you have installed optimum-intel and ipex.
- Input:
model_name: str = Model name. max_seq_len: int = The maximum sequence length for tokenization. (default 512) pooling_strategy: str =
āmeanā or āclsā, pooling strategy for the final layer. (default āmeanā)
- query_instruction: Optional[str] =
An instruction to add to the query before embedding. (default None)
- document_instruction: Optional[str] =
An instruction to add to each document before embedding. (default None)
- padding: Optional[bool] =
Whether to add padding during tokenization or not. (default True)
- model_kwargs: Optional[Dict] =
Parameters to add to the model during initialization. (default {})
- encode_kwargs: Optional[Dict] =
Parameters to add during the embedding forward pass. (default {})
Example:
from langchain_community.embeddings import QuantizedBiEncoderEmbeddings
model_name = āIntel/bge-small-en-v1.5-rag-int8-staticā encode_kwargs = {ānormalize_embeddingsā: True} hf = QuantizedBiEncoderEmbeddings(
model_name, encode_kwargs=encode_kwargs, query_instruction=āRepresent this sentence for searching relevant passages: ā
)
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- async aembed_documents(texts: List[str]) List[List[float]] Ā¶
Asynchronous Embed search docs.
- Parameters
texts (List[str]) ā List of text to embed.
- Returns
List of embeddings.
- Return type
List[List[float]]
- async aembed_query(text: str) List[float] Ā¶
Asynchronous Embed query text.
- Parameters
text (str) ā Text to embed.
- Returns
Embedding.
- Return type
List[float]
- embed_documents(texts: List[str]) List[List[float]] [source]Ā¶
Embed a list of text documents using the Optimized Embedder model.
- Input:
texts: List[str] = List of text documents to embed.
- Output:
List[List[float]] = The embeddings of each text document.
- Parameters
texts (List[str]) ā
- Return type
List[List[float]]