Parameters
Parameter | Type | Default | Description |
---|---|---|---|
model_name | str | "BAAI/bge-small-en-v1.5" | FastEmbed model name |
cache_dir | Optional[str] | None | Model cache directory |
threads | Optional[int] | None | Number of threads (auto-detected if None) |
providers | List[str] | ["CPUExecutionProvider"] | ONNX execution providers |
enable_gpu | bool | False | Enable GPU acceleration if available |
enable_parallel_processing | bool | True | Enable parallel text processing |
doc_embed_type | str | "default" | Document embedding type (default, passage) |
max_memory_mb | Optional[int] | None | Maximum memory usage in MB |
model_warmup | bool | True | Warm up model on initialization |
enable_sparse_embeddings | bool | False | Use sparse embeddings for better performance |
sparse_model_name | Optional[str] | None | Sparse model name if different from dense |
Functions
__init__
Initialize the FastEmbedProvider.
Parameters:
config
(Optional[FastEmbedConfig]): Configuration object**kwargs
: Additional configuration options
_setup_providers
Setup ONNX execution providers based on configuration.
_initialize_models
Initialize FastEmbed models.
_warmup_models
Warm up models with sample data.
supported_modes
Get supported embedding modes.
Returns:
List[EmbeddingMode]
: List of supported embedding modes
pricing_info
Get FastEmbed pricing info (local execution is free).
Returns:
Dict[str, float]
: Pricing information
get_model_info
Get information about the current FastEmbed model.
Returns:
Dict[str, Any]
: Model information
_process_embeddings
Process embeddings iterator into list format.
Parameters:
embeddings_iterator
(Iterator[np.ndarray]): Embeddings iterator
List[List[float]]
: Processed embeddings
_embed_batch
Embed a batch of texts using FastEmbed.
Parameters:
texts
(List[str]): List of text strings to embedmode
(EmbeddingMode): Embedding mode (affects processing strategy)
List[List[float]]
: List of embedding vectors
_normalize_embeddings
Normalize embeddings to unit length.
Parameters:
embeddings
(List[List[float]]): List of embedding vectors
List[List[float]]
: Normalized embeddings
validate_connection
Validate FastEmbed model is working.
Returns:
bool
: True if model is working
get_performance_info
Get performance and resource usage information.
Returns:
Dict[str, Any]
: Performance information
list_available_models
List available FastEmbed models.
Returns:
List[Dict[str, Any]]
: List of available models
get_cache_info
Get information about model caching.
Returns:
Dict[str, Any]
: Cache information
close
Clean up FastEmbed models and clear memory.
create_bge_small_embedding
Create BGE-small FastEmbed provider (fast and efficient).
Parameters:
**kwargs
: Additional configuration options
FastEmbedProvider
: Configured FastEmbedProvider instance
create_bge_large_embedding
Create BGE-large FastEmbed provider (high quality).
Parameters:
**kwargs
: Additional configuration options
FastEmbedProvider
: Configured FastEmbedProvider instance
create_e5_embedding
Create E5 FastEmbed provider (multilingual).
Parameters:
**kwargs
: Additional configuration options
FastEmbedProvider
: Configured FastEmbedProvider instance
create_sparse_embedding
Create sparse embedding provider for efficiency.
Parameters:
**kwargs
: Additional configuration options
FastEmbedProvider
: Configured FastEmbedProvider instance
create_gpu_accelerated_embedding
Create GPU-accelerated FastEmbed provider.
Parameters:
model_name
(str): Model name to use**kwargs
: Additional configuration options
FastEmbedProvider
: Configured FastEmbedProvider instance