autointent.modules.embedding.RetrievalAimedEmbedding#
- class autointent.modules.embedding.RetrievalAimedEmbedding(embedder_config, k=10)#
Bases:
autointent.modules.base.BaseEmbedding
Module for configuring embeddings optimized for retrieval tasks.
The main purpose of this module is to be used at embedding node for optimizing embedding configuration using its retrieval quality as a sort of proxy metric.
- Parameters:
k (pydantic.PositiveInt) – Number of nearest neighbors to retrieve
embedder_config (autointent.configs.EmbedderConfig | str | dict[str, Any]) – Config of the embedder used for creating embeddings
Examples:#
from autointent.modules.embedding import RetrievalAimedEmbedding utterances = ["bye", "how are you?", "good morning"] labels = [0, 1, 1] retrieval = RetrievalAimedEmbedding( k=2, embedder_config="sergeyzh/rubert-tiny-turbo", ) retrieval.fit(utterances, labels)
- name = 'retrieval'#
Name of the module.
- supports_multiclass = True#
Whether the module supports multiclass classification
- supports_multilabel = True#
Whether the module supports multilabel classification
- supports_oos = False#
Whether the module supports oos data
- k = 10#
- embedder_config#
- classmethod from_context(context, embedder_config, k=10)#
Create an instance using a Context object.
- Parameters:
context (autointent.Context) – The context containing configurations and utilities
k (pydantic.PositiveInt) – Number of nearest neighbors to retrieve
embedder_config (autointent.configs.EmbedderConfig | str) – Config of the embedder to use
- Return type:
- fit(utterances, labels)#
Fit the vector index using the provided utterances and labels.
- score_ho(context, metrics)#
Evaluate the embedding model using specified metric functions.
- score_cv(context, metrics)#
Evaluate the embedding model using specified metric functions.
- get_assets()#
Get the retriever artifacts for this module.
- Returns:
A EmbeddingArtifact object containing embedder information
- Return type:
- clear_cache()#
Clear cached data in memory used by the vector index.
- Return type:
None