mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[GH-ISSUE #183] Attention is not masked on padding tokens #157
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openai/CLIP#157
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mesnico on GitHub (Nov 17, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/183
I noticed that no padding masks are used in the attention computation of the input sentence.
The transformer in the
encode_textfunction should be masked with the actual sentence length. However, in this implementation, it appears not to be the case:github.com/openai/CLIP@573315e83f/clip/model.py (L344)All the 77 tokens (padding tokens comprised) seem to participate in the attention computation.
Am I missing something?
Thank you in advance!
@jongwook commented on GitHub (Nov 17, 2021):
We use a causal attention mask (code, cf. #179) and it basically blocks any information from "future" tokens from flowing back in. So we can take the embedding at the EOT token (code), while safely ignoring any attention calculation of the padding tokens.
@mesnico commented on GitHub (Nov 17, 2021):
I was totally ignoring the pad masking "side effect" of causal attention.
Thank you!