MCPcopy Create free account
hub / github.com/espnet/espnet / create_adapter

Function create_adapter

espnet2/layers/create_adapter.py:23–40  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

21
22@typechecked
23def 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)

Callers 4

main_workerMethod · 0.90
build_model_from_fileMethod · 0.90
test_create_adapter_loraFunction · 0.90

Calls

no outgoing calls

Tested by 2

test_create_adapter_loraFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…