-
Notifications
You must be signed in to change notification settings - Fork 33.9k
[DocTest] Doctest for Electra Pytorch #16628
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
Changes from 2 commits
b34eb19
509ca47
ce8716b
c475e5e
bd3ab18
e6352b2
cca3a14
dc99180
09a272b
080e42d
389f661
4099817
3e26e78
af14c61
33cb211
4ef0abb
9db2eeb
5db2fcc
9a24b97
ab22966
d57da99
50f7da3
de66e69
de5638f
cadbb8c
d1ce7dd
454f586
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1102,6 +1102,8 @@ def forward( | |
| ... 0 | ||
| >>> ) # Batch size 1 | ||
| >>> logits = model(input_ids).logits | ||
|
|
||
|
|
||
| ```""" | ||
| return_dict = return_dict if return_dict is not None else self.config.use_return_dict | ||
|
|
||
|
|
@@ -1175,6 +1177,9 @@ def set_output_embeddings(self, word_embeddings): | |
| checkpoint=_CHECKPOINT_FOR_DOC, | ||
| output_type=MaskedLMOutput, | ||
| config_class=_CONFIG_FOR_DOC, | ||
| mask="[mask]", | ||
| expected_output="'togo'", | ||
| expected_loss=11.43, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To use Electra for mask LM task, we need checkpoints like https://huggingface.co/google/electra-small-generator You can find more with https://huggingface.co/models?pipeline_tag=fill-mask&sort=downloads&search=electra The is not good for Mask LM, since it is See https://huggingface.co/google/electra-small-discriminator |
||
| ) | ||
| def forward( | ||
| self, | ||
|
|
@@ -1256,9 +1261,11 @@ def __init__(self, config): | |
| @add_start_docstrings_to_model_forward(ELECTRA_INPUTS_DOCSTRING.format("batch_size, sequence_length")) | ||
| @add_code_sample_docstrings( | ||
| processor_class=_TOKENIZER_FOR_DOC, | ||
| checkpoint=_CHECKPOINT_FOR_DOC, | ||
| checkpoint="bhadresh-savani/electra-base-discriminator-finetuned-conll03-english ", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
| output_type=TokenClassifierOutput, | ||
| config_class=_CONFIG_FOR_DOC, | ||
| expected_output="['B-LOC', 'B-ORG', 'O', 'O', 'O', 'O', 'O', 'B-LOC', 'O', 'B-LOC', 'I-LOC']", | ||
| expected_loss=0.11, | ||
| ) | ||
| def forward( | ||
| self, | ||
|
|
@@ -1336,9 +1343,11 @@ def __init__(self, config): | |
| @add_start_docstrings_to_model_forward(ELECTRA_INPUTS_DOCSTRING.format("batch_size, sequence_length")) | ||
| @add_code_sample_docstrings( | ||
| processor_class=_TOKENIZER_FOR_DOC, | ||
| checkpoint=_CHECKPOINT_FOR_DOC, | ||
| checkpoint="deepset/electra-base-squad2", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
| output_type=QuestionAnsweringModelOutput, | ||
| config_class=_CONFIG_FOR_DOC, | ||
| expected_output="'a nice puppet'", | ||
| expected_loss=0.0, | ||
| ) | ||
| def forward( | ||
| self, | ||
|
|
@@ -1592,6 +1601,8 @@ def forward( | |
| >>> outputs = model(**inputs) | ||
|
|
||
| >>> prediction_logits = outputs.logits | ||
|
|
||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove these extra new lines :-) |
||
| ```""" | ||
| return_dict = return_dict if return_dict is not None else self.config.use_return_dict | ||
| if labels 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.
It would be a good idea to use the example shown here
https://huggingface.co/google/electra-small-discriminator