add hint for freeze #2412
This commit is contained in:
parent
4ecadc3512
commit
6545c02790
|
@ -17,6 +17,7 @@ class FreezeArguments:
|
|||
BLOOM & Falcon & ChatGLM choices: ["mlp", "self_attention"], \
|
||||
Qwen choices: ["mlp", "attn"], \
|
||||
Phi choices: ["mlp", "mixer"], \
|
||||
InternLM2 choices: ["feed_forward", "attention"], \
|
||||
Others choices: the same as LLaMA.'
|
||||
},
|
||||
)
|
||||
|
|
|
@ -52,8 +52,18 @@ def init_adapter(
|
|||
else: # fine-tuning the first n layers if num_layer_trainable < 0
|
||||
trainable_layer_ids = [k for k in range(-finetuning_args.num_layer_trainable)] # noqa: C416
|
||||
|
||||
freeze_modules = set()
|
||||
for name, _ in model.named_modules():
|
||||
if "0." in name:
|
||||
freeze_modules.add(name.split("0.")[-1].split(".")[0])
|
||||
|
||||
trainable_layers = []
|
||||
for module_name in finetuning_args.name_module_trainable:
|
||||
if module_name not in freeze_modules:
|
||||
raise ValueError(
|
||||
"Module {} is not found, please choose from {}".format(module_name, ", ".join(freeze_modules))
|
||||
)
|
||||
|
||||
for idx in trainable_layer_ids:
|
||||
trainable_layers.append("{:d}.{}".format(idx, module_name))
|
||||
|
||||
|
|
Loading…
Reference in New Issue