Unverified Commit 87e6e4fe authored by Sylvain Gugger's avatar Sylvain Gugger Committed by GitHub
Browse files

Doc styler v2 (#14950)

* New doc styler

* Fix issue with args at the start

* Code sample fixes

* Style code examples in MDX

* Fix more patterns

* Typo

* Typo

* More patterns

* Do without black for now

* Get more info in error

* Docstring style

* Re-enable check

* Quality

* Fix add_end_docstring decorator

* Fix docstring
parent c1138273
...@@ -72,9 +72,10 @@ SPIECE_UNDERLINE = "▁" ...@@ -72,9 +72,10 @@ SPIECE_UNDERLINE = "▁"
class AlbertTokenizerFast(PreTrainedTokenizerFast): class AlbertTokenizerFast(PreTrainedTokenizerFast):
""" """
Construct a "fast" ALBERT tokenizer (backed by HuggingFace's *tokenizers* library). Based on [Unigram](https://huggingface.co/docs/tokenizers/python/latest/components.html?highlight=unigram#models). This tokenizer Construct a "fast" ALBERT tokenizer (backed by HuggingFace's *tokenizers* library). Based on
inherits from [`PreTrainedTokenizerFast`] which contains most of the main methods. Users should [Unigram](https://huggingface.co/docs/tokenizers/python/latest/components.html?highlight=unigram#models). This
refer to this superclass for more information regarding those methods tokenizer inherits from [`PreTrainedTokenizerFast`] which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods
Args: Args:
vocab_file (`str`): vocab_file (`str`):
...@@ -213,8 +214,7 @@ class AlbertTokenizerFast(PreTrainedTokenizerFast): ...@@ -213,8 +214,7 @@ class AlbertTokenizerFast(PreTrainedTokenizerFast):
Optional second list of IDs for sequence pairs. Optional second list of IDs for sequence pairs.
Returns: Returns:
`List[int]`: List of [token type IDs](../glossary#token-type-ids) according to the given `List[int]`: List of [token type IDs](../glossary#token-type-ids) according to the given sequence(s).
sequence(s).
""" """
sep = [self.sep_token_id] sep = [self.sep_token_id]
cls = [self.cls_token_id] cls = [self.cls_token_id]
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" Auto Config class. """ """ Auto Config class."""
import importlib import importlib
import re import re
import warnings import warnings
...@@ -501,9 +501,8 @@ class AutoConfig: ...@@ -501,9 +501,8 @@ class AutoConfig:
r""" r"""
Instantiate one of the configuration classes of the library from a pretrained model configuration. Instantiate one of the configuration classes of the library from a pretrained model configuration.
The configuration class to instantiate is selected based on the `model_type` property of the config object The configuration class to instantiate is selected based on the `model_type` property of the config object that
that is loaded, or when it's missing, by falling back to using pattern matching on is loaded, or when it's missing, by falling back to using pattern matching on `pretrained_model_name_or_path`:
`pretrained_model_name_or_path`:
List options List options
...@@ -515,8 +514,8 @@ class AutoConfig: ...@@ -515,8 +514,8 @@ class AutoConfig:
huggingface.co. Valid model ids can be located at the root-level, like `bert-base-uncased`, or huggingface.co. Valid model ids can be located at the root-level, like `bert-base-uncased`, or
namespaced under a user or organization name, like `dbmdz/bert-base-german-cased`. namespaced under a user or organization name, like `dbmdz/bert-base-german-cased`.
- A path to a *directory* containing a configuration file saved using the - A path to a *directory* containing a configuration file saved using the
[`~PretrainedConfig.save_pretrained`] method, or the [`~PretrainedConfig.save_pretrained`] method, or the [`~PreTrainedModel.save_pretrained`] method,
[`~PreTrainedModel.save_pretrained`] method, e.g., `./my_model_directory/`. e.g., `./my_model_directory/`.
- A path or url to a saved configuration JSON *file*, e.g., - A path or url to a saved configuration JSON *file*, e.g.,
`./my_model_directory/configuration.json`. `./my_model_directory/configuration.json`.
cache_dir (`str` or `os.PathLike`, *optional*): cache_dir (`str` or `os.PathLike`, *optional*):
...@@ -529,7 +528,8 @@ class AutoConfig: ...@@ -529,7 +528,8 @@ class AutoConfig:
Whether or not to delete incompletely received files. Will attempt to resume the download if such a Whether or not to delete incompletely received files. Will attempt to resume the download if such a
file exists. file exists.
proxies (`Dict[str, str]`, *optional*): proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request.
revision(`str`, *optional*, defaults to `"main"`): revision(`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
...@@ -537,13 +537,13 @@ class AutoConfig: ...@@ -537,13 +537,13 @@ class AutoConfig:
return_unused_kwargs (`bool`, *optional*, defaults to `False`): return_unused_kwargs (`bool`, *optional*, defaults to `False`):
If `False`, then this function returns just the final configuration object. If `False`, then this function returns just the final configuration object.
If `True`, then this functions returns a `Tuple(config, unused_kwargs)` where *unused_kwargs* If `True`, then this functions returns a `Tuple(config, unused_kwargs)` where *unused_kwargs* is a
is a dictionary consisting of the key/value pairs whose keys are not configuration attributes: i.e., dictionary consisting of the key/value pairs whose keys are not configuration attributes: i.e., the
the part of `kwargs` which has not been used to update `config` and is otherwise ignored. part of `kwargs` which has not been used to update `config` and is otherwise ignored.
trust_remote_code (`bool`, *optional*, defaults to `False`): trust_remote_code (`bool`, *optional*, defaults to `False`):
Whether or not to allow for custom models defined on the Hub in their own modeling files. This option Whether or not to allow for custom models defined on the Hub in their own modeling files. This option
should only be set to `True` for repositories you trust and in which you have read the code, as it should only be set to `True` for repositories you trust and in which you have read the code, as it will
will execute code present on the Hub on your local machine. execute code present on the Hub on your local machine.
kwargs(additional keyword arguments, *optional*): kwargs(additional keyword arguments, *optional*):
The values in kwargs of any keys which are configuration attributes will be used to override the loaded The values in kwargs of any keys which are configuration attributes will be used to override the loaded
values. Behavior concerning key/value pairs whose keys are *not* configuration attributes is controlled values. Behavior concerning key/value pairs whose keys are *not* configuration attributes is controlled
......
...@@ -122,8 +122,8 @@ def get_class_from_dynamic_module( ...@@ -122,8 +122,8 @@ def get_class_from_dynamic_module(
<Tip warning={true}> <Tip warning={true}>
Calling this function will execute the code in the module file found locally or downloaded from the Hub. It Calling this function will execute the code in the module file found locally or downloaded from the Hub. It should
should therefore only be called on trusted repos. therefore only be called on trusted repos.
</Tip> </Tip>
...@@ -132,8 +132,8 @@ def get_class_from_dynamic_module( ...@@ -132,8 +132,8 @@ def get_class_from_dynamic_module(
This can be either: This can be either:
- a string, the *model id* of a pretrained model configuration hosted inside a model repo on - a string, the *model id* of a pretrained model configuration hosted inside a model repo on
huggingface.co. Valid model ids can be located at the root-level, like `bert-base-uncased`, or huggingface.co. Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced
namespaced under a user or organization name, like `dbmdz/bert-base-german-cased`. under a user or organization name, like `dbmdz/bert-base-german-cased`.
- a path to a *directory* containing a configuration file saved using the - a path to a *directory* containing a configuration file saved using the
[`~PreTrainedTokenizer.save_pretrained`] method, e.g., `./my_model_directory/`. [`~PreTrainedTokenizer.save_pretrained`] method, e.g., `./my_model_directory/`.
...@@ -150,10 +150,11 @@ def get_class_from_dynamic_module( ...@@ -150,10 +150,11 @@ def get_class_from_dynamic_module(
resume_download (`bool`, *optional*, defaults to `False`): resume_download (`bool`, *optional*, defaults to `False`):
Whether or not to delete incompletely received file. Attempts to resume the download if such a file exists. Whether or not to delete incompletely received file. Attempts to resume the download if such a file exists.
proxies (`Dict[str, str]`, *optional*): proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request. A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
use_auth_token (`str` or *bool*, *optional*): use_auth_token (`str` or *bool*, *optional*):
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
generated when running `transformers-cli login` (stored in `~/.huggingface`). when running `transformers-cli login` (stored in `~/.huggingface`).
revision(`str`, *optional*, defaults to `"main"`): revision(`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" AutoFeatureExtractor class. """ """ AutoFeatureExtractor class."""
import importlib import importlib
import os import os
from collections import OrderedDict from collections import OrderedDict
...@@ -82,9 +82,9 @@ class AutoFeatureExtractor: ...@@ -82,9 +82,9 @@ class AutoFeatureExtractor:
r""" r"""
Instantiate one of the feature extractor classes of the library from a pretrained model vocabulary. Instantiate one of the feature extractor classes of the library from a pretrained model vocabulary.
The feature extractor class to instantiate is selected based on the `model_type` property of the config The feature extractor class to instantiate is selected based on the `model_type` property of the config object
object (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible), or when (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible), or when it's
it's missing, by falling back to using pattern matching on `pretrained_model_name_or_path`: missing, by falling back to using pattern matching on `pretrained_model_name_or_path`:
List options List options
...@@ -110,19 +110,20 @@ class AutoFeatureExtractor: ...@@ -110,19 +110,20 @@ class AutoFeatureExtractor:
Whether or not to delete incompletely received file. Attempts to resume the download if such a file Whether or not to delete incompletely received file. Attempts to resume the download if such a file
exists. exists.
proxies (`Dict[str, str]`, *optional*): proxies (`Dict[str, str]`, *optional*):
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request. A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
use_auth_token (`str` or *bool*, *optional*): use_auth_token (`str` or *bool*, *optional*):
The token to use as HTTP bearer authorization for remote files. If `True`, will use the token The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
generated when running `transformers-cli login` (stored in `~/.huggingface`). when running `transformers-cli login` (stored in `~/.huggingface`).
revision(`str`, *optional*, defaults to `"main"`): revision(`str`, *optional*, defaults to `"main"`):
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
identifier allowed by git. identifier allowed by git.
return_unused_kwargs (`bool`, *optional*, defaults to `False`): return_unused_kwargs (`bool`, *optional*, defaults to `False`):
If `False`, then this function returns just the final feature extractor object. If `True`, If `False`, then this function returns just the final feature extractor object. If `True`, then this
then this functions returns a `Tuple(feature_extractor, unused_kwargs)` where *unused_kwargs* is a functions returns a `Tuple(feature_extractor, unused_kwargs)` where *unused_kwargs* is a dictionary
dictionary consisting of the key/value pairs whose keys are not feature extractor attributes: i.e., the consisting of the key/value pairs whose keys are not feature extractor attributes: i.e., the part of
part of `kwargs` which has not been used to update `feature_extractor` and is otherwise ignored. `kwargs` which has not been used to update `feature_extractor` and is otherwise ignored.
kwargs (`Dict[str, Any]`, *optional*): kwargs (`Dict[str, Any]`, *optional*):
The values in kwargs of any keys which are feature extractor attributes will be used to override the The values in kwargs of any keys which are feature extractor attributes will be used to override the
loaded values. Behavior concerning key/value pairs whose keys are *not* feature extractor attributes is loaded values. Behavior concerning key/value pairs whose keys are *not* feature extractor attributes is
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" Auto Model class. """ """ Auto Model class."""
import warnings import warnings
from collections import OrderedDict from collections import OrderedDict
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment