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

Fix Gemma2 4d attention mask #31674

Merged
merged 2 commits into from
Jun 28, 2024
Merged

Fix Gemma2 4d attention mask #31674

merged 2 commits into from
Jun 28, 2024

Conversation

hiyouga
Copy link
Contributor

@hiyouga hiyouga commented Jun 27, 2024

What does this PR do?

(Might) continuation of #31670

Fixes #31673

The attention mask here should be a 4d mask, while the current implementation mistakenly treated it as a 2d mask. Additionally, the mask needs to be inverted to prevent label leakage.

Before this pr:

image

After this pr:

image2

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@ArthurZucker

hiyouga added a commit to hiyouga/LLaMA-Factory that referenced this pull request Jun 27, 2024
Gemma2 finetuning cannot work until merging huggingface/transformers#31674
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

Thanks, with this we do avoid the overflow!

@ArthurZucker ArthurZucker merged commit 5e89b33 into huggingface:main Jun 28, 2024
18 of 23 checks passed
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

ArthurZucker added a commit that referenced this pull request Jun 28, 2024
Update modeling_gemma2.py

Co-authored-by: Arthur <[email protected]>
@ArthurZucker
Copy link
Collaborator

The patch is out for this! Thanks again 🤗 https://pypi.org/project/transformers/4.42.2/

PrimaLuz pushed a commit to PrimaLuz/LLaMA-Factory that referenced this pull request Jul 1, 2024
Gemma2 finetuning cannot work until merging huggingface/transformers#31674
@kkk935208447
Copy link

Thank you all for your hard work. I've been dealing with this issue recently as well.

xtchen96 pushed a commit to xtchen96/LLaMA-Factory that referenced this pull request Jul 17, 2024
Gemma2 finetuning cannot work until merging huggingface/transformers#31674
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Label Leakage in Gemma 2 Finetuning
4 participants