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][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

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]

embed_documents(texts: List[str]) List[List[float]][source]#

This method is async only.

Parameters:

texts (List[str])

Return type:

List[List[float]]

embed_query(text: str) List[float][source]#
Parameters:

text (str)

Return type:

List[float]

Examples using InfinityEmbeddingsLocal