autointent.modules.GCNScorer#

class autointent.modules.GCNScorer(embedder_config=None, label_embedder_config=None, gcn_hidden_dims=None, p_reweight=0.2, tau_threshold=0.4, num_train_epochs=10, batch_size=16, learning_rate=0.001, seed=42, device=None, early_stopping_config=None)#

Bases: autointent.modules.scoring._torch.base_scorer.BaseTorchTrainerScorer

Graph Convolutional Network (GCN) scorer for intent classification.

This module uses a GCN to model label correlations for multi-label text classification. It leverages embeddings for both utterances and labels (descriptions/names) to learn a classifier for each label.

Parameters:
  • embedder_config (autointent.configs.EmbedderConfig | str | dict[str, Any] | None) – Config for utterance embedder.

  • label_embedder_config (autointent.configs.EmbedderConfig | str | dict[str, Any] | None) – Config for label description embedder.

  • gcn_hidden_dims (list[int] | None) – List of hidden dimensions for GCN layers.

  • p_reweight (float) – Reweighting parameter for the correlation matrix.

  • tau_threshold (float) – Threshold for creating the adjacency matrix.

  • num_train_epochs (pydantic.PositiveInt) – Number of training epochs.

  • batch_size (pydantic.PositiveInt) – Batch size for training.

  • learning_rate (float) – Learning rate for the optimizer.

  • seed (int) – Random seed for reproducibility.

  • device (str | None) – Device to train on (‘cpu’, ‘cuda’, etc.).

  • early_stopping_config (autointent.configs.EarlyStoppingConfig | dict[str, Any] | None) – Configuration for early stopping.

Reference:

Chen, Z. M., Wei, X. S., Wang, P., & Guo, Y. (2019). Multi-Label Image Recognition with Graph Convolutional Networks. arXiv preprint arXiv:1904.03582.

name = 'gcn'#

Name of the module to reference in search space configuration.

supports_multiclass = True#

Whether the module supports multiclass classification

supports_multilabel = True#

Whether the module supports multilabel classification

embedder_config#
label_embedder_config#
gcn_hidden_dims = None#
p_reweight = 0.2#
tau_threshold = 0.4#
classmethod from_context(context, embedder_config=None, label_embedder_config=None, gcn_hidden_dims=None, p_reweight=0.2, tau_threshold=0.4, num_train_epochs=10, batch_size=16, learning_rate=0.001, seed=42, early_stopping_config=None)#

Initialize self from context.

Parameters:
Returns:

Initialized module

Return type:

GCNScorer

get_implicit_initialization_params()#

Return default params used in __init__ method.

Some parameters of the module may be inferred using context rather from __init__ method. But they need to be logged for reproducibility during loading from disk.

Returns:

Dictionary of default params

Return type:

dict[str, Any]

get_train_data(context)#

Get train data.

Parameters:

context (autointent.Context) – Context to get train data from

Returns:

Tuple of train utterances and train labels

Return type:

tuple[list[str], autointent.custom_types.ListOfLabels, list[str]]

fit(utterances, labels, descriptions)#

Fit the scoring module to the training data.

Parameters:
  • utterances (list[str]) – List of training utterances.

  • labels (autointent.custom_types.ListOfLabels) – List of training labels.

  • descriptions (list[str])

Return type:

None

predict(utterances)#

Predict scores for a list of utterances.

Parameters:

utterances (list[str]) – List of utterances to score.

Returns:

Array of predicted scores.

Return type:

numpy.typing.NDArray[Any]

clear_cache()#

Clear cache.

Return type:

None