autointent.modules.scoring.GCNScorer#
- class autointent.modules.scoring.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.BaseTorchTrainerScorerGraph 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#
- 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:
context (autointent.Context) – Context to init from
**kwargs – Additional kwargs
embedder_config (autointent.configs.EmbedderConfig | str | dict[str, Any] | None)
label_embedder_config (autointent.configs.EmbedderConfig | str | dict[str, Any] | None)
p_reweight (float)
tau_threshold (float)
num_train_epochs (pydantic.PositiveInt)
batch_size (pydantic.PositiveInt)
learning_rate (float)
seed (int)
early_stopping_config (autointent.configs.EarlyStoppingConfig | dict[str, Any] | None)
- Returns:
Initialized module
- Return type:
- 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.
- get_train_data(context)#
Get train data.
- fit(utterances, labels, descriptions)#
Fit the scoring module to the training data.
- predict(utterances)#
Predict scores for a list of utterances.
- clear_cache()#
Clear cache.
- Return type:
None