renate.benchmark.models.transformer module#

class renate.benchmark.models.transformer.FeatureExtractorTextTransformer(pretrained_model_name_or_path)[source]#

Bases: PreTrainedModel

This is a facade class to extract the correct output from the transformer model.

forward(x)[source]#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool#
class renate.benchmark.models.transformer.HuggingFaceSequenceClassificationTransformer(pretrained_model_name_or_path, num_outputs=10, prediction_strategy=None, add_icarl_class_means=True)[source]#

Bases: RenateBenchmarkingModule

RenateBenchmarkingModule which wraps around Hugging Face transformers.

Parameters:
  • pretrained_model_name_or_path (str) – Hugging Face model id.

  • num_outputs (int) – Number of outputs.

  • prediction_strategy (Optional[PredictionStrategy]) – Continual learning strategies may alter the prediction at train or test time.

  • add_icarl_class_means (bool) – If True, additional parameters used only by the ICaRLModelUpdater are added. Only required when using that updater.

get_features(*args, **kwargs)[source]#
training: bool#