add max_length to showcase the use of truncation (#8975)

This commit is contained in:
Navjot 2020-12-07 15:35:39 -08:00 committed by GitHub
parent 62d30e0583
commit c108d0b5a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -182,6 +182,7 @@ and get tensors back. You can specify all of that to the tokenizer:
... ["We are very happy to show you the 🤗 Transformers library.", "We hope you don't hate it."],
... padding=True,
... truncation=True,
... max_length=512,
... return_tensors="pt"
... )
>>> ## TENSORFLOW CODE
@ -189,6 +190,7 @@ and get tensors back. You can specify all of that to the tokenizer:
... ["We are very happy to show you the 🤗 Transformers library.", "We hope you don't hate it."],
... padding=True,
... truncation=True,
... max_length=512,
... return_tensors="tf"
... )