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)

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:

int

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:
Return type:

Embedder

embed(utterances, task_type=None)#

Calculate embeddings for a list of utterances.

Parameters:
Returns:

A numpy array of embeddings.

Return type:

numpy.typing.NDArray[numpy.float32]