From b960e9f9073c70dcc3b932782bf50d0cc5d138a5 Mon Sep 17 00:00:00 2001 From: patil-suraj Date: Tue, 5 Apr 2022 14:49:54 +0200 Subject: [PATCH 1/5] fix bart and mbart --- src/transformers/models/bart/modeling_bart.py | 14 ++++++++------ src/transformers/models/mbart/modeling_mbart.py | 16 +++++++++------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/transformers/models/bart/modeling_bart.py b/src/transformers/models/bart/modeling_bart.py index cfb4632a0958..b75f1c081b36 100755 --- a/src/transformers/models/bart/modeling_bart.py +++ b/src/transformers/models/bart/modeling_bart.py @@ -56,11 +56,12 @@ _EXPECTED_OUTPUT_SHAPE = [1, 8, 768] # SequenceClassification docstring -_SEQ_CLASS_EXPECTED_OUTPUT_SHAPE = [1, 2] +_SEQ_CLASS_EXPECTED_LOSS = 0.0 +_SEQ_CLASS_EXPECTED_OUTPUT = "'POSITIVE'" # QuestionAsnwering docstring -_QA_EXPECTED_LOSS = 2.98 -_QA_EXPECTED_OUTPUT_SHAPE = [1, 17] +_QA_EXPECTED_LOSS = 0.59 +_QA_EXPECTED_OUTPUT = "' nice puppet'" BART_PRETRAINED_MODEL_ARCHIVE_LIST = [ @@ -1447,10 +1448,11 @@ def __init__(self, config: BartConfig, **kwargs): @add_start_docstrings_to_model_forward(BART_INPUTS_DOCSTRING) @add_code_sample_docstrings( processor_class=_TOKENIZER_FOR_DOC, - checkpoint=_CHECKPOINT_FOR_DOC, + checkpoint="valhalla/bart-large-sst2", output_type=Seq2SeqSequenceClassifierOutput, config_class=_CONFIG_FOR_DOC, - expected_output=_SEQ_CLASS_EXPECTED_OUTPUT_SHAPE, + expected_output=_SEQ_CLASS_EXPECTED_OUTPUT, + expected_loss=_SEQ_CLASS_EXPECTED_LOSS, ) def forward( self, @@ -1576,7 +1578,7 @@ def __init__(self, config): output_type=Seq2SeqQuestionAnsweringModelOutput, config_class=_CONFIG_FOR_DOC, expected_loss=_QA_EXPECTED_LOSS, - expected_output=_QA_EXPECTED_OUTPUT_SHAPE, + expected_output=_QA_EXPECTED_OUTPUT, ) def forward( self, diff --git a/src/transformers/models/mbart/modeling_mbart.py b/src/transformers/models/mbart/modeling_mbart.py index 6ed7c24ab176..93fcfda7aa30 100755 --- a/src/transformers/models/mbart/modeling_mbart.py +++ b/src/transformers/models/mbart/modeling_mbart.py @@ -55,11 +55,12 @@ _EXPECTED_OUTPUT_SHAPE = [1, 8, 1024] # SequenceClassification docstring -_SEQ_CLASS_EXPECTED_OUTPUT_SHAPE = [1, 2] +_SEQ_CLASS_EXPECTED_LOSS = 0.69 +_SEQ_CLASS_EXPECTED_OUTPUT = "'LABEL_1'" # QuestionAsnwering docstring -_QA_EXPECTED_LOSS = 3.04 -_QA_EXPECTED_OUTPUT_SHAPE = [1, 16] +_QA_EXPECTED_LOSS = 3.55 +_QA_EXPECTED_OUTPUT = "'? Jim Henson was a'" MBART_PRETRAINED_MODEL_ARCHIVE_LIST = [ @@ -1437,10 +1438,11 @@ def __init__(self, config: MBartConfig, **kwargs): @add_start_docstrings_to_model_forward(MBART_INPUTS_DOCSTRING) @add_code_sample_docstrings( processor_class=_TOKENIZER_FOR_DOC, - checkpoint=_CHECKPOINT_FOR_DOC, + checkpoint="hf-internal-testing/tiny-random-mbart", output_type=Seq2SeqSequenceClassifierOutput, config_class=_CONFIG_FOR_DOC, - expected_output=_SEQ_CLASS_EXPECTED_OUTPUT_SHAPE, + expected_output=_SEQ_CLASS_EXPECTED_OUTPUT, + expected_loss=_SEQ_CLASS_EXPECTED_LOSS, ) # Copied from transformers.models.bart.modeling_bart.BartForSequenceClassification.forward def forward( @@ -1563,11 +1565,11 @@ def __init__(self, config): @add_start_docstrings_to_model_forward(MBART_INPUTS_DOCSTRING) @add_code_sample_docstrings( processor_class=_TOKENIZER_FOR_DOC, - checkpoint=_CHECKPOINT_FOR_DOC, + checkpoint="hf-internal-testing/tiny-random-mbart", output_type=Seq2SeqQuestionAnsweringModelOutput, config_class=_CONFIG_FOR_DOC, expected_loss=_QA_EXPECTED_LOSS, - expected_output=_QA_EXPECTED_OUTPUT_SHAPE, + expected_output=_QA_EXPECTED_OUTPUT, ) # Copied from transformers.models.bart.modeling_bart.BartForQuestionAnswering.forward def forward( From 17f9af40e65b5d5c708a7cd840df3bbea177d4c0 Mon Sep 17 00:00:00 2001 From: patil-suraj Date: Tue, 5 Apr 2022 16:14:05 +0200 Subject: [PATCH 2/5] add ckpt names as variables --- src/transformers/models/bart/modeling_bart.py | 6 ++++-- .../modeling_bigbird_pegasus.py | 20 +++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/transformers/models/bart/modeling_bart.py b/src/transformers/models/bart/modeling_bart.py index b75f1c081b36..8e5003a4efda 100755 --- a/src/transformers/models/bart/modeling_bart.py +++ b/src/transformers/models/bart/modeling_bart.py @@ -56,10 +56,12 @@ _EXPECTED_OUTPUT_SHAPE = [1, 8, 768] # SequenceClassification docstring +_CHECKPOINT_FOR_SEQUENCE_CLASSIFICATION = "valhalla/bart-large-sst2" _SEQ_CLASS_EXPECTED_LOSS = 0.0 _SEQ_CLASS_EXPECTED_OUTPUT = "'POSITIVE'" # QuestionAsnwering docstring +_CHECKPOINT_FOR_QA = "valhalla/bart-large-finetuned-squadv1" _QA_EXPECTED_LOSS = 0.59 _QA_EXPECTED_OUTPUT = "' nice puppet'" @@ -1448,7 +1450,7 @@ def __init__(self, config: BartConfig, **kwargs): @add_start_docstrings_to_model_forward(BART_INPUTS_DOCSTRING) @add_code_sample_docstrings( processor_class=_TOKENIZER_FOR_DOC, - checkpoint="valhalla/bart-large-sst2", + checkpoint=_CHECKPOINT_FOR_SEQUENCE_CLASSIFICATION, output_type=Seq2SeqSequenceClassifierOutput, config_class=_CONFIG_FOR_DOC, expected_output=_SEQ_CLASS_EXPECTED_OUTPUT, @@ -1574,7 +1576,7 @@ def __init__(self, config): @add_start_docstrings_to_model_forward(BART_INPUTS_DOCSTRING) @add_code_sample_docstrings( processor_class=_TOKENIZER_FOR_DOC, - checkpoint=_CHECKPOINT_FOR_DOC, + checkpoint=_CHECKPOINT_FOR_QA, output_type=Seq2SeqQuestionAnsweringModelOutput, config_class=_CONFIG_FOR_DOC, expected_loss=_QA_EXPECTED_LOSS, diff --git a/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py b/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py index 1fb8de8e1452..d7025193e930 100755 --- a/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py +++ b/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py @@ -51,17 +51,20 @@ _CHECKPOINT_FOR_DOC = "google/bigbird-pegasus-large-arxiv" _CONFIG_FOR_DOC = "BigBirdPegasusConfig" -_TOKENIZER_FOR_DOC = "PegasusTokenizer" +_TOKENIZER_FOR_DOC = "PegasusTokenizerFast" # Base model docstring _EXPECTED_OUTPUT_SHAPE = [1, 7, 1024] # SequenceClassification docstring -_SEQ_CLASS_EXPECTED_OUTPUT_SHAPE = [1, 2] +_CHECKPOINT_FOR_SEQUENCE_CLASSIFICATION = "hf-internal-testing/tiny-random-bigbird_pegasus" +_SEQ_CLASS_EXPECTED_LOSS = 0.69 +_SEQ_CLASS_EXPECTED_OUTPUT = "'LABEL_1'" # QuestionAsnwering docstring -_QA_EXPECTED_LOSS = 2.56 -_QA_EXPECTED_OUTPUT_SHAPE = [1, 12] +_CHECKPOINT_FOR_QA = "hf-internal-testing/tiny-random-bigbird_pegasus" +_QA_EXPECTED_LOSS = 3.96 +_QA_EXPECTED_OUTPUT = "''" BIGBIRD_PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST = [ @@ -2645,10 +2648,11 @@ def __init__(self, config: BigBirdPegasusConfig, **kwargs): @add_start_docstrings_to_model_forward(BIGBIRD_PEGASUS_INPUTS_DOCSTRING) @add_code_sample_docstrings( processor_class=_TOKENIZER_FOR_DOC, - checkpoint=_CHECKPOINT_FOR_DOC, + checkpoint=_CHECKPOINT_FOR_SEQUENCE_CLASSIFICATION, output_type=Seq2SeqSequenceClassifierOutput, config_class=_CONFIG_FOR_DOC, - expected_output=_SEQ_CLASS_EXPECTED_OUTPUT_SHAPE, + expected_output=_SEQ_CLASS_EXPECTED_OUTPUT, + expected_loss=_SEQ_CLASS_EXPECTED_LOSS, ) def forward( self, @@ -2771,11 +2775,11 @@ def __init__(self, config): @add_start_docstrings_to_model_forward(BIGBIRD_PEGASUS_INPUTS_DOCSTRING) @add_code_sample_docstrings( processor_class=_TOKENIZER_FOR_DOC, - checkpoint=_CHECKPOINT_FOR_DOC, + checkpoint=_CHECKPOINT_FOR_QA, output_type=Seq2SeqQuestionAnsweringModelOutput, config_class=_CONFIG_FOR_DOC, expected_loss=_QA_EXPECTED_LOSS, - expected_output=_QA_EXPECTED_OUTPUT_SHAPE, + expected_output=_QA_EXPECTED_OUTPUT, ) def forward( self, From 10233a18eccdfa2d5cb5688172126e788450b5fa Mon Sep 17 00:00:00 2001 From: patil-suraj Date: Tue, 5 Apr 2022 16:21:02 +0200 Subject: [PATCH 3/5] fix mbart --- src/transformers/models/mbart/modeling_mbart.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/transformers/models/mbart/modeling_mbart.py b/src/transformers/models/mbart/modeling_mbart.py index 93fcfda7aa30..ccf792489eb5 100755 --- a/src/transformers/models/mbart/modeling_mbart.py +++ b/src/transformers/models/mbart/modeling_mbart.py @@ -55,10 +55,12 @@ _EXPECTED_OUTPUT_SHAPE = [1, 8, 1024] # SequenceClassification docstring +_CHECKPOINT_FOR_SEQUENCE_CLASSIFICATION = "hf-internal-testing/tiny-random-mbart" _SEQ_CLASS_EXPECTED_LOSS = 0.69 _SEQ_CLASS_EXPECTED_OUTPUT = "'LABEL_1'" # QuestionAsnwering docstring +_CHECKPOINT_FOR_QA = "hf-internal-testing/tiny-random-mbart" _QA_EXPECTED_LOSS = 3.55 _QA_EXPECTED_OUTPUT = "'? Jim Henson was a'" @@ -1438,7 +1440,7 @@ def __init__(self, config: MBartConfig, **kwargs): @add_start_docstrings_to_model_forward(MBART_INPUTS_DOCSTRING) @add_code_sample_docstrings( processor_class=_TOKENIZER_FOR_DOC, - checkpoint="hf-internal-testing/tiny-random-mbart", + checkpoint=_CHECKPOINT_FOR_SEQUENCE_CLASSIFICATION, output_type=Seq2SeqSequenceClassifierOutput, config_class=_CONFIG_FOR_DOC, expected_output=_SEQ_CLASS_EXPECTED_OUTPUT, @@ -1565,7 +1567,7 @@ def __init__(self, config): @add_start_docstrings_to_model_forward(MBART_INPUTS_DOCSTRING) @add_code_sample_docstrings( processor_class=_TOKENIZER_FOR_DOC, - checkpoint="hf-internal-testing/tiny-random-mbart", + checkpoint=_CHECKPOINT_FOR_QA, output_type=Seq2SeqQuestionAnsweringModelOutput, config_class=_CONFIG_FOR_DOC, expected_loss=_QA_EXPECTED_LOSS, From a64cb9c88465c6fd96ee67a29ac228bffc6a73ab Mon Sep 17 00:00:00 2001 From: patil-suraj Date: Tue, 5 Apr 2022 16:44:16 +0200 Subject: [PATCH 4/5] fix plbart --- src/transformers/models/plbart/modeling_plbart.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/transformers/models/plbart/modeling_plbart.py b/src/transformers/models/plbart/modeling_plbart.py index 37230541e9db..f0f64e84e97f 100755 --- a/src/transformers/models/plbart/modeling_plbart.py +++ b/src/transformers/models/plbart/modeling_plbart.py @@ -54,7 +54,8 @@ _EXPECTED_OUTPUT_SHAPE = [1, 8, 768] # SequenceClassification docstring -_SEQ_CLASS_EXPECTED_OUTPUT_SHAPE = [1, 2] +_SEQ_CLASS_EXPECTED_OUTPUT = "'LABEL_1'" +_SEQ_CLASS_EXPECTED_LOSS = 0.69 PLBART_PRETRAINED_MODEL_ARCHIVE_LIST = [ @@ -1408,10 +1409,11 @@ def __init__(self, config: PLBartConfig, **kwargs): @add_start_docstrings_to_model_forward(PLBART_INPUTS_DOCSTRING) @add_code_sample_docstrings( processor_class=_TOKENIZER_FOR_DOC, - checkpoint=_CHECKPOINT_FOR_DOC, + checkpoint="hf-internal-testing/tiny-plbart", output_type=Seq2SeqSequenceClassifierOutput, config_class=_CONFIG_FOR_DOC, - expected_output=_SEQ_CLASS_EXPECTED_OUTPUT_SHAPE, + expected_output=_SEQ_CLASS_EXPECTED_OUTPUT, + expected_loss=_SEQ_CLASS_EXPECTED_LOSS, ) # Copied from transformers.models.bart.modeling_bart.BartForSequenceClassification.forward def forward( From 0764b0806329737383512dcd57f1700e7ccfe850 Mon Sep 17 00:00:00 2001 From: patil-suraj Date: Wed, 6 Apr 2022 11:31:40 +0200 Subject: [PATCH 5/5] use varibale for ckot name --- src/transformers/models/plbart/modeling_plbart.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/transformers/models/plbart/modeling_plbart.py b/src/transformers/models/plbart/modeling_plbart.py index f0f64e84e97f..af46fa8b449f 100755 --- a/src/transformers/models/plbart/modeling_plbart.py +++ b/src/transformers/models/plbart/modeling_plbart.py @@ -54,6 +54,7 @@ _EXPECTED_OUTPUT_SHAPE = [1, 8, 768] # SequenceClassification docstring +_CHECKPOINT_FOR_SEQUENCE_CLASSIFICATION = "hf-internal-testing/tiny-plbart" _SEQ_CLASS_EXPECTED_OUTPUT = "'LABEL_1'" _SEQ_CLASS_EXPECTED_LOSS = 0.69 @@ -1409,7 +1410,7 @@ def __init__(self, config: PLBartConfig, **kwargs): @add_start_docstrings_to_model_forward(PLBART_INPUTS_DOCSTRING) @add_code_sample_docstrings( processor_class=_TOKENIZER_FOR_DOC, - checkpoint="hf-internal-testing/tiny-plbart", + checkpoint=_CHECKPOINT_FOR_SEQUENCE_CLASSIFICATION, output_type=Seq2SeqSequenceClassifierOutput, config_class=_CONFIG_FOR_DOC, expected_output=_SEQ_CLASS_EXPECTED_OUTPUT,