这是indexloc提供的服务,不要输入任何密码
Skip to content

如何在训练的时候冻结语言模块,只训练vision tower? #438

@xvlincaigou

Description

@xvlincaigou

我在https://github.com/hiyouga/EasyR1/blob/main/verl/workers/fsdp_workers.py#L239 之后加了这样的代码,不知道对不对?

    if model_config.freeze_language_backbone:
        model.requires_grad_(False)
        
        if not model_config.freeze_vision_tower:
             if hasattr(model, "model") and hasattr(model.model, "visual"):
                model.model.visual.requires_grad_(True)
             elif hasattr(model, "visual"):
                model.visual.requires_grad_(True)

        if hasattr(model, "model") and hasattr(model.model, "mm_projector"):
            model.model.mm_projector.requires_grad_(True)
        if hasattr(model, "lm_head"):
            model.lm_head.requires_grad_(True)
        
        fsdp_config.use_orig_params = True
        self.print_rank0("Language backbone is frozen. Only specified layers are trainable.")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions