Skip to content

Commit 72c6e8b

Browse files
author
Xing Han Lu
authored
Update t5.rst (huggingface#14776)
1 parent a94105f commit 72c6e8b

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

docs/source/model_doc/t5.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,8 @@ language modeling head on top of the decoder.
191191
labels = target_encoding.input_ids
192192
193193
# replace padding token id's of the labels by -100
194-
labels = [
195-
[(label if label != tokenizer.pad_token_id else -100) for label in labels_example] for labels_example in labels
196-
]
197194
labels = torch.tensor(labels)
195+
labels[labels == tokenizer.pad_token_id] = -100
198196
199197
# forward pass
200198
loss = model(input_ids=input_ids, attention_mask=attention_mask, labels=labels).loss

0 commit comments

Comments
 (0)