mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-04 21:30:07 +06:00

* Fixed typo: insted to instead * Fixed typo: relase to release * Fixed typo: nighlty to nightly * Fixed typos: versatible, benchamarks, becnhmark to versatile, benchmark, benchmarks * Fixed typo in comment: quantizd to quantized * Fixed typo: architecutre to architecture * Fixed typo: contibution to contribution * Fixed typo: Presequities to Prerequisites * Fixed typo: faste to faster * Fixed typo: extendeding to extending * Fixed typo: segmetantion_maps to segmentation_maps * Fixed typo: Alternativelly to Alternatively * Fixed incorrectly defined variable: output to output_disabled * Fixed typo in library name: tranformers.onnx to transformers.onnx * Fixed missing import: import tensorflow as tf * Fixed incorrectly defined variable: token_tensor to tokens_tensor * Fixed missing import: import torch * Fixed incorrectly defined variable and typo: uromaize to uromanize * Fixed incorrectly defined variable and typo: uromaize to uromanize * Fixed typo in function args: numpy.ndarry to numpy.ndarray * Fixed Inconsistent Library Name: Torchscript to TorchScript * Fixed Inconsistent Class Name: OneformerProcessor to OneFormerProcessor * Fixed Inconsistent Class Named Typo: TFLNetForMultipleChoice to TFXLNetForMultipleChoice * Fixed Inconsistent Library Name Typo: Pytorch to PyTorch * Fixed Inconsistent Function Name Typo: captureWarning to captureWarnings * Fixed Inconsistent Library Name Typo: Pytorch to PyTorch * Fixed Inconsistent Class Name Typo: TrainingArgument to TrainingArguments * Fixed Inconsistent Model Name Typo: Swin2R to Swin2SR * Fixed Inconsistent Model Name Typo: EART to BERT * Fixed Inconsistent Library Name Typo: TensorFLow to TensorFlow * Fixed Broken Link for Speech Emotion Classification with Wav2Vec2 * Fixed minor missing word Typo * Fixed minor missing word Typo * Fixed minor missing word Typo * Fixed minor missing word Typo * Fixed minor missing word Typo * Fixed minor missing word Typo * Fixed minor missing word Typo * Fixed minor missing word Typo * Fixed Punctuation: Two commas * Fixed Punctuation: No Space between XLM-R and is * Fixed Punctuation: No Space between [~accelerate.Accelerator.backward] and method * Added backticks to display model.fit() in codeblock * Added backticks to display openai-community/gpt2 in codeblock * Fixed Minor Typo: will to with * Fixed Minor Typo: is to are * Fixed Minor Typo: in to on * Fixed Minor Typo: inhibits to exhibits * Fixed Minor Typo: they need to it needs * Fixed Minor Typo: cast the load the checkpoints To load the checkpoints * Fixed Inconsistent Class Name Typo: TFCamembertForCasualLM to TFCamembertForCausalLM * Fixed typo in attribute name: outputs.last_hidden_states to outputs.last_hidden_state * Added missing verbosity level: fatal * Fixed Minor Typo: take To takes * Fixed Minor Typo: heuristic To heuristics * Fixed Minor Typo: setting To settings * Fixed Minor Typo: Content To Contents * Fixed Minor Typo: millions To million * Fixed Minor Typo: difference To differences * Fixed Minor Typo: while extract To which extracts * Fixed Minor Typo: Hereby To Here * Fixed Minor Typo: addition To additional * Fixed Minor Typo: supports To supported * Fixed Minor Typo: so that benchmark results TO as a consequence, benchmark * Fixed Minor Typo: a To an * Fixed Minor Typo: a To an * Fixed Minor Typo: Chain-of-though To Chain-of-thought
120 lines
4.4 KiB
Markdown
120 lines
4.4 KiB
Markdown
<!--Copyright 2020 The HuggingFace Team. All rights reserved.
|
|
|
|
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.
|
|
|
|
⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
|
|
rendered properly in your Markdown viewer.
|
|
|
|
-->
|
|
|
|
# Logging
|
|
|
|
🤗 Transformers has a centralized logging system, so that you can setup the verbosity of the library easily.
|
|
|
|
Currently the default verbosity of the library is `WARNING`.
|
|
|
|
To change the level of verbosity, just use one of the direct setters. For instance, here is how to change the verbosity
|
|
to the INFO level.
|
|
|
|
```python
|
|
import transformers
|
|
|
|
transformers.logging.set_verbosity_info()
|
|
```
|
|
|
|
You can also use the environment variable `TRANSFORMERS_VERBOSITY` to override the default verbosity. You can set it
|
|
to one of the following: `debug`, `info`, `warning`, `error`, `critical`, `fatal`. For example:
|
|
|
|
```bash
|
|
TRANSFORMERS_VERBOSITY=error ./myprogram.py
|
|
```
|
|
|
|
Additionally, some `warnings` can be disabled by setting the environment variable
|
|
`TRANSFORMERS_NO_ADVISORY_WARNINGS` to a true value, like *1*. This will disable any warning that is logged using
|
|
[`logger.warning_advice`]. For example:
|
|
|
|
```bash
|
|
TRANSFORMERS_NO_ADVISORY_WARNINGS=1 ./myprogram.py
|
|
```
|
|
|
|
Here is an example of how to use the same logger as the library in your own module or script:
|
|
|
|
```python
|
|
from transformers.utils import logging
|
|
|
|
logging.set_verbosity_info()
|
|
logger = logging.get_logger("transformers")
|
|
logger.info("INFO")
|
|
logger.warning("WARN")
|
|
```
|
|
|
|
|
|
All the methods of this logging module are documented below, the main ones are
|
|
[`logging.get_verbosity`] to get the current level of verbosity in the logger and
|
|
[`logging.set_verbosity`] to set the verbosity to the level of your choice. In order (from the least
|
|
verbose to the most verbose), those levels (with their corresponding int values in parenthesis) are:
|
|
|
|
- `transformers.logging.CRITICAL` or `transformers.logging.FATAL` (int value, 50): only report the most
|
|
critical errors.
|
|
- `transformers.logging.ERROR` (int value, 40): only report errors.
|
|
- `transformers.logging.WARNING` or `transformers.logging.WARN` (int value, 30): only reports error and
|
|
warnings. This is the default level used by the library.
|
|
- `transformers.logging.INFO` (int value, 20): reports error, warnings and basic information.
|
|
- `transformers.logging.DEBUG` (int value, 10): report all information.
|
|
|
|
By default, `tqdm` progress bars will be displayed during model download. [`logging.disable_progress_bar`] and [`logging.enable_progress_bar`] can be used to suppress or unsuppress this behavior.
|
|
|
|
## `logging` vs `warnings`
|
|
|
|
Python has two logging systems that are often used in conjunction: `logging`, which is explained above, and `warnings`,
|
|
which allows further classification of warnings in specific buckets, e.g., `FutureWarning` for a feature or path
|
|
that has already been deprecated and `DeprecationWarning` to indicate an upcoming deprecation.
|
|
|
|
We use both in the `transformers` library. We leverage and adapt `logging`'s `captureWarnings` method to allow
|
|
management of these warning messages by the verbosity setters above.
|
|
|
|
What does that mean for developers of the library? We should respect the following heuristics:
|
|
- `warnings` should be favored for developers of the library and libraries dependent on `transformers`
|
|
- `logging` should be used for end-users of the library using it in every-day projects
|
|
|
|
See reference of the `captureWarnings` method below.
|
|
|
|
[[autodoc]] logging.captureWarnings
|
|
|
|
## Base setters
|
|
|
|
[[autodoc]] logging.set_verbosity_error
|
|
|
|
[[autodoc]] logging.set_verbosity_warning
|
|
|
|
[[autodoc]] logging.set_verbosity_info
|
|
|
|
[[autodoc]] logging.set_verbosity_debug
|
|
|
|
## Other functions
|
|
|
|
[[autodoc]] logging.get_verbosity
|
|
|
|
[[autodoc]] logging.set_verbosity
|
|
|
|
[[autodoc]] logging.get_logger
|
|
|
|
[[autodoc]] logging.enable_default_handler
|
|
|
|
[[autodoc]] logging.disable_default_handler
|
|
|
|
[[autodoc]] logging.enable_explicit_format
|
|
|
|
[[autodoc]] logging.reset_format
|
|
|
|
[[autodoc]] logging.enable_progress_bar
|
|
|
|
[[autodoc]] logging.disable_progress_bar
|