Model Adapters Config

This class manages the setup and configuration of adapter modules in a pre-trained model.

class transformers.ModelAdaptersConfig(**kwargs)

This class manages the setup and configuration of adapter modules in a pre-trained model.

add(adapter_name: str, adapter_type: transformers.adapter_utils.AdapterType, config: Optional[Union[dict, str]] = None)

Adds a new adapter of the given type and name to the model config.

Parameters
  • adapter_name (str) – The name of the adapter.

  • adapter_type (AdapterType) – The type of the adapter.

  • config (Optional[Union[str, dict]], optional) – The adapter config. Defaults to None.

common_config_value(adapter_names: list, attribute: str)

Checks whether all adapters in a list share the same config setting for a given attribute and returns the shared value.

Parameters
  • adapter_names (list) – The adapters to check.

  • attribute (str) – The config attribute to check.

get(adapter_name: str, return_type: bool = False)

Gets the config dictionary for a given adapter.

Parameters
  • adapter_name (str) – The name of the adapter.

  • return_type (bool, optional) – If set to True, also return the adapter type. Defaults to False.

Returns

The adapter configuration and optionally the adapter type.

Return type

Mapping or tuple(Mapping, AdapterType)

get_config(adapter_type: transformers.adapter_utils.AdapterType) → dict

Gets the default adapter configuration of the specified adapter type.

get_type(adapter_name: str) → Optional[transformers.adapter_utils.AdapterType]

Gets the type of a given adapter.

Parameters

adapter_name (str) – The name of the adapter.

Returns

The adapter’s type.

Return type

Optional[AdapterType]

set_config(adapter_type: transformers.adapter_utils.AdapterType, config: Union[dict, str, transformers.adapter_config.AdapterConfig])

Sets the default adapter configuration of the specified adapter type.

Parameters

config (str or dict or AdapterConfig) – adapter configuration, can be either: - a string identifying a pre-defined adapter configuration - a dictionary representing the adapter configuration - the path to a file containing the adapter configuration