Upload code/build_sft_v17_dataset.py with huggingface_hub
Browse files790 unmodified lines7917927937947957967977987998008018028037 unmodified lines811812813814815816817818819820821822823824825826827828829790 unmodified linesfull_ids.extend(a_ids)labels.extend(a_ids)if len(full_ids) > MAX_SEQ_LEN:full_ids = full_ids[:MAX_SEQ_LEN]full_ids[-1] = EOT_IDlabels = labels[:MAX_SEQ_LEN]labels[-1] = EOT_IDelse:labels = labels[:len(full_ids)]jsonl_rows.append({"conversations": item["conversations"], "domain": item["domain"]})else:7 unmodified linesprompt_ids = tokenizer.encode(prompt_str).idsfull_ids = tokenizer.encode(full_str).idsif len(prompt_ids) >= MAX_SEQ_LEN - 16:skipped_count += 1continueif len(full_ids) > MAX_SEQ_LEN:full_ids = full_ids[:MAX_SEQ_LEN]full_ids[-1] = EOT_IDprompt_len = min(len(prompt_ids), len(full_ids))labels = [-100] * prompt_len + full_ids[prompt_len:]labels = labels[:len(full_ids)]if len(full_ids) == MAX_SEQ_LEN:labels[-1] = EOT_IDjsonl_rows.append({"instruction": inst, "thinking": th, "response": resp, "domain": item["domain"]})790 unmodified lines7917927937947957967977987998007 unmodified lines808809810811812813814815816817818819820790 unmodified linesfull_ids.extend(a_ids)labels.extend(a_ids)# Skip entire multi-turn sample if total conversation exceeds context length (Zero broken samples)if len(full_ids) > MAX_SEQ_LEN:skipped_count += 1continuejsonl_rows.append({"conversations": item["conversations"], "domain": item["domain"]})else:7 unmodified linesprompt_ids = tokenizer.encode(prompt_str).idsfull_ids = tokenizer.encode(full_str).idsif len(prompt_ids) >= MAX_SEQ_LEN - 16 or len(full_ids) > MAX_SEQ_LEN:skipped_count += 1continueprompt_len = min(len(prompt_ids), len(full_ids))labels = [-100] * prompt_len + full_ids[prompt_len:]labels = labels[:len(full_ids)]jsonl_rows.append({"instruction": inst, "thinking": th, "response": resp, "domain": item["domain"]})
code/build_sft_v17_dataset.py+4-13