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 issue of canine forward requiring input_ids anyway #26290

Merged
merged 9 commits into from
Oct 2, 2023
Merged

Fix issue of canine forward requiring input_ids anyway #26290

merged 9 commits into from
Oct 2, 2023

Conversation

marcmk6
Copy link
Contributor

@marcmk6 marcmk6 commented Sep 20, 2023

The current forward requires (the shape of) input_ids for deriving other variables whenever input_ids or inputs_embeds is provided. Change this to use the given one instead of input_ids all the time.

What does this PR do?

Fixes #26288

Who can review?

@ArthurZucker and @younesbelkada

The `forward` requires `input_ids` for deriving other variables in all cases. Change this to use the given one between `input_ids` and `inputs_embeds`
The current `forward` requires (the shape of) `input_ids` for deriving other variables whenever `input_ids` or `inputs_embeds` is provided. Change this to use the given one instead of `input_ids` all the time.
Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your PR !
The method should correctly retrieve the sequence length as the second dimension corresponds to it: https://github.com/huggingface/transformers/blob/main/src/transformers/models/canine/modeling_canine.py#L1042

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

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!

Comment on lines +1172 to +1174
char_attention_mask = self._create_3d_attention_mask_from_input_mask(
input_ids if input_ids is not None else inputs_embeds, attention_mask
)
Copy link
Collaborator

@ArthurZucker ArthurZucker Sep 22, 2023

Choose a reason for hiding this comment

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

we should use the input_shape defined above, since the function is only used once, no problem changing it
I'm pretty sure we have tests in our CI for that make sure generation work with use cache and in that case, you need this to work. Good for me as is

@LysandreJik LysandreJik merged commit 6d02ca4 into huggingface:main Oct 2, 2023
@marcmk6 marcmk6 deleted the fix-canine-forward branch October 7, 2023 10:37
blbadger pushed a commit to blbadger/transformers that referenced this pull request Nov 8, 2023
…6290)

* fix issue of canine forward requires input_ids anyway

The `forward` requires `input_ids` for deriving other variables in all cases. Change this to use the given one between `input_ids` and `inputs_embeds`

* fix canine forward

The current `forward` requires (the shape of) `input_ids` for deriving other variables whenever `input_ids` or `inputs_embeds` is provided. Change this to use the given one instead of `input_ids` all the time.

* fix format

* fix format
EduardoPach pushed a commit to EduardoPach/transformers that referenced this pull request Nov 18, 2023
…6290)

* fix issue of canine forward requires input_ids anyway

The `forward` requires `input_ids` for deriving other variables in all cases. Change this to use the given one between `input_ids` and `inputs_embeds`

* fix canine forward

The current `forward` requires (the shape of) `input_ids` for deriving other variables whenever `input_ids` or `inputs_embeds` is provided. Change this to use the given one instead of `input_ids` all the time.

* fix format

* fix format
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.

CANINE unexpectedly requires input_ids anyway
5 participants