-
Notifications
You must be signed in to change notification settings - Fork 26.2k
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 serving_output
for TF composite models (encoder-decoder like models)
#22743
Conversation
cross_attns = ( | ||
tf.convert_to_tensor(output.cross_attentions) | ||
if self.config.output_attentions and output.cross_attentions is not None | ||
if self.config.decoder.output_attentions and output.cross_attentions is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the attributes in the components' configurations (i.e. self.config.encoder
and self.config.decoder
)
The documentation is not available anymore as the PR was closed or merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me but would like for a TF expert to have a look too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me!
…dels) (huggingface#22743) * fix * style * fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
What does this PR do?
[If the concept is approved, I will apply the same changes to other TF encoder-decoder family of models]
The composite models use its components' configurations. See for example
transformers/src/transformers/modeling_tf_utils.py
Lines 426 to 430 in 95e7057
However, in some places, our codebase still try to access some attributes at the top level of the configuration (i.e. not inside the 2 components), like
transformers/src/transformers/models/vision_encoder_decoder/modeling_tf_vision_encoder_decoder.py
Lines 664 to 669 in 95e7057
In particular,
self.config
may not haveuse_cache
, for example, for this checkpoint"nlpconnect/vit-gpt2-image-captioning"
. We should instead lookself.config.deocder.use_cache
.This PR try to follow the rule of
# Encoder Decoder models delegate the application of the configuration options to their inner models.
.This PR is also (another) one necessary step to fix #22731.