仅仅训练最后一轮对话

Former-commit-id: ab6198e4c099edeb1a400f58729cd617e8cd8e50
This commit is contained in:
Shiyu Zhang
2024-07-18 15:30:25 +08:00
parent 341225a405
commit c1e1918db1
6 changed files with 30 additions and 3 deletions

View File

@@ -70,7 +70,11 @@ def _encode_supervised_example(
source_mask = [IGNORE_INDEX] * source_len
input_ids += source_ids + target_ids
labels += source_mask + target_ids
if data_args.train_last_turn_only and turn_idx != len(encoded_pairs) - 1:
labels += source_mask + [IGNORE_INDEX] * len(target_ids)
else:
labels += source_mask + target_ids
if template.efficient_eos:
input_ids += [tokenizer.eos_token_id]