We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a94105f commit 72c6e8bCopy full SHA for 72c6e8b
docs/source/model_doc/t5.rst
@@ -191,10 +191,8 @@ language modeling head on top of the decoder.
191
labels = target_encoding.input_ids
192
193
# 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
- ]
197
labels = torch.tensor(labels)
+ labels[labels == tokenizer.pad_token_id] = -100
198
199
# forward pass
200
loss = model(input_ids=input_ids, attention_mask=attention_mask, labels=labels).loss
0 commit comments