add some
Former-commit-id: b4790c66c126567bd193de52a564e3ce11c94769
This commit is contained in:
@@ -142,6 +142,10 @@ def get_forbidden_modules(config: "PretrainedConfig", finetuning_args: "Finetuni
|
||||
forbidden_modules.update({"visual.patch_embed", "visual.blocks", "model", "lm_head"})
|
||||
elif finetuning_args.freeze_vision_tower:
|
||||
forbidden_modules.add("visual")
|
||||
|
||||
elif model_type == "minicpmv":
|
||||
if finetuning_args.freeze_vision_tower:
|
||||
forbidden_modules.add("vpm")
|
||||
|
||||
return forbidden_modules
|
||||
|
||||
@@ -196,6 +200,8 @@ def patch_target_modules(
|
||||
return "^(?!.*vision_model).*(?:{}).*".format("|".join(target_modules))
|
||||
elif model_type == "qwen2_vl":
|
||||
return "^(?!.*visual).*(?:{}).*".format("|".join(target_modules))
|
||||
elif model_type == "minicpmv":
|
||||
return "^(?!.*vpm).*(?:{}).*".format("|".join(target_modules))
|
||||
else:
|
||||
return target_modules
|
||||
else:
|
||||
|
||||
@@ -138,12 +138,13 @@ def patch_model(
|
||||
add_valuehead: bool,
|
||||
) -> None:
|
||||
gen_config = model.generation_config # check and fix generation config
|
||||
if not gen_config.do_sample and (
|
||||
(gen_config.temperature is not None and gen_config.temperature != 1.0)
|
||||
or (gen_config.top_p is not None and gen_config.top_p != 1.0)
|
||||
or (gen_config.typical_p is not None and gen_config.typical_p != 1.0)
|
||||
):
|
||||
gen_config.do_sample = True
|
||||
if gen_config is not None:
|
||||
if not gen_config.do_sample and (
|
||||
(gen_config.temperature is not None and gen_config.temperature != 1.0)
|
||||
or (gen_config.top_p is not None and gen_config.top_p != 1.0)
|
||||
or (gen_config.typical_p is not None and gen_config.typical_p != 1.0)
|
||||
):
|
||||
gen_config.do_sample = True
|
||||
|
||||
if "GenerationMixin" not in str(model.generate.__func__):
|
||||
model.generate = MethodType(PreTrainedModel.generate, model)
|
||||
|
||||
Reference in New Issue
Block a user