fix bug in DPO data collator

Former-commit-id: 4fc262cdf1347691e253bdfbd96568db5a49c086
This commit is contained in:
hiyouga 2023-09-08 20:45:07 +08:00
parent e70b3e8947
commit 692b132dbf

View File

@ -16,7 +16,7 @@ class DPODataCollatorWithPadding(DataCollatorForSeq2Seq):
if self.tokenizer.padding_side == "left":
start, end = feature.size(0) - answer_len, feature.size(0)
else:
start, end = prompt_len, answer_len
start, end = prompt_len, prompt_len + answer_len
padded_tensor = self.label_pad_token_id * torch.ones_like(feature)
padded_tensor[start:end] = feature[start:end]
padded_labels.append(padded_tensor)