-
Notifications
You must be signed in to change notification settings - Fork 31.9k
MBartForConditionalGeneration #6441
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fe24b20
add MBartForConditionalGeneration
patil-suraj f8670ee
style
patil-suraj 5a31182
rebase and fixes
patil-suraj fbc028b
add mbart test in TEST_FILES_WITH_NO_COMMON_TESTS
patil-suraj 8c7d69b
fix docs
patil-suraj 3ecd8a4
don't ignore mbart
patil-suraj 2d49f98
doc
patil-suraj bb61b64
fix mbart fairseq link
patil-suraj 6527293
put mbart before bart
patil-suraj 674d68b
apply doc suggestions
patil-suraj 49f74a5
Merge branch 'master' into add-mbart-class
patil-suraj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| MBart | ||
| ---------------------------------------------------- | ||
| **DISCLAIMER:** If you see something strange, | ||
| file a `Github Issue <https://github.com/huggingface/transformers/issues/new?assignees=&labels=&template=bug-report.md&title>`__ and assign | ||
| @sshleifer | ||
|
|
||
| Overview | ||
| ~~~~~~~~~~~~~~~~~~~~~ | ||
| The MBart model was presented in `Multilingual Denoising Pre-training for Neural Machine Translation <https://arxiv.org/abs/2001.08210>`_ by Yinhan Liu, Jiatao Gu, Naman Goyal, Xian Li, Sergey Edunov | ||
| Marjan Ghazvininejad, Mike Lewis, Luke Zettlemoyer. According to the abstract, | ||
|
|
||
| MBART is a sequence-to-sequence denoising auto-encoder pre-trained on large-scale monolingual corpora in many languages using the BART objective. mBART is one of the first methods for pre-training a complete sequence-to-sequence model by denoising full texts in multiple languages, while previous approaches have focused only on the encoder, decoder, or reconstructing parts of the text. | ||
|
|
||
| The Authors' code can be found `here <https://github.com/pytorch/fairseq/tree/master/examples/mbart>`_ | ||
|
|
||
|
|
||
| MBartConfig | ||
| ~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: transformers.MBartConfig | ||
| :members: | ||
|
|
||
|
|
||
| MBartTokenizer | ||
| ~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: transformers.MBartTokenizer | ||
| :members: build_inputs_with_special_tokens, prepare_seq2seq_batch | ||
|
|
||
|
|
||
| MBartForConditionalGeneration | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: transformers.MBartForConditionalGeneration | ||
| :members: generate, forward | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # coding=utf-8 | ||
| # Copyright 2020 The Fairseq Authors and The HuggingFace Inc. team. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """ MBART configuration """ | ||
|
|
||
| import logging | ||
|
|
||
| from .configuration_bart import BartConfig | ||
|
|
||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| MBART_PRETRAINED_CONFIG_ARCHIVE_MAP = { | ||
| "facebook/mbart-large-en-ro": "https://s3.amazonaws.com/models.huggingface.co/bert/facebook/mbart-large-en-ro/config.json", | ||
| "facebook/mbart-large-cc25": "https://s3.amazonaws.com/models.huggingface.co/bert/facebook/mbart-large-cc25/config.json", | ||
| } | ||
|
|
||
|
|
||
| class MBartConfig(BartConfig): | ||
| model_type = "mbart" | ||
| """See real config values at https://s3.amazonaws.com/models.huggingface.co/bert/facebook/mbart-large-en-ro/config.json.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||||
| from .configuration_mbart import MBartConfig | ||||||
| from .file_utils import add_start_docstrings | ||||||
| from .modeling_bart import BartForConditionalGeneration | ||||||
|
|
||||||
|
|
||||||
| _CONFIG_FOR_DOC = "MBartConfig" | ||||||
| _TOKENIZER_FOR_DOC = "MBartTokenizer" | ||||||
|
|
||||||
| MBART_PRETRAINED_MODEL_ARCHIVE_LIST = [ | ||||||
| "facebook/mbart-large-cc25", | ||||||
| "facebook/mbart-large-en-ro", | ||||||
| # See all BART models at https://huggingface.co/models?filter=mbart | ||||||
|
||||||
| # See all BART models at https://huggingface.co/models?filter=mbart | |
| # See all multilingual BART models at https://huggingface.co/models?filter=mbart |
Outdated
Collaborator
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.
Suggested change
| This model is a PyTorch `torch.nn.Module <https://pytorch.org/docs/stable/nn.html#torch.nn.Module>`_ sub-class. | |
| This model is a PyTorch `torch.nn.Module <https://pytorch.org/docs/stable/nn.html#torch.nn.Module>`__ sub-class. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
(Using only one _ will cause sphinx to associate every here with that link or complain, so it's best to always use two _)