fix SFT trainer
This commit is contained in:
parent
f4e4a04529
commit
d8cf8cfdeb
|
@ -33,10 +33,10 @@ class CustomSeq2SeqTrainer(Seq2SeqTrainer):
|
|||
|
||||
Subclass and override to inject custom behavior.
|
||||
"""
|
||||
labels = inputs["labels"].clone() if "labels" in inputs else None # backup labels
|
||||
if self.args.predict_with_generate:
|
||||
assert self.tokenizer.padding_side == "left", "This method only accepts left-padded tensor."
|
||||
prompt_len, label_len = inputs["input_ids"].size(-1), inputs["labels"].size(-1)
|
||||
labels = inputs["labels"].clone()
|
||||
if prompt_len > label_len:
|
||||
inputs["labels"] = self._pad_tensors_to_target_len(inputs["labels"], inputs["input_ids"])
|
||||
if label_len > prompt_len:
|
||||
|
|
Loading…
Reference in New Issue