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

[Generate] correct encoder_outputs are passed without attention_mask #14980

Conversation

patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Dec 29, 2021

What does this PR do?

Very very edge case is solved in this PR which occurs if "encoder_outputs" is passed in combination without passing "attention_mask", but a model that accepts an "attention_mask".

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.

@patrickvonplaten patrickvonplaten requested review from Narsil and sgugger and removed request for Narsil December 29, 2021 17:15
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

Comment on lines 1902 to 1904
output_sequences_with_mask = model.generate(
encoder_outputs=encoder_outputs, attention_mask=attention_mask
).cpu()
Copy link
Collaborator

Choose a reason for hiding this comment

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

As usual, when formatted like this by black, I'd go for two lines :-)

Copy link
Contributor

@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

The wav2vec2 doesn't seem to belong, if it does maybe a test should explain what the test is actually about.

tests/test_pipelines_automatic_speech_recognition.py Outdated Show resolved Hide resolved
framework="pt",
)

ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation").sort("id")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the sort necessary ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah since it different versions datasets might break the order

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a very odd thing in datasets that order could be messed up by subsequent versions...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anton-l and I have experienced this now a couple of times so tat we'll just make sure this way

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to know !

@patrickvonplaten patrickvonplaten merged commit c043ce6 into huggingface:master Dec 30, 2021
@patrickvonplaten patrickvonplaten deleted the correct_generate_edge_case branch December 30, 2021 09:16
stevhliu pushed a commit to stevhliu/transformers that referenced this pull request Jan 6, 2022
…uggingface#14980)

* [Generate] correct encoder_outputs are passed without attention_mask

* Apply suggestions from code review

* up
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.

3 participants