Model Adapters Config
This class manages the setup and configuration of adapter modules in a pre-trained model.
- class adapters.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(adapter_names: List[str], config: Optional[Union[dict, str]] = None, fusion_name: Optional[str] = None)
Adds a new AdapterFusion.
- Parameters
adapter_names (List[str]) – The names of the adapters to fuse.
config (Optional[Union[str, dict]], optional) – AdapterFusion config. Defaults to None.
fusion_name (Optional[str], optional) – The name of the AdapterFusion. If not specified, will default to comma-separated adapter names.
- 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]]) Tuple[Optional[dict], Optional[list]]
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. Optional[list]: The names of the adapters to fuse.
- 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.