Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何在LoRA训练中加入embed和norm层的训练? #161

Open
Zheng-Jay opened this issue Dec 22, 2023 · 0 comments
Open

如何在LoRA训练中加入embed和norm层的训练? #161

Zheng-Jay opened this issue Dec 22, 2023 · 0 comments

Comments

@Zheng-Jay
Copy link

感谢作者的开源分享!
阅读了你的文章,其中提到LoRA+embed、norm层的训练,可以有效提高模型在支持长上下文时的性能,我想要在自己的训练代码中加入这种训练,但对于如何添加,有些疑惑。
我看了你的训练代码,LoRA+的配置似乎是:

        config = LoraConfig(
            r=8,
            lora_alpha=16,
            target_modules=targets,
            lora_dropout=0,
            bias="none",
            task_type="CAUSAL_LM",
        )
        model = get_peft_model(model, config)
        # enable trainable params
        [p.requires_grad_() for n, p in model.named_parameters() if any([k in n for k in training_args.trainable_params.split(",")])]

我对这种配置感到疑惑,对“embed、norm”层的配置为什么采用这种形式,而不是在LoraConfig的“modules_to_save”参数中进行配置?如下:

            lora_config = LoraConfig(
                task_type=TaskType.CAUSAL_LM,
                inference_mode=False,
                r=finetuning_args.lora_rank,
                lora_alpha=finetuning_args.lora_alpha,
                lora_dropout=finetuning_args.lora_dropout,
                target_modules=target_modules,
                modules_to_save=“embed、norm”层
            )
            model = get_peft_model(model, lora_config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant