InfinityEmbeddingsLocal#
- class langchain_community.embeddings.infinity_local.InfinityEmbeddingsLocal[source]#
Bases:
BaseModel
,Embeddings
Optimized Infinity embedding models.
michaelfeil/infinity This class deploys a local Infinity instance to embed text. The class requires async usage.
Infinity is a class to interact with Embedding Models on michaelfeil/infinity
Example
from langchain_community.embeddings import InfinityEmbeddingsLocal async with InfinityEmbeddingsLocal( model="BAAI/bge-small-en-v1.5", revision=None, device="cpu", ) as embedder: embeddings = await engine.aembed_documents(["text1", "text2"])
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.
- param backend: str = 'torch'#
Backend for inference, e.g. ‘torch’ (recommended for ROCm/Nvidia)
- param batch_size: int = 32#
Internal batch size for inference, e.g. 32
- param device: str = 'auto'#
Device to use for inference, e.g. ‘cpu’ or ‘cuda’, or ‘mps’
- param engine: Any = None#
Infinity’s AsyncEmbeddingEngine.
- param model: str [Required]#
Underlying model id from huggingface, e.g. BAAI/bge-small-en-v1.5
- param model_warmup: bool = True#
Warmup the model with the max batch size.
- param revision: str | None = None#
Model version, the commit hash from huggingface
- async aembed_documents(texts: List[str]) List[List[float]] [source]#
Async call out to Infinity’s embedding endpoint.
- Parameters:
texts (List[str]) – The list of texts to embed.
- Returns:
List of embeddings, one for each text.
- Return type:
List[List[float]]
- async aembed_query(text: str) List[float] [source]#
Async call out to Infinity’s embedding endpoint.
- Parameters:
text (str) – The text to embed.
- Returns:
Embeddings for the text.
- Return type:
List[float]
Examples using InfinityEmbeddingsLocal