Create adapter for the base model. Args: model (torch.nn.Module): Base model to be adapted. adapter_type (str): Name of adapter adapter_conf (dict): Configuration for the adapter e.g. {"rank": 8, "alpha": 8, ...} for lora
(
model: torch.nn.Module,
adapter: str,
adapter_conf: dict,
)
| 21 | |
| 22 | @typechecked |
| 23 | def create_adapter( |
| 24 | model: torch.nn.Module, |
| 25 | adapter: str, |
| 26 | adapter_conf: dict, |
| 27 | ): |
| 28 | """Create adapter for the base model. |
| 29 | |
| 30 | |
| 31 | Args: |
| 32 | model (torch.nn.Module): Base model to be adapted. |
| 33 | adapter_type (str): Name of adapter |
| 34 | adapter_conf (dict): Configuration for the adapter |
| 35 | e.g. {"rank": 8, "alpha": 8, ...} for lora |
| 36 | |
| 37 | """ |
| 38 | assert adapter in create_adapter_fn_table, f"Adapter {adapter} is not supported." |
| 39 | create_adapter_fn = create_adapter_fn_table[adapter] |
| 40 | create_adapter_fn(model=model, **adapter_conf) |
no outgoing calls
searching dependent graphs…