Embeddings#
ragbits.core.embeddings.Embeddings
#
Bases: ABC
Abstract client for communication with embedding models.
embed_text
abstractmethod
async
#
Creates embeddings for the given strings.
PARAMETER | DESCRIPTION |
---|---|
data |
List of strings to get embeddings for.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[list[float]]
|
List of embeddings for the given strings. |
Source code in packages/ragbits-core/src/ragbits/core/embeddings/base.py
image_support
#
Check if the model supports image embeddings.
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the model supports image embeddings, False otherwise. |
embed_image
async
#
Creates embeddings for the given images.
PARAMETER | DESCRIPTION |
---|---|
images |
List of images to get embeddings for.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[list[float]]
|
List of embeddings for the given images. |
Source code in packages/ragbits-core/src/ragbits/core/embeddings/base.py
ragbits.core.embeddings.local.LocalEmbeddings
#
Bases: Embeddings
Class for interaction with any encoder available in HuggingFace.
Constructs a new local LLM instance.
PARAMETER | DESCRIPTION |
---|---|
model_name |
Name of the model to use.
TYPE:
|
api_key |
The API key for Hugging Face authentication.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ImportError
|
If the 'local' extra requirements are not installed. |
Source code in packages/ragbits-core/src/ragbits/core/embeddings/local.py
image_support
#
Check if the model supports image embeddings.
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the model supports image embeddings, False otherwise. |
embed_image
async
#
Creates embeddings for the given images.
PARAMETER | DESCRIPTION |
---|---|
images |
List of images to get embeddings for.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[list[float]]
|
List of embeddings for the given images. |
Source code in packages/ragbits-core/src/ragbits/core/embeddings/base.py
embed_text
async
#
Calls the appropriate encoder endpoint with the given data and options.
PARAMETER | DESCRIPTION |
---|---|
data |
List of strings to get embeddings for.
TYPE:
|
batch_size |
Batch size.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[list[float]]
|
List of embeddings for the given strings. |
Source code in packages/ragbits-core/src/ragbits/core/embeddings/local.py
ragbits.core.embeddings.litellm.LiteLLMEmbeddings
#
LiteLLMEmbeddings(model: str = 'text-embedding-3-small', options: dict | None = None, api_base: str | None = None, api_key: str | None = None, api_version: str | None = None)
Bases: Embeddings
Client for creating text embeddings using LiteLLM API.
Constructs the LiteLLMEmbeddingClient.
PARAMETER | DESCRIPTION |
---|---|
model |
Name of the LiteLLM supported model to be used. Default is "text-embedding-3-small".
TYPE:
|
options |
Additional options to pass to the LiteLLM API.
TYPE:
|
api_base |
The API endpoint you want to call the model with.
TYPE:
|
api_key |
API key to be used. API key to be used. If not specified, an environment variable will be used, for more information, follow the instructions for your specific vendor in the LiteLLM documentation.
TYPE:
|
api_version |
The API version for the call.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ImportError
|
If the 'litellm' extra requirements are not installed. |
Source code in packages/ragbits-core/src/ragbits/core/embeddings/litellm.py
image_support
#
Check if the model supports image embeddings.
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the model supports image embeddings, False otherwise. |
embed_image
async
#
Creates embeddings for the given images.
PARAMETER | DESCRIPTION |
---|---|
images |
List of images to get embeddings for.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[list[float]]
|
List of embeddings for the given images. |
Source code in packages/ragbits-core/src/ragbits/core/embeddings/base.py
embed_text
async
#
Creates embeddings for the given strings.
PARAMETER | DESCRIPTION |
---|---|
data |
List of strings to get embeddings for.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[list[float]]
|
List of embeddings for the given strings. |
RAISES | DESCRIPTION |
---|---|
EmbeddingConnectionError
|
If there is a connection error with the embedding API. |
EmbeddingEmptyResponseError
|
If the embedding API returns an empty response. |
EmbeddingStatusError
|
If the embedding API returns an error status code. |
EmbeddingResponseError
|
If the embedding API response is invalid. |