Adapter Training

Classes and methods related to training adapters.

class transformers.adapters.training.AdapterArguments(train_adapter: bool = False, load_adapter: Optional[str] = '', adapter_config: Optional[str] = 'pfeiffer', load_lang_adapter: Optional[str] = None, lang_adapter_config: Optional[str] = None)

The subset of arguments related to adapter training.

Parameters
  • train_adapter (bool) – Whether to train an adapter instead of the full model.

  • load_adapter (str) – Pre-trained adapter module to be loaded from Hub.

  • adapter_config (str) – Adapter configuration. Either a config string or a path to a file.

  • load_lang_adapter (str) – Pre-trained language adapter module to be loaded from Hub.

  • lang_adapter_config (str) – Language adapter configuration. Either an identifier or a path to a file.

transformers.adapters.training.setup_adapter_training(model, adapter_args: transformers.adapters.training.AdapterArguments, adapter_name: str, adapter_config_kwargs: Optional[dict] = None, adapter_load_kwargs: Optional[dict] = None)

Setup model for adapter training based on given adapter arguments.

Parameters
  • model (_type_) – The model instance to be trained.

  • adapter_args (AdapterArguments) – The adapter arguments used for configuration.

  • adapter_name (str) – The name of the adapter to be added.

Returns

A tuple containing the names of the loaded adapters.

Return type

Tuple[str, str]