Skip to content

Commit

Permalink
Remove ambiguous padding_mask and instead use a 2D->4D Attn Mask Ma…
Browse files Browse the repository at this point in the history
…pper (huggingface#26792)

* [Attn Mask Converter] refactor attn mask

* up

* Apply suggestions from code review

Co-authored-by: fxmarty <9808326+fxmarty@users.noreply.github.com>

* improve

* rename

* better cache

* renaming

* improve more

* improve

* fix bug

* finalize

* make style & make fix-copies

* correct more

* start moving attention_mask

* fix llama

* improve falcon

* up

* improve more

* improve more

* Update src/transformers/models/owlv2/modeling_owlv2.py

* make style

* make style

* rename to converter

* Apply suggestions from code review

---------

Co-authored-by: fxmarty <9808326+fxmarty@users.noreply.github.com>
  • Loading branch information
2 people authored and staghado committed Oct 24, 2023
1 parent 63c177a commit f5a2c7d
Show file tree
Hide file tree
Showing 6 changed files with 735 additions and 265 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def get_input_embeddings(self):
def set_input_embeddings(self, value):
self.embed_tokens = value

# Copied from transformers.models.llama.modeling_llama.LlamaModel._prepare_decoder_attention_mask
# Copied from transformers.models.bart.modeling_bart.BartDecoder._prepare_decoder_attention_mask
def _prepare_decoder_attention_mask(self, attention_mask, input_shape, inputs_embeds, past_key_values_length):
# create causal mask
# [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
Expand Down
Loading

0 comments on commit f5a2c7d

Please sign in to comment.