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

Model Templates for Seq2Seq #9251

Merged

Conversation

patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Dec 22, 2020

What does this PR do?

This PR adds the possibility to generate Encoder-Decoder models via the cookie-cutter tool.
Model is correctly generated for PT and TF with all tests passing. Two test files are added.
These templates should very much facilitate the addition of Pegasus, Blenderbot, Marian as separate model files as well as adding BigBird, etc...

Please note that for now the safety checks: # Copied from transformers.models.bart.modeling_bart... are only added for very few layers because:

  • Bart has some hacks that we should not copy for new models, but that we need to keep for backwards compatibility. E.g. positional embeddings have an offset hack leading to slightly too large positional embeddings, which we should not repeat (same as in RoBERTa), automatic creation of decoder_input_ids is a special feature and not the default case, Sinusoidal position embeddings are IMO also not general enough to be in the templates
  • modeling_bart.py still has the add_layer_norm hacks which are not copied to the model templates. When Bart is separated into Pegasus, etc... those if-else hacks can be deleted from modeling_bart.py at which point some more # Copied from transformers.models.bart.modeling_bart... should be added to the Seq2Seq model templates

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 a lot for adding those!

@patrickvonplaten
Copy link
Contributor Author

Improvements to TFBart: #9252 are now included in this PR as well.

@patrickvonplaten patrickvonplaten merged commit cbe6394 into huggingface:master Dec 22, 2020
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.

2 participants