add yivl and save processor to model_dir

This commit is contained in:
BUAADreamer 2024-05-15 09:54:00 +08:00
parent d72e6f8dfd
commit afc6c7b9fd
2 changed files with 3 additions and 2 deletions

View File

@ -859,7 +859,7 @@ _register_template(
_register_template( _register_template(
name="yivl", name="yivl",
format_user=StringFormatter(slots=["### Human: {{content}}\n### Assistant:"]), format_user=StringFormatter(slots=["### Human: {{content}}\n### Assistant:"]),
format_assistant=StringFormatter(slots=[" {{content}}"]), format_assistant=StringFormatter(slots=[" {{content}}\n"]),
stop_words=["###"], stop_words=["###"],
default_system=( default_system=(
"This is a chat between an inquisitive human and an AI assistant. " "This is a chat between an inquisitive human and an AI assistant. "

View File

@ -29,7 +29,8 @@ def autocast_projector_dtype(
) -> "torch.Tensor": ) -> "torch.Tensor":
return output.to(model_args.compute_dtype) return output.to(model_args.compute_dtype)
if hasattr(model, mm_projector_name) and getattr(model.config, "quantization_method", None): if hasattr(model, mm_projector_name) and (getattr(model.config, "quantization_method", None)
or "Yi" in getattr(model.config.text_config, "_name_or_path", None)):
logger.info("Casting multimodal projector outputs in {}.".format(model_args.compute_dtype)) logger.info("Casting multimodal projector outputs in {}.".format(model_args.compute_dtype))
mm_projector: "torch.nn.Module" = getattr(model, mm_projector_name) mm_projector: "torch.nn.Module" = getattr(model, mm_projector_name)
mm_projector.register_forward_hook(_mm_projector_forward_post_hook) mm_projector.register_forward_hook(_mm_projector_forward_post_hook)