autointent.modules.base.BaseModule#

class autointent.modules.base.BaseModule#

Bases: abc.ABC

Base module for all intent classification modules.

supports_oos: bool#

Whether the module supports oos data

supports_multilabel: bool#

Whether the module supports multilabel classification

supports_multiclass: bool#

Whether the module supports multiclass classification

name: str#

Name of the module.

abstract fit(*args, **kwargs)#

Fit the model.

Parameters:
  • *args (tuple[Any]) – Args to fit

  • **kwargs (dict[str, Any]) – Kwargs to fit

Return type:

None

score(context, metrics)#

Calculate metric on test set and return metric value.

Parameters:
Raises:

ValueError – If unknown scheme is provided

Return type:

dict[str, float]

abstract score_cv(context, metrics)#
Parameters:
Return type:

dict[str, float]

abstract score_ho(context, metrics)#
Parameters:
Return type:

dict[str, float]

abstract get_assets()#

Return useful assets that represent intermediate data into context.

Returns:

Artifact containing intermediate data

Return type:

autointent.context.optimization_info.Artifact

abstract clear_cache()#

Clear cache.

Return type:

None

dump(path)#

Dump all data needed for inference.

Parameters:

path (str) – Path to dump

Return type:

None

load(path, embedder_config=None, cross_encoder_config=None)#

Load data from file system.

Parameters:
Return type:

None

abstract predict(*args, **kwargs)#

Predict on the input.

Parameters:
  • *args (list[str] | numpy.typing.NDArray[Any]) – args to predict

  • **kwargs (dict[str, Any]) – kwargs to predict

Return type:

autointent.custom_types.ListOfGenericLabels | numpy.typing.NDArray[Any]

predict_with_metadata(*args, **kwargs)#

Predict on the input with metadata.

Parameters:
  • *args (list[str] | numpy.typing.NDArray[Any]) – args to predict

  • **kwargs (dict[str, Any]) – kwargs to predict

Returns:

Tuple of predictions and metadata

Return type:

tuple[autointent.custom_types.ListOfGenericLabels | numpy.typing.NDArray[Any], list[dict[str, Any]] | None]

classmethod from_context(context, **kwargs)#
Abstractmethod:

Parameters:
Return type:

BaseModule

Initialize self from context.

Parameters:
Returns:

Initialized module

Return type:

BaseModule

get_embedder_config()#

Get the config of the embedder.

Return type:

dict[str, Any] | None

static score_metrics_ho(params, metrics_dict)#

Score metrics on the test set.

Parameters:
  • params (tuple[Any, Any]) – Params to score

  • metrics_dict (dict[str, Any]) – Dictionary of metrics to compute

Return type:

dict[str, float]

score_metrics_cv(metrics_dict, cv_iterator, **fit_kwargs)#

Score metrics using cross-validation.

Parameters:
  • metrics_dict (dict[str, Any]) – Dictionary of metrics to compute

  • cv_iterator (collections.abc.Iterable[tuple[list[str], autointent.custom_types.ListOfLabels, list[str], autointent.custom_types.ListOfLabels]]) – Cross-validation iterator

  • **fit_kwargs – Additional arguments for fit method

Return type:

tuple[dict[str, float], list[autointent.custom_types.ListOfGenericLabels] | list[numpy.typing.NDArray[Any]]]