Skip to main content

litellm_to_list

Convert a LiteLLM embedding response to a list of embeddings. Arguments:
  • embeds: The LiteLLM embedding response.
Returns: A list of embeddings.

LiteLLMEncoder Objects

LiteLLM encoder class for generating embeddings using LiteLLM. The LiteLLMEncoder class is a subclass of DenseEncoder and utilizes the LiteLLM SDK to generate embeddings for given documents. It supports all encoders supported by LiteLLM and supports customization of the score threshold for filtering or processing the embeddings.

__init__

Initialize the LiteLLMEncoder. Arguments:
  • name (str): The name of the embedding model to use. Must use LiteLLM naming convention (e.g. “openai/text-embedding-3-small” or “mistral/mistral-embed”).
  • score_threshold (float): The score threshold for the embeddings.

__call__

Encode a list of text documents into embeddings using LiteLLM. Arguments:
  • docs: List of text documents to encode.
Returns: List of embeddings for each document.

acall

Encode a list of documents into embeddings using LiteLLM asynchronously. Arguments:
  • docs: List of documents to encode.
Returns: List of embeddings for each document.