pyseekdb.utils.embedding_functions.SentenceTransformerEmbeddingFunction
- class pyseekdb.utils.embedding_functions.SentenceTransformerEmbeddingFunction(model_name: str = 'all-MiniLM-L6-v2', device: str = 'cpu', normalize_embeddings: bool = False, **kwargs: Any)[source]
Bases:
EmbeddingFunction[str|list[str]]An embedding function using sentence-transformers with a specific model.
Example
pip install pyseekdb sentence-transformers
- __init__(model_name: str = 'all-MiniLM-L6-v2', device: str = 'cpu', normalize_embeddings: bool = False, **kwargs: Any)[source]
Initialize SentenceTransformerEmbeddingFunction.
- Parameters:
model_name (str, optional) – Identifier of the SentenceTransformer model, defaults to “all-MiniLM-L6-v2”
device (str, optional) – Device used for computation, defaults to “cpu”
normalize_embeddings (bool, optional) – Whether to normalize returned vectors, defaults to False
**kwargs – Additional arguments to pass to the SentenceTransformer model.
Methods
__init__([model_name, device, ...])Initialize SentenceTransformerEmbeddingFunction.
build_from_config(config)Get the configuration dictionary for the embedding function.
name()support_persistence(embedding_function)Check if the embedding function supports persistence.
Attributes
models- get_config() dict[str, Any][source]
Get the configuration dictionary for the embedding function.
This method should return a dictionary that contains all the information needed to restore the embedding function after restart.
- Returns:
Dictionary containing the embedding function’s configuration. Note: The ‘name’ field is not included as it’s handled by the upper layer for routing.