From 2e5dbdf2db4599a6694d0974575a70f9bc3c978e Mon Sep 17 00:00:00 2001 From: Stas Bekman Date: Fri, 18 Jun 2021 10:00:19 -0700 Subject: [PATCH] [t5 doc] make the example work out of the box (#12239) * [run_clm.py] restore caching * style * [t5 doc] make the example work out of the box This PR expands the training example to include the correct model type for the example to work, e.g. with `T5Model` this example will break. * Update docs/source/model_doc/t5.rst Co-authored-by: Suraj Patil * expand the other example Co-authored-by: Suraj Patil --- docs/source/model_doc/t5.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/source/model_doc/t5.rst b/docs/source/model_doc/t5.rst index 7defbdbb74..3c1cd0a064 100644 --- a/docs/source/model_doc/t5.rst +++ b/docs/source/model_doc/t5.rst @@ -74,6 +74,10 @@ token. T5 can be trained / fine-tuned both in a supervised and unsupervised fash .. code-block:: + from transformers import T5ForConditionalGeneration, T5Tokenizer + model = T5ForConditionalGeneration.from_pretrained("t5-small") + tokenizer = T5Tokenizer.from_pretrained("t5-small") + input_ids = tokenizer('The walks in park', return_tensors='pt').input_ids labels = tokenizer(' cute dog the ', return_tensors='pt').input_ids # the forward function automatically creates the correct decoder_input_ids @@ -87,6 +91,10 @@ token. T5 can be trained / fine-tuned both in a supervised and unsupervised fash .. code-block:: + from transformers import T5ForConditionalGeneration, T5Tokenizer + model = T5ForConditionalGeneration.from_pretrained("t5-small") + tokenizer = T5Tokenizer.from_pretrained("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 # the forward function automatically creates the correct decoder_input_ids