Repository navigation
Fix ProphetNet forward to handle tuple encoder_outputs - #39794
Abdennacer-Badaoui wants to merge 13 commits into
Conversation
|
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. |
9299165 to
feb83dd
Compare
|
cc @ArthurZucker for text models |
ArthurZucker
left a comment
There was a problem hiding this comment.
I think we'd rather update the docstring as it should no longer be a tuple!
|
Alright! In this case, the |
…der-outputs-tuple
….com/Abdennacer-Badaoui/transformers into fix/prophetnet-encoder-outputs-tuple
| @@ -1056,7 +1056,6 @@ def forward( | |||
| inputs_embeds: Optional[torch.Tensor] = None, | |||
| output_attentions: Optional[bool] = None, | |||
There was a problem hiding this comment.
btw if you have time, can you add the check_model_input decorator, updating to the latest standards? 🤗
There was a problem hiding this comment.
sorry, what I mean by that is add this, remove the args, add the TransformersKwargs, remove the
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
output_hidden_states = (
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
)
etc! Have a look at modeling llama to see how we handle ti
There was a problem hiding this comment.
My bad, it’s clearer now. I’ll try to fix it. Thanks!
|
[For maintainers] Suggested jobs to run (before merge) run-slow: prophetnet |
|
Thanks for the PR, and sorry it didn't make it in! This branch is based on v4, and v5 is very different, so rather than rebasing we'd love to invite you to open a new PR against
Closing this one in the meantime, thanks again! |
This PR fixes a bug in ProphetNet where passing
encoder_outputsas a tuple toforward()would raise:AttributeError: 'tuple' object has no attribute 'last_hidden_state'This happens because the
forward()method assumesencoder_outputsis aBaseModelOutputwhen provided manually, while the docstring says it can be a tuple.Changes:
Added a check in
forward():Convert tuple
encoder_outputstoBaseModelOutputformat before passing toProphetNetSeq2SeqModelOutput.