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, config: Optional[Union[dict, str]] = None)¶ Adds a new adapter of the name to the model config.
- Parameters
adapter_name (str) – The name of the adapter.
config (Optional[Union[str, dict]], optional) – The adapter config. Defaults to None.
-
add_fusion
(fusion_name: Union[str, List[str]], config: Optional[Union[dict, str]] = None)¶ Adds a new AdapterFusion.
- Parameters
fusion_name (Union[str, List[str]]) – The name of the AdapterFusion or the adapters to fuse.
config (Optional[Union[str, dict]], optional) – AdapterFusion 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) → Optional[dict]¶ Gets the config dictionary for a given adapter.
- Parameters
adapter_name (str) – The name of the adapter.
- Returns
The adapter configuration.
- Return type
Mapping
-
get_fusion
(fusion_name: Union[str, List[str]]) → Optional[dict]¶ Gets the config dictionary for a given AdapterFusion.
- Parameters
fusion_name (Union[str, List[str]]) – The name of the AdapterFusion or the adapters to fuse.
- Returns
The AdapterFusion configuration.
- Return type
Optional[dict]
-
match
(adapter_name: str, config_type: type, layer_idx: Optional[int] = None, location_key: Optional[str] = None) → Optional[dict]¶ Tries to match the given criteria to an existing adapter. Return the adapter config if a match is found, otherwise None.
-