autointent.Embedder#
- class autointent.Embedder(embedder_config)#
A wrapper for managing embedding models using
sentence_transformers.SentenceTransformer
.This class handles initialization, saving, loading, and clearing of embedding models, as well as calculating embeddings for input texts.
- Parameters:
embedder_config (autointent.configs.EmbedderConfig)
- embedding_model: sentence_transformers.SentenceTransformer#
- __hash__()#
Compute a hash value for the Embedder.
- Returns:
The hash value of the Embedder.
- Return type:
- clear_ram()#
Move the embedding model to CPU and delete it from memory.
- Return type:
None
- delete()#
Delete the embedding model and its associated directory.
- Return type:
None
- dump(path)#
Save the embedding model and metadata to disk.
- Parameters:
path (pathlib.Path) – Path to the directory where the model will be saved.
- Return type:
None
- classmethod load(path, override_config=None)#
Load the embedding model and metadata from disk.
- Parameters:
path (pathlib.Path | str) – Path to the directory where the model is stored.
override_config (autointent.configs.EmbedderConfig | None) – one can override presaved settings
- Return type:
- embed(utterances, task_type=None)#
Calculate embeddings for a list of utterances.
- Parameters:
utterances (list[str]) – List of input texts to calculate embeddings for.
task_type (autointent.configs.TaskTypeEnum | None) – Type of task for which embeddings are calculated.
- Returns:
A numpy array of embeddings.
- Return type:
numpy.typing.NDArray[numpy.float32]