Skip to content

Commit

Permalink
handling mask_lm_head for idefics model.
Browse files Browse the repository at this point in the history
  • Loading branch information
Luodian committed Jul 28, 2023
1 parent a5537b4 commit 035e900
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pipeline/train/instruction_following.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ def mask_embedding(m):

if args.mask_lm_head:
unwrapped_model = accelerator.unwrap_model(model)
if unwrapped_model.lang_encoder.__class__.__name__ in ["MPTForCausalLM", "MosaicGPT"]:
if isinstance(unwrapped_model, IdeficsForVisionText2Text):
unwrapped_model.lm_head.apply(mask_embedding)
elif unwrapped_model.lang_encoder.__class__.__name__ in ["MPTForCausalLM", "MosaicGPT"]:
unwrapped_model.lang_encoder.transformer.wte.apply(mask_embedding)
elif unwrapped_model.lang_encoder.__class__.__name__ == "LlamaForCausalLM":
unwrapped_model.lang_encoder.model.embed_tokens.apply(mask_embedding)
Expand Down

0 comments on commit 035e900

Please sign in to comment.