Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bart] Move CLS rep extraction from EOS tokens to head classes #624

Merged
merged 1 commit into from
Jan 7, 2024

Conversation

calpt
Copy link
Member

@calpt calpt commented Dec 21, 2023

Fixes #494 and fixes #563.

BartAdapterModel currently tries to extract CLS token representations from EOS tokens independent from the used heads (if at all). This causes weird issues for models not using CLS token based heads.

This PR moves CLS token rep extraction into the specific head classes to only compute it when needed. Two (re-usable) new args to forward_head() are introduced:

  • get_cls_from_eos_tokens: to indicate a model uses CLS reps from EOS tokens
  • eos_mask: token mask to extract CLS reps (required when passing get_cls_from_eos_tokens=True)

@calpt calpt marked this pull request as ready for review December 21, 2023 15:34
Copy link
Member

@lenglaender lenglaender left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@calpt calpt merged commit 2e2f302 into adapter-hub:main Jan 7, 2024
5 checks passed
@calpt calpt deleted the fix/bart_eos_tokens branch January 7, 2024 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants