source
stringclasses
470 values
url
stringlengths
49
167
file_type
stringclasses
1 value
chunk
stringlengths
1
512
chunk_id
stringlengths
5
9
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#generation
.md
>>> translated_tokens = model.generate(**inputs, decoder_start_token_id=tokenizer.lang_code_to_id["en_XX"]) >>> tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[0] "Returns the maximum value of a b c." ```
293_4_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#resources
.md
- [Text classification task guide](../tasks/sequence_classification) - [Causal language modeling task guide](../tasks/language_modeling) - [Translation task guide](../tasks/translation) - [Summarization task guide](../tasks/summarization)
293_5_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartconfig
.md
This is the configuration class to store the configuration of a [`PLBartModel`]. It is used to instantiate an PLBART model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of the PLBART [uclanlp/plbart-base](https://huggingface.co/uclanlp/plbart-base) architecture. Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
293_6_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartconfig
.md
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the documentation from [`PretrainedConfig`] for more information. Args: vocab_size (`int`, *optional*, defaults to 50005): Vocabulary size of the PLBART model. Defines the number of different tokens that can be represented by the `inputs_ids` passed when calling [`PLBartModel`]. d_model (`int`, *optional*, defaults to 768): Dimensionality of the layers and the pooler layer.
293_6_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartconfig
.md
d_model (`int`, *optional*, defaults to 768): Dimensionality of the layers and the pooler layer. encoder_layers (`int`, *optional*, defaults to 6): Number of encoder layers. decoder_layers (`int`, *optional*, defaults to 6): Number of decoder layers. encoder_attention_heads (`int`, *optional*, defaults to 12): Number of attention heads for each attention layer in the Transformer encoder. decoder_attention_heads (`int`, *optional*, defaults to 12):
293_6_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartconfig
.md
decoder_attention_heads (`int`, *optional*, defaults to 12): Number of attention heads for each attention layer in the Transformer decoder. decoder_ffn_dim (`int`, *optional*, defaults to 3072): Dimensionality of the "intermediate" (often named feed-forward) layer in decoder. encoder_ffn_dim (`int`, *optional*, defaults to 3072): Dimensionality of the "intermediate" (often named feed-forward) layer in decoder. activation_function (`str` or `function`, *optional*, defaults to `"gelu"`):
293_6_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartconfig
.md
activation_function (`str` or `function`, *optional*, defaults to `"gelu"`): The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`, `"relu"`, `"silu"` and `"gelu_new"` are supported. dropout (`float`, *optional*, defaults to 0.1): The dropout probability for all fully connected layers in the embeddings, encoder, and pooler. attention_dropout (`float`, *optional*, defaults to 0.1): The dropout ratio for the attention probabilities.
293_6_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartconfig
.md
attention_dropout (`float`, *optional*, defaults to 0.1): The dropout ratio for the attention probabilities. activation_dropout (`float`, *optional*, defaults to 0.0): The dropout ratio for activations inside the fully connected layer. classifier_dropout (`float`, *optional*, defaults to 0.0): The dropout ratio for classifier. max_position_embeddings (`int`, *optional*, defaults to 1024): The maximum sequence length that this model might ever be used with. Typically set this to something large
293_6_5
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartconfig
.md
The maximum sequence length that this model might ever be used with. Typically set this to something large just in case (e.g., 512 or 1024 or 2048). init_std (`float`, *optional*, defaults to 0.02): The standard deviation of the truncated_normal_initializer for initializing all weight matrices. encoder_layerdrop (`float`, *optional*, defaults to 0.0): The LayerDrop probability for the encoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556) for more details.
293_6_6
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartconfig
.md
The LayerDrop probability for the encoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556) for more details. decoder_layerdrop (`float`, *optional*, defaults to 0.0): The LayerDrop probability for the decoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556) for more details. scale_embedding (`bool`, *optional*, defaults to `True`): Scale embeddings by diving by sqrt(d_model). use_cache (`bool`, *optional*, defaults to `True`):
293_6_7
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartconfig
.md
Scale embeddings by diving by sqrt(d_model). use_cache (`bool`, *optional*, defaults to `True`): Whether or not the model should return the last key/values attentions (not used by all models) forced_eos_token_id (`int`, *optional*, defaults to 2): The id of the token to force as the last generated token when `max_length` is reached. Usually set to `eos_token_id`. Example: ```python >>> from transformers import PLBartConfig, PLBartModel
293_6_8
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartconfig
.md
>>> # Initializing a PLBART uclanlp/plbart-base style configuration >>> configuration = PLBartConfig() >>> # Initializing a model (with random weights) from the uclanlp/plbart-base style configuration >>> model = PLBartModel(configuration) >>> # Accessing the model configuration >>> configuration = model.config ```
293_6_9
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbarttokenizer
.md
Construct an PLBART tokenizer. Adapted from [`RobertaTokenizer`] and [`XLNetTokenizer`]. Based on [SentencePiece](https://github.com/google/sentencepiece). The tokenization method is `<tokens> <eos> <language code>` for source language documents, and `<language code> <tokens> <eos>` for target language documents. Args: vocab_file (`str`): Path to the vocabulary file. src_lang (`str`, *optional*): A string representing the source language. tgt_lang (`str`, *optional*):
293_7_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbarttokenizer
.md
src_lang (`str`, *optional*): A string representing the source language. tgt_lang (`str`, *optional*): A string representing the target language. bos_token (`str`, *optional*, defaults to `"<s>"`): The start of sequence token. eos_token (`str`, *optional*, defaults to `"</s>"`): The end of sequence token. sep_token (`str`, *optional*, defaults to `"</s>"`): The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
293_7_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbarttokenizer
.md
The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for sequence classification or for a text and a question for question answering. It is also used as the last token of a sequence built with special tokens. cls_token (`str`, *optional*, defaults to `"<s>"`): The cls token, which is a special token used as the first token for all tasks. unk_token (`str`, *optional*, defaults to `"<unk>"`):
293_7_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbarttokenizer
.md
unk_token (`str`, *optional*, defaults to `"<unk>"`): The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this token instead. pad_token (`str`, *optional*, defaults to `"<pad>"`): The token used for padding, for example when batching sequences of different lengths. mask_token(`str`, *optional*, defaults to `"<mask>"`): The token used for masking values. This is the token used when training this model with masking tasks. This
293_7_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbarttokenizer
.md
The token used for masking values. This is the token used when training this model with masking tasks. This is only used in the `"base"` tokenizer type. For `"multi"` tokenizer, masking is never done for the downstream tasks. language_codes (`str`, *optional*, defaults to `"base"`): What language codes to use. Should be one of `"base"` or `"multi"`. sp_model_kwargs (`dict`, *optional*): Will be passed to the `SentencePieceProcessor.__init__()` method. The [Python wrapper for
293_7_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbarttokenizer
.md
sp_model_kwargs (`dict`, *optional*): Will be passed to the `SentencePieceProcessor.__init__()` method. The [Python wrapper for SentencePiece](https://github.com/google/sentencepiece/tree/master/python) can be used, among other things, to set: - `enable_sampling`: Enable subword regularization. - `nbest_size`: Sampling parameters for unigram. Invalid for BPE-Dropout. - `nbest_size = {0,1}`: No sampling is performed. - `nbest_size > 1`: samples from the nbest_size results.
293_7_5
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbarttokenizer
.md
- `nbest_size = {0,1}`: No sampling is performed. - `nbest_size > 1`: samples from the nbest_size results. - `nbest_size < 0`: assuming that nbest_size is infinite and samples from the all hypothesis (lattice) using forward-filtering-and-backward-sampling algorithm. - `alpha`: Smoothing parameter for unigram sampling, and dropout probability of merge operations for BPE-dropout. Examples: ```python >>> from transformers import PLBartTokenizer
293_7_6
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbarttokenizer
.md
>>> tokenizer = PLBartTokenizer.from_pretrained("uclanlp/plbart-python-en_XX", src_lang="python", tgt_lang="en_XX") >>> example_python_phrase = "def maximum(a,b,c):NEW_LINE_INDENTreturn max([a,b,c])" >>> expected_translation_english = "Returns the maximum value of a b c." >>> inputs = tokenizer(example_python_phrase, text_target=expected_translation_english, return_tensors="pt") ``` Methods: build_inputs_with_special_tokens
293_7_7
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartmodel
.md
The bare PLBART Model outputting raw hidden-states without any specific head on top. This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads etc.) This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
293_8_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartmodel
.md
etc.) This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and behavior. Parameters: config ([`PLBartConfig`]): Model configuration class with all the parameters of the model. Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the
293_8_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartmodel
.md
load the weights associated with the model, only the configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights. Methods: forward
293_8_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartforconditionalgeneration
.md
The PLBART Model with a language modeling head. Can be used for code-to-text, text-to-code and code-to-code. This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads etc.) This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
293_9_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartforconditionalgeneration
.md
etc.) This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and behavior. Parameters: config ([`PLBartConfig`]): Model configuration class with all the parameters of the model. Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the
293_9_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartforconditionalgeneration
.md
load the weights associated with the model, only the configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights. Methods: forward
293_9_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartforsequenceclassification
.md
PLBart model with a sequence classification/head on top (a linear layer on top of the pooled output) e.g. for code classification. This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads etc.) This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
293_10_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartforsequenceclassification
.md
etc.) This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and behavior. Parameters: config ([`PLBartConfig`]): Model configuration class with all the parameters of the model. Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the
293_10_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartforsequenceclassification
.md
load the weights associated with the model, only the configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights. Methods: forward
293_10_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/plbart.md
https://huggingface.co/docs/transformers/en/model_doc/plbart/#plbartforcausallm
.md
No docstring available for PLBartForCausalLM Methods: forward
293_11_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/
.md
<!--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
294_0_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/
.md
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. -->
294_0_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#t5
.md
<div class="flex flex-wrap space-x-1"> <a href="https://huggingface.co/models?filter=t5"> <img alt="Models" src="https://img.shields.io/badge/All_model_pages-t5-blueviolet"> </a> <a href="https://huggingface.co/spaces/docs-demos/t5-base"> <img alt="Spaces" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue"> </a> <a href="https://huggingface.co/papers/1910.10683"> <img alt="Paper page" src="https://img.shields.io/badge/Paper%20page-1910.10683-green"> </a> </div>
294_1_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#overview
.md
The T5 model was presented in [Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer](https://arxiv.org/pdf/1910.10683.pdf) by [Colin Raffel](https://huggingface.co/craffel), Noam Shazeer, [Adam Roberts](https://huggingface.co/adarob), Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, [Peter J. Liu](https://huggingface.co/peterjliu). The abstract from the paper is the following:
294_2_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#overview
.md
The abstract from the paper is the following: *Transfer learning, where a model is first pre-trained on a data-rich task before being fine-tuned on a downstream task, has emerged as a powerful technique in natural language processing (NLP). The effectiveness of transfer learning has given rise to a diversity of approaches, methodology, and practice. In this paper, we explore the landscape of
294_2_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#overview
.md
has given rise to a diversity of approaches, methodology, and practice. In this paper, we explore the landscape of transfer learning techniques for NLP by introducing a unified framework that converts every language problem into a text-to-text format. Our systematic study compares pretraining objectives, architectures, unlabeled datasets, transfer approaches, and other factors on dozens of language understanding tasks. By combining the insights from our exploration
294_2_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#overview
.md
approaches, and other factors on dozens of language understanding tasks. By combining the insights from our exploration with scale and our new "Colossal Clean Crawled Corpus", we achieve state-of-the-art results on many benchmarks covering summarization, question answering, text classification, and more. To facilitate future work on transfer learning for NLP, we release our dataset, pre-trained models, and code.* All checkpoints can be found on the [hub](https://huggingface.co/models?search=t5).
294_2_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#overview
.md
All checkpoints can be found on the [hub](https://huggingface.co/models?search=t5). This model was contributed by [thomwolf](https://huggingface.co/thomwolf). The original code can be found [here](https://github.com/google-research/text-to-text-transfer-transformer).
294_2_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#usage-tips
.md
- T5 is an encoder-decoder model pre-trained on a multi-task mixture of unsupervised and supervised tasks and for which each task is converted into a text-to-text format. T5 works well on a variety of tasks out-of-the-box by prepending a different prefix to the input corresponding to each task, e.g., for translation: *translate English to German: ...*, for summarization: *summarize: ...*.
294_3_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#usage-tips
.md
for summarization: *summarize: ...*. - The pretraining includes both supervised and self-supervised training. Supervised training is conducted on downstream tasks provided by the GLUE and SuperGLUE benchmarks (converting them into text-to-text tasks as explained above).
294_3_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#usage-tips
.md
- Self-supervised training uses corrupted tokens, by randomly removing 15% of the tokens and replacing them with individual sentinel tokens (if several consecutive tokens are marked for removal, the whole group is replaced with a single sentinel token). The input of the encoder is the corrupted sentence, the input of the decoder is the original sentence and the target is then the dropped out tokens delimited by their sentinel tokens.
294_3_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#usage-tips
.md
- T5 uses relative scalar embeddings. Encoder input padding can be done on the left and on the right. - See the [training](#training), [inference](#inference) and [resources](#resources) sections below for all details regarding usage. T5 comes in different sizes: - [google-t5/t5-small](https://huggingface.co/google-t5/t5-small) - [google-t5/t5-base](https://huggingface.co/google-t5/t5-base) - [google-t5/t5-large](https://huggingface.co/google-t5/t5-large)
294_3_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#usage-tips
.md
- [google-t5/t5-large](https://huggingface.co/google-t5/t5-large) - [google-t5/t5-3b](https://huggingface.co/google-t5/t5-3b) - [google-t5/t5-11b](https://huggingface.co/google-t5/t5-11b). Based on the original T5 model, Google has released some follow-up works: - **T5v1.1**: T5v1.1 is an improved version of T5 with some architectural tweaks, and is pre-trained on C4 only without mixing in the supervised tasks. Refer to the documentation of T5v1.1 which can be found [here](t5v1.1).
294_3_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#usage-tips
.md
mixing in the supervised tasks. Refer to the documentation of T5v1.1 which can be found [here](t5v1.1). - **mT5**: mT5 is a multilingual T5 model. It is pre-trained on the mC4 corpus, which includes 101 languages. Refer to the documentation of mT5 which can be found [here](mt5). - **byT5**: byT5 is a T5 model pre-trained on byte sequences rather than SentencePiece subword token sequences. Refer to the documentation of byT5 which can be found [here](byt5).
294_3_5
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#usage-tips
.md
to the documentation of byT5 which can be found [here](byt5). - **UL2**: UL2 is a T5 like model pretrained on various denoising objectives - **Flan-T5**: Flan is a pretraining methods that is based on prompting. The Flan-T5 are T5 models trained on the Flan collection of datasets which include: `taskmaster2`, `djaym7/wiki_dialog`, `deepmind/code_contests`, `lambada`, `gsm8k`, `aqua_rat`, `esnli`, `quasc` and `qed`.
294_3_6
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#usage-tips
.md
- **FLan-UL2** : the UL2 model finetuned using the "Flan" prompt tuning and dataset collection. - **UMT5**: UmT5 is a multilingual T5 model trained on an improved and refreshed mC4 multilingual corpus, 29 trillion characters across 107 language, using a new sampling method, UniMax. Refer to the documentation of mT5 which can be found [here](umt5).
294_3_7
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
T5 is an encoder-decoder model and converts all NLP problems into a text-to-text format. It is trained using teacher forcing. This means that for training, we always need an input sequence and a corresponding target sequence. The input sequence is fed to the model using `input_ids`. The target sequence is shifted to the right, i.e., prepended by a start-sequence token and fed to the decoder using the `decoder_input_ids`. In teacher-forcing style, the target
294_4_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
start-sequence token and fed to the decoder using the `decoder_input_ids`. In teacher-forcing style, the target sequence is then appended by the EOS token and corresponds to the `labels`. The PAD token is hereby used as the start-sequence token. T5 can be trained / fine-tuned both in a supervised and unsupervised fashion. One can use [`T5ForConditionalGeneration`] (or the Tensorflow/Flax variant), which includes the language modeling head on top of the decoder. - Unsupervised denoising training
294_4_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
language modeling head on top of the decoder. - Unsupervised denoising training In this setup, spans of the input sequence are masked by so-called sentinel tokens (*a.k.a* unique mask tokens) and the output sequence is formed as a concatenation of the same sentinel tokens and the *real* masked tokens. Each sentinel token represents a unique mask token for this sentence and should start with `<extra_id_0>`, `<extra_id_1>`, ... up to `<extra_id_99>`. As a default, 100 sentinel tokens are available in
294_4_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
`<extra_id_1>`, ... up to `<extra_id_99>`. As a default, 100 sentinel tokens are available in [`T5Tokenizer`]. For instance, the sentence "The cute dog walks in the park" with the masks put on "cute dog" and "the" should be processed as follows: ```python >>> from transformers import T5Tokenizer, T5ForConditionalGeneration
294_4_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
>>> tokenizer = T5Tokenizer.from_pretrained("google-t5/t5-small") >>> model = T5ForConditionalGeneration.from_pretrained("google-t5/t5-small") >>> input_ids = tokenizer("The <extra_id_0> walks in <extra_id_1> park", return_tensors="pt").input_ids >>> labels = tokenizer("<extra_id_0> cute dog <extra_id_1> the <extra_id_2>", return_tensors="pt").input_ids
294_4_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
>>> # the forward function automatically creates the correct decoder_input_ids >>> loss = model(input_ids=input_ids, labels=labels).loss >>> loss.item() 3.7837 ``` If you're interested in pre-training T5 on a new corpus, check out the [run_t5_mlm_flax.py](https://github.com/huggingface/transformers/tree/main/examples/flax/language-modeling) script in the Examples directory. - Supervised training
294_4_5
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
directory. - Supervised training In this setup, the input sequence and output sequence are a standard sequence-to-sequence input-output mapping. Suppose that we want to fine-tune the model for translation for example, and we have a training example: the input sequence "The house is wonderful." and output sequence "Das Haus ist wunderbar.", then they should be prepared for the model as follows: ```python >>> from transformers import T5Tokenizer, T5ForConditionalGeneration
294_4_6
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
>>> tokenizer = T5Tokenizer.from_pretrained("google-t5/t5-small") >>> model = T5ForConditionalGeneration.from_pretrained("google-t5/t5-small") >>> input_ids = tokenizer("translate English to German: The house is wonderful.", return_tensors="pt").input_ids >>> labels = tokenizer("Das Haus ist wunderbar.", return_tensors="pt").input_ids
294_4_7
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
>>> # the forward function automatically creates the correct decoder_input_ids >>> loss = model(input_ids=input_ids, labels=labels).loss >>> loss.item() 0.2542 ``` As you can see, only 2 inputs are required for the model in order to compute a loss: `input_ids` (which are the `input_ids` of the encoded input sequence) and `labels` (which are the `input_ids` of the encoded target sequence). The model will automatically create the `decoder_input_ids` based on the `labels`, by
294_4_8
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
target sequence). The model will automatically create the `decoder_input_ids` based on the `labels`, by shifting them one position to the right and prepending the `config.decoder_start_token_id`, which for T5 is equal to 0 (i.e. the id of the pad token). Also note the task prefix: we prepend the input sequence with 'translate English to German: ' before encoding it. This will help in improving the performance, as this task prefix was used during T5's pre-training.
294_4_9
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
during T5's pre-training. However, the example above only shows a single training example. In practice, one trains deep learning models in batches. This entails that we must pad/truncate examples to the same length. For encoder-decoder models, one typically defines a `max_source_length` and `max_target_length`, which determine the maximum length of the input and output sequences respectively (otherwise they are truncated). These should be carefully set depending on the task.
294_4_10
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
input and output sequences respectively (otherwise they are truncated). These should be carefully set depending on the task. In addition, we must make sure that padding token id's of the `labels` are not taken into account by the loss function. In PyTorch and Tensorflow, this can be done by replacing them with -100, which is the `ignore_index` of the `CrossEntropyLoss`. In Flax, one can use the `decoder_attention_mask` to ignore padded tokens from
294_4_11
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
of the `CrossEntropyLoss`. In Flax, one can use the `decoder_attention_mask` to ignore padded tokens from the loss (see the [Flax summarization script](https://github.com/huggingface/transformers/tree/main/examples/flax/summarization) for details). We also pass `attention_mask` as additional input to the model, which makes sure that padding tokens of the inputs are ignored. The code example below illustrates all of this. ```python >>> from transformers import T5Tokenizer, T5ForConditionalGeneration
294_4_12
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
```python >>> from transformers import T5Tokenizer, T5ForConditionalGeneration >>> import torch
294_4_13
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
>>> tokenizer = T5Tokenizer.from_pretrained("google-t5/t5-small") >>> model = T5ForConditionalGeneration.from_pretrained("google-t5/t5-small") >>> # the following 2 hyperparameters are task-specific >>> max_source_length = 512 >>> max_target_length = 128 >>> # Suppose we have the following 2 training examples: >>> input_sequence_1 = "Welcome to NYC" >>> output_sequence_1 = "Bienvenue Γ  NYC" >>> input_sequence_2 = "HuggingFace is a company" >>> output_sequence_2 = "HuggingFace est une entreprise"
294_4_14
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
>>> input_sequence_2 = "HuggingFace is a company" >>> output_sequence_2 = "HuggingFace est une entreprise" >>> # encode the inputs >>> task_prefix = "translate English to French: " >>> input_sequences = [input_sequence_1, input_sequence_2] >>> encoding = tokenizer( ... [task_prefix + sequence for sequence in input_sequences], ... padding="longest", ... max_length=max_source_length, ... truncation=True, ... return_tensors="pt", ... )
294_4_15
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
>>> input_ids, attention_mask = encoding.input_ids, encoding.attention_mask >>> # encode the targets >>> target_encoding = tokenizer( ... [output_sequence_1, output_sequence_2], ... padding="longest", ... max_length=max_target_length, ... truncation=True, ... return_tensors="pt", ... ) >>> labels = target_encoding.input_ids >>> # replace padding token id's of the labels by -100 so it's ignored by the loss >>> labels[labels == tokenizer.pad_token_id] = -100
294_4_16
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
>>> # forward pass >>> loss = model(input_ids=input_ids, attention_mask=attention_mask, labels=labels).loss >>> loss.item() 0.188 ``` Additional training tips: - T5 models need a slightly higher learning rate than the default one set in the `Trainer` when using the AdamW optimizer. Typically, 1e-4 and 3e-4 work well for most problems (classification, summarization, translation, question answering, question generation). Note that T5 was pre-trained using the AdaFactor optimizer.
294_4_17
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
answering, question generation). Note that T5 was pre-trained using the AdaFactor optimizer. According to [this forum post](https://discuss.huggingface.co/t/t5-finetuning-tips/684), task prefixes matter when (1) doing multi-task training (2) your task is similar or related to one of the supervised tasks used in T5's pre-training mixture (see Appendix D of the [paper](https://arxiv.org/pdf/1910.10683.pdf) for the task prefixes used).
294_4_18
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
pre-training mixture (see Appendix D of the [paper](https://arxiv.org/pdf/1910.10683.pdf) for the task prefixes used). If training on TPU, it is recommended to pad all examples of the dataset to the same length or make use of *pad_to_multiple_of* to have a small number of predefined bucket sizes to fit all examples in. Dynamically padding batches to the longest example is not recommended on TPU as it triggers a recompilation for every batch shape that is
294_4_19
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#training
.md
batches to the longest example is not recommended on TPU as it triggers a recompilation for every batch shape that is encountered during training thus significantly slowing down the training. only padding up to the longest example in a batch) leads to very slow training on TPU.
294_4_20
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#inference
.md
At inference time, it is recommended to use [`~generation.GenerationMixin.generate`]. This method takes care of encoding the input and feeding the encoded hidden states via cross-attention layers to the decoder and auto-regressively generates the decoder output. Check out [this blog post](https://huggingface.co/blog/how-to-generate) to know all the details about generating text with Transformers. There's also [this blog post](https://huggingface.co/blog/encoder-decoder#encoder-decoder) which explains how
294_5_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#inference
.md
There's also [this blog post](https://huggingface.co/blog/encoder-decoder#encoder-decoder) which explains how generation works in general in encoder-decoder models. ```python >>> from transformers import T5Tokenizer, T5ForConditionalGeneration
294_5_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#inference
.md
>>> tokenizer = T5Tokenizer.from_pretrained("google-t5/t5-small") >>> model = T5ForConditionalGeneration.from_pretrained("google-t5/t5-small")
294_5_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#inference
.md
>>> input_ids = tokenizer("translate English to German: The house is wonderful.", return_tensors="pt").input_ids >>> outputs = model.generate(input_ids) >>> print(tokenizer.decode(outputs[0], skip_special_tokens=True)) Das Haus ist wunderbar. ``` Note that T5 uses the `pad_token_id` as the `decoder_start_token_id`, so when doing generation without using [`~generation.GenerationMixin.generate`], make sure you start it with the `pad_token_id`.
294_5_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#inference
.md
[`~generation.GenerationMixin.generate`], make sure you start it with the `pad_token_id`. The example above only shows a single example. You can also do batched inference, like so: ```python >>> from transformers import T5Tokenizer, T5ForConditionalGeneration
294_5_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#inference
.md
>>> tokenizer = T5Tokenizer.from_pretrained("google-t5/t5-small") >>> model = T5ForConditionalGeneration.from_pretrained("google-t5/t5-small") >>> task_prefix = "translate English to German: " >>> # use different length sentences to test batching >>> sentences = ["The house is wonderful.", "I like to work in NYC."] >>> inputs = tokenizer([task_prefix + sentence for sentence in sentences], return_tensors="pt", padding=True)
294_5_5
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#inference
.md
>>> inputs = tokenizer([task_prefix + sentence for sentence in sentences], return_tensors="pt", padding=True) >>> output_sequences = model.generate( ... input_ids=inputs["input_ids"], ... attention_mask=inputs["attention_mask"], ... do_sample=False, # disable sampling to test if batching affects output ... )
294_5_6
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#inference
.md
>>> print(tokenizer.batch_decode(output_sequences, skip_special_tokens=True)) ['Das Haus ist wunderbar.', 'Ich arbeite gerne in NYC.'] ``` Because T5 has been trained with the span-mask denoising objective, it can be used to predict the sentinel (masked-out) tokens during inference. The predicted tokens will then be placed between the sentinel tokens. ```python >>> from transformers import T5Tokenizer, T5ForConditionalGeneration
294_5_7
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#inference
.md
>>> tokenizer = T5Tokenizer.from_pretrained("google-t5/t5-small") >>> model = T5ForConditionalGeneration.from_pretrained("google-t5/t5-small") >>> input_ids = tokenizer("The <extra_id_0> walks in <extra_id_1> park", return_tensors="pt").input_ids >>> sequence_ids = model.generate(input_ids) >>> sequences = tokenizer.batch_decode(sequence_ids) >>> sequences ['<pad> <extra_id_0> park offers <extra_id_1> the <extra_id_2> park.</s>'] ```
294_5_8
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#performance
.md
If you'd like a faster training and inference performance, install [NVIDIA APEX](https://github.com/NVIDIA/apex#quick-start) for NVIDIA GPUs, or [ROCm APEX](https://github.com/ROCmSoftwarePlatform/apex) for AMD GPUs and then the model will automatically use `apex.normalization.FusedRMSNorm` instead of `T5LayerNorm`. The former uses an optimized fused kernel which is several times faster than the latter.
294_6_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#resources
.md
A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with T5. If you're interested in submitting a resource to be included here, please feel free to open a Pull Request and we'll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource. <PipelineTag pipeline="text-classification"/>
294_7_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#resources
.md
<PipelineTag pipeline="text-classification"/> - A notebook for how to [finetune T5 for classification and multiple choice](https://colab.research.google.com/github/patil-suraj/exploring-T5/blob/master/t5_fine_tuning.ipynb). - A notebook for how to [finetune T5 for sentiment span extraction](https://colab.research.google.com/github/enzoampil/t5-intro/blob/master/t5_qa_training_pytorch_span_extraction.ipynb). 🌎 <PipelineTag pipeline="token-classification"/>
294_7_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#resources
.md
<PipelineTag pipeline="token-classification"/> - A notebook for how to [finetune T5 for named entity recognition](https://colab.research.google.com/drive/1obr78FY_cBmWY5ODViCmzdY6O1KB65Vc?usp=sharing). 🌎 <PipelineTag pipeline="text-generation"/> - A notebook for [Finetuning CodeT5 for generating docstrings from Ruby code](https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/T5/Fine_tune_CodeT5_for_generating_docstrings_from_Ruby_code.ipynb).
294_7_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#resources
.md
<PipelineTag pipeline="summarization"/> - A notebook to [Finetune T5-base-dutch to perform Dutch abstractive summarization on a TPU](https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/T5/Fine_tuning_Dutch_T5_base_on_CNN_Daily_Mail_for_summarization_(on_TPU_using_HuggingFace_Accelerate).ipynb).
294_7_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#resources
.md
- A notebook for how to [finetune T5 for summarization in PyTorch and track experiments with WandB](https://colab.research.google.com/github/abhimishra91/transformers-tutorials/blob/master/transformers_summarization_wandb.ipynb#scrollTo=OKRpFvYhBauC). 🌎 - A blog post on [Distributed Training: Train BART/T5 for Summarization using πŸ€— Transformers and Amazon SageMaker](https://huggingface.co/blog/sagemaker-distributed-training-seq2seq).
294_7_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#resources
.md
- [`T5ForConditionalGeneration`] is supported by this [example script](https://github.com/huggingface/transformers/tree/main/examples/pytorch/summarization) and [notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization.ipynb).
294_7_5
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#resources
.md
- [`TFT5ForConditionalGeneration`] is supported by this [example script](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/summarization) and [notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization-tf.ipynb). - [`FlaxT5ForConditionalGeneration`] is supported by this [example script](https://github.com/huggingface/transformers/tree/main/examples/flax/summarization).
294_7_6
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#resources
.md
- [Summarization](https://huggingface.co/course/chapter7/5?fw=pt#summarization) chapter of the πŸ€— Hugging Face course. - [Summarization task guide](../tasks/summarization) <PipelineTag pipeline="fill-mask"/>
294_7_7
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#resources
.md
- [`FlaxT5ForConditionalGeneration`] is supported by this [example script](https://github.com/huggingface/transformers/tree/main/examples/flax/language-modeling#t5-like-span-masked-language-modeling) for training T5 with a span-masked language model objective. The script also shows how to train a T5 tokenizer. [`FlaxT5ForConditionalGeneration`] is also supported by this [notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/masked_language_modeling_flax.ipynb).
294_7_8
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#resources
.md
<PipelineTag pipeline="translation"/> - [`T5ForConditionalGeneration`] is supported by this [example script](https://github.com/huggingface/transformers/tree/main/examples/pytorch/translation) and [notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/translation.ipynb).
294_7_9
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#resources
.md
- [`TFT5ForConditionalGeneration`] is supported by this [example script](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/translation) and [notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/translation-tf.ipynb). - [Translation task guide](../tasks/translation) <PipelineTag pipeline="question-answering"/>
294_7_10
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#resources
.md
- [Translation task guide](../tasks/translation) <PipelineTag pipeline="question-answering"/> - A notebook on how to [finetune T5 for question answering with TensorFlow 2](https://colab.research.google.com/github/snapthat/TF-T5-text-to-text/blob/master/snapthatT5/notebooks/TF-T5-Datasets%20Training.ipynb). 🌎 - A notebook on how to [finetune T5 for question answering on a TPU](https://colab.research.google.com/github/patil-suraj/exploring-T5/blob/master/T5_on_TPU.ipynb#scrollTo=QLGiFCDqvuil).
294_7_11
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#resources
.md
πŸš€ **Deploy** - A blog post on how to deploy [T5 11B for inference for less than $500](https://www.philschmid.de/deploy-t5-11b).
294_7_12
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#t5config
.md
This is the configuration class to store the configuration of a [`T5Model`] or a [`TFT5Model`]. It is used to instantiate a T5 model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of the T5 [google-t5/t5-small](https://huggingface.co/google-t5/t5-small) architecture. Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
294_8_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#t5config
.md
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the documentation from [`PretrainedConfig`] for more information. Arguments: vocab_size (`int`, *optional*, defaults to 32128): Vocabulary size of the T5 model. Defines the number of different tokens that can be represented by the `inputs_ids` passed when calling [`T5Model`] or [`TFT5Model`]. d_model (`int`, *optional*, defaults to 512): Size of the encoder layers and the pooler layer.
294_8_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#t5config
.md
d_model (`int`, *optional*, defaults to 512): Size of the encoder layers and the pooler layer. d_kv (`int`, *optional*, defaults to 64): Size of the key, query, value projections per attention head. The `inner_dim` of the projection layer will be defined as `num_heads * d_kv`. d_ff (`int`, *optional*, defaults to 2048): Size of the intermediate feed forward layer in each `T5Block`. num_layers (`int`, *optional*, defaults to 6): Number of hidden layers in the Transformer encoder.
294_8_2
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#t5config
.md
num_layers (`int`, *optional*, defaults to 6): Number of hidden layers in the Transformer encoder. num_decoder_layers (`int`, *optional*): Number of hidden layers in the Transformer decoder. Will use the same value as `num_layers` if not set. num_heads (`int`, *optional*, defaults to 8): Number of attention heads for each attention layer in the Transformer encoder. relative_attention_num_buckets (`int`, *optional*, defaults to 32): The number of buckets to use for each attention layer.
294_8_3
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#t5config
.md
relative_attention_num_buckets (`int`, *optional*, defaults to 32): The number of buckets to use for each attention layer. relative_attention_max_distance (`int`, *optional*, defaults to 128): The maximum distance of the longer sequences for the bucket separation. dropout_rate (`float`, *optional*, defaults to 0.1): The ratio for all dropout layers. classifier_dropout (`float`, *optional*, defaults to 0.0): The dropout ratio for classifier. layer_norm_eps (`float`, *optional*, defaults to 1e-6):
294_8_4
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#t5config
.md
The dropout ratio for classifier. layer_norm_eps (`float`, *optional*, defaults to 1e-6): The epsilon used by the layer normalization layers. initializer_factor (`float`, *optional*, defaults to 1): A factor for initializing all weight matrices (should be kept to 1, used internally for initialization testing). feed_forward_proj (`string`, *optional*, defaults to `"relu"`): Type of feed forward layer to be used. Should be one of `"relu"` or `"gated-gelu"`. T5v1.1 uses the
294_8_5
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#t5config
.md
Type of feed forward layer to be used. Should be one of `"relu"` or `"gated-gelu"`. T5v1.1 uses the `"gated-gelu"` feed forward projection. Original T5 uses `"relu"`. use_cache (`bool`, *optional*, defaults to `True`): Whether or not the model should return the last key/values attentions (not used by all models).
294_8_6
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#t5tokenizer
.md
Construct a T5 tokenizer. Based on [SentencePiece](https://github.com/google/sentencepiece). This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to this superclass for more information regarding those methods. Args: vocab_file (`str`): [SentencePiece](https://github.com/google/sentencepiece) file (generally has a *.spm* extension) that contains the vocabulary necessary to instantiate a tokenizer.
294_9_0
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#t5tokenizer
.md
contains the vocabulary necessary to instantiate a tokenizer. eos_token (`str`, *optional*, defaults to `"</s>"`): The end of sequence token. <Tip> When building a sequence using special tokens, this is not the token that is used for the end of sequence. The token used is the `sep_token`. </Tip> unk_token (`str`, *optional*, defaults to `"<unk>"`): The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this token instead.
294_9_1
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/t5.md
https://huggingface.co/docs/transformers/en/model_doc/t5/#t5tokenizer
.md
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this token instead. pad_token (`str`, *optional*, defaults to `"<pad>"`): The token used for padding, for example when batching sequences of different lengths. extra_ids (`int`, *optional*, defaults to 100): Add a number of extra ids added to the vocabulary for use as sentinels. These tokens are accessible as "<extra_id_{%d}>" where "{%d}" is a number between 0 and extra_ids-1. These tokens can be
294_9_2