fix t5 training docstring (#7911)
This commit is contained in:
committed by
GitHub
parent
df1ddcedf2
commit
e3d2bee8d0
@@ -62,10 +62,10 @@ token. T5 can be trained / fine-tuned both in a supervised and unsupervised fash
|
|||||||
|
|
||||||
.. code-block::
|
.. code-block::
|
||||||
|
|
||||||
input_ids = tokenizer.encode('The <extra_id_0> walks in <extra_id_1> park', return_tensors='pt')
|
input_ids = tokenizer('The <extra_id_0> walks in <extra_id_1> park', return_tensors='pt').input_ids
|
||||||
labels = tokenizer.encode('<extra_id_0> cute dog <extra_id_1> the <extra_id_2> </s>', return_tensors='pt')
|
labels = tokenizer('<extra_id_0> cute dog <extra_id_1> the <extra_id_2>', return_tensors='pt').input_ids
|
||||||
# the forward function automatically creates the correct decoder_input_ids
|
# the forward function automatically creates the correct decoder_input_ids
|
||||||
model(input_ids=input_ids, labels=labels)
|
loss = model(input_ids=input_ids, labels=labels, return_dict=True).loss
|
||||||
|
|
||||||
- Supervised training
|
- Supervised training
|
||||||
|
|
||||||
@@ -75,10 +75,10 @@ token. T5 can be trained / fine-tuned both in a supervised and unsupervised fash
|
|||||||
|
|
||||||
.. code-block::
|
.. code-block::
|
||||||
|
|
||||||
input_ids = tokenizer.encode('translate English to German: The house is wonderful. </s>', return_tensors='pt')
|
input_ids = tokenizer('translate English to German: The house is wonderful.', return_tensors='pt').input_ids
|
||||||
labels = tokenizer.encode('Das Haus ist wunderbar. </s>', return_tensors='pt')
|
labels = tokenizer('Das Haus ist wunderbar.', return_tensors='pt').input_ids
|
||||||
# the forward function automatically creates the correct decoder_input_ids
|
# the forward function automatically creates the correct decoder_input_ids
|
||||||
model(input_ids=input_ids, labels=labels)
|
loss = model(input_ids=input_ids, labels=labels, return_dict=True).loss
|
||||||
|
|
||||||
|
|
||||||
T5Config
|
T5Config
|
||||||
|
|||||||
Reference in New Issue
Block a user