autointent.modules.regex.SimpleRegex#

class autointent.modules.regex.SimpleRegex#

Bases: autointent.modules.base.BaseRegex

Regular expressions based intent detection module.

A module that uses regular expressions to detect intents in text utterances. Supports both full and partial pattern matching.

name = 'simple'#

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

classmethod from_context(context)#

Initialize from context.

Parameters:

context (autointent.Context) – Context object containing configuration

Returns:

Initialized SimpleRegex instance

Return type:

SimpleRegex

fit(intents)#

Fit the model with intent patterns.

Parameters:

intents (list[autointent.schemas.Intent]) – List of intents to fit the model with

Return type:

None

predict(utterances)#

Predict intents for given utterances.

Parameters:

utterances (list[str]) – List of utterances to predict intents for

Returns:

List of predicted intent labels

Return type:

list[autointent.custom_types.LabelType]

predict_with_metadata(utterances)#

Predict intents for utterances with pattern matching metadata.

Parameters:

utterances (list[str]) – List of utterances to predict intents for

Returns:

  • List of predicted intent labels

  • List of pattern matching metadata for each utterance

Return type:

Tuple containing

score_ho(context, metrics)#

Score the model using holdout validation.

Parameters:
  • context (autointent.Context) – Context containing validation data

  • metrics (list[str]) – List of metric names to compute

Returns:

Dictionary of computed metric values

Return type:

dict[str, float]

score_cv(context, metrics)#

Score the model in cross-validation mode.

Parameters:
  • context (autointent.Context) – Context containing validation data

  • metrics (list[str]) – List of metric names to compute

Returns:

Dictionary of computed metric values

Return type:

dict[str, float]

score_metrics_cv(metrics_dict, cv_iterator, intents)#

Score metrics using cross-validation.

Parameters:
Returns:

Tuple of metrics dictionary and predictions

Return type:

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

clear_cache()#

Clear cached regex patterns.

Return type:

None

get_assets()#

Get model assets.

Returns:

Empty Artifact object

Return type:

autointent.context.optimization_info.Artifact

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