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

Fix 9918 #9932

Merged
merged 2 commits into from
Feb 2, 2021
Merged

Fix 9918 #9932

merged 2 commits into from
Feb 2, 2021

Conversation

sgugger
Copy link
Collaborator

@sgugger sgugger commented Feb 1, 2021

What does this PR do?

This PR addresses the problem shown in #9918 by:

  • adding the documentation of the encode method to the PreTrainedTokenizer and PreTrainedTokenizerFast (it is in all their subclasses already)
  • adding the "What are input IDs" link where missing in some models docstrings.

In passing, I uncovered a failure of the doc styling script on DPR, so this PR also fixes that.

Fixes #9918

@sgugger sgugger requested a review from LysandreJik February 1, 2021 21:23
@@ -486,22 +486,26 @@ def serving(self, inputs):

(a) For sequence pairs (for a pair title+text for example):

``tokens: [CLS] is this jack ##son ##ville ? [SEP] no it is not . [SEP]``
::
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That docstring had been changed to work around the doc-styling failure. This makes it the same as the PyTorch one,

Comment on lines +138 to +144
def end_of_special_style(self, line):
"""
Sets back the `in_block` attribute to `NOT_SPECIAL`.

Useful for some docstrings where we may have to go back to `ARG_LIST` instead.
"""
self.in_block = SpecialBlock.NOT_SPECIAL
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically the problem was that when a code block was nested in the argument list, we were returning to a not special style instead of returning to an arg list style. This new method overriden in the subclass DocStyler ensures we return to the proper type.

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for updating all of these! LGTM!

@LysandreJik LysandreJik merged commit de38a6e into master Feb 2, 2021
@LysandreJik LysandreJik deleted the fix_9918 branch February 2, 2021 10:22
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.

[doc] transformers.PreTrainedTokenizer.encode() doesn't get resolved to its doc
2 participants