mirror of
https://github.com/saymrwulf/transformers.git
synced 2026-05-14 20:58:08 +00:00
fix labels (#6213)
This commit is contained in:
parent
cedc547e7e
commit
0b41867357
1 changed files with 2 additions and 1 deletions
|
|
@ -87,7 +87,8 @@ class DataCollatorForLanguageModeling:
|
|||
return {"input_ids": inputs, "labels": labels}
|
||||
else:
|
||||
labels = batch.clone().detach()
|
||||
labels[labels == self.tokenizer.pad_token_id] = -100
|
||||
if self.tokenizer.pad_token_id is not None:
|
||||
labels[labels == self.tokenizer.pad_token_id] = -100
|
||||
return {"input_ids": batch, "labels": labels}
|
||||
|
||||
def _tensorize_batch(self, examples: List[torch.Tensor]) -> torch.Tensor:
|
||||
|
|
|
|||
Loading…
Reference in a new issue