models
langroid/embedding_models/models.py
FastEmbedEmbeddingsConfig
¶
Bases: EmbeddingModelsConfig
Config for qdrant/fastembed embeddings, see here: https://github.com/qdrant/fastembed
EmbeddingFunctionCallable(embed_model, batch_size=512)
¶
A callable class designed to generate embeddings for a list of texts using the OpenAI or Azure OpenAI API, with automatic retries on failure.
Attributes:
Name | Type | Description |
---|---|---|
embed_model |
EmbeddingModel
|
An instance of EmbeddingModel that provides configuration and utilities for generating embeddings. |
Methods:
Name | Description |
---|---|
__call__ |
List[str]) -> Embeddings: Generate embeddings for a list of input texts. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
OpenAIEmbeddings or AzureOpenAIEmbeddings
|
An instance of OpenAIEmbeddings or AzureOpenAIEmbeddings to use for generating embeddings. |
required |
batch_size
|
int
|
Batch size |
512
|
Source code in langroid/embedding_models/models.py
OpenAIEmbeddings(config=OpenAIEmbeddingsConfig())
¶
Bases: EmbeddingModel
Source code in langroid/embedding_models/models.py
truncate_texts(texts)
¶
Truncate texts to the embedding model's context length. TODO: Maybe we should show warning, and consider doing T5 summarization?
Source code in langroid/embedding_models/models.py
AzureOpenAIEmbeddings(config=AzureOpenAIEmbeddingsConfig())
¶
Bases: EmbeddingModel
Azure OpenAI embeddings model implementation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
AzureOpenAIEmbeddingsConfig
|
Configuration for Azure OpenAI embeddings model. |
AzureOpenAIEmbeddingsConfig()
|
Raises: ValueError: If required Azure config values are not set.
Source code in langroid/embedding_models/models.py
truncate_texts(texts)
¶
Truncate texts to the embedding model's context length. TODO: Maybe we should show warning, and consider doing T5 summarization?
Source code in langroid/embedding_models/models.py
embedding_fn()
¶
Get the embedding function for Azure OpenAI.
Returns:
Type | Description |
---|---|
Callable[[List[str]], Embeddings]
|
Callable that generates embeddings for input texts. |
Source code in langroid/embedding_models/models.py
embedding_model(embedding_fn_type='openai')
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
embedding_fn_type
|
str
|
Type of embedding model to use. Options are: - "openai", - "azure-openai", - "sentencetransformer", or - "fastembed". (others may be added in the future) |
'openai'
|
Returns: EmbeddingModel: The corresponding embedding model class.