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

Idefics2: sync added image tokens with transformers #2080

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

danieldk
Copy link
Member

@danieldk danieldk commented Jun 17, 2024

What does this PR do?

Before this change, the number of reserved image tokens was not the same as the number of images. Fixes #2029.

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?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@danieldk danieldk force-pushed the bugfix/idefics2-no-image-splitting branch 9 times, most recently from 99be263 to 9ce4552 Compare June 20, 2024 07:22
@danieldk danieldk marked this pull request as ready for review June 20, 2024 08:55
@danieldk danieldk marked this pull request as draft June 24, 2024 13:47
..
}))
) {
tokens = tokens.repeat(5);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Careful about the removal of contiguous <fake> tokens in the preprocessor.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. I'm now doing it in the same way as transformers. First add the duplicate tokens, then substitute them away.

I first wanted to make the image token processing aware of preceding chunks and only add a preceding fake token if there was not a preceding image (and then only intersperse the image splits with a single fake token). But that seemed like a bit of premature optimization of the image token processing.

@danieldk danieldk force-pushed the bugfix/idefics2-no-image-splitting branch 3 times, most recently from 1f1f4be to 8cafd28 Compare June 25, 2024 13:13
@danieldk danieldk marked this pull request as ready for review June 25, 2024 15:04
@danieldk danieldk requested a review from Narsil June 26, 2024 07:11
Narsil
Narsil previously approved these changes Jun 27, 2024
Copy link
Collaborator

@Narsil Narsil left a comment

Choose a reason for hiding this comment

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

LGTM. Let's merge we should probably add a unit test for the adversarial fixup.

(2 consecutive images showing the fixup removed 1 fake token).

Before this change, the number of reserved image tokens was not the
same as the number of images. Fixes #2029.

While at it, also remove all the image token handling duplication
in `prepare_input`.
@danieldk danieldk force-pushed the bugfix/idefics2-no-image-splitting branch from 8cafd28 to 80b448c Compare June 27, 2024 13:42
@Narsil Narsil merged commit dd2d91b into main Jun 27, 2024
8 checks passed
@Narsil Narsil deleted the bugfix/idefics2-no-image-splitting branch June 27, 2024 13:54
glegendre01 pushed a commit that referenced this pull request Jul 2, 2024
Before this change, the number of reserved image tokens was not the
same as the number of images. Fixes #2029.

While at it, also remove all the image token handling duplication
in `prepare_input`.
yuanwu2017 pushed a commit to yuanwu2017/tgi-gaudi that referenced this pull request Sep 26, 2024
Before this change, the number of reserved image tokens was not the
same as the number of images. Fixes huggingface#2029.

While at it, also remove all the image token handling duplication
in `prepare_input`.
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.

HuggingFaceM4/idefics2: TGI would crash when I set do_image_splitting to False
2 participants