.. Copyright 2020 The HuggingFace Team and TFT 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. T5 Tokenizer ----------------------------------------------------------------------------------------------------------------------- Overview ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This page includes information about how to use T5Tokenizer with tensorflow-text. This tokenizer works in sync with :class:`~tf.data.Dataset` and so is useful for on the fly tokenization. .. code-block:: >>> from tf_transformers.models import T5TokenizerTFText >>> tokenizer = T5TokenizerTFText.from_pretrained("t5-small") >>> text = ['The following statements are true about sentences in English:', '', 'A new sentence begins with a capital letter.'] >>> inputs = {'text': text} >>> outputs = tokenizer(inputs) # Ragged Tensor Output # Dynamic Padding >>> tokenizer = T5TokenizerTFText.from_pretrained("t5-small", dynamic_padding=True) >>> text = ['The following statements are true about sentences in English:', '', 'A new sentence begins with a capital letter.'] >>> inputs = {'text': text} >>> outputs = tokenizer(inputs) # Dict of tf.Tensor # Static Padding >>> tokenizer = T5TokenizerTFText.from_pretrained("t5-small", pack_model_inputs=True) >>> text = ['The following statements are true about sentences in English:', '', 'A new sentence begins with a capital letter.'] >>> inputs = {'text': text} >>> outputs = tokenizer(inputs) # Dict of tf.Tensor # To Add Special Tokens >>> tokenizer = T5TokenizerTFText.from_pretrained("t5-small", add_special_tokens=True) T5TokenizerTFText ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. autoclass:: tf_transformers.models.T5TokenizerTFText :members: T5TokenizerLayer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. autoclass:: tf_transformers.models.T5TokenizerLayer :members: