Download lora_checkpoints/data/QiaoBan/split_data.py from Ray121381/lora_ckp: direct link, hf CLI and curl.
- Browser
- Download file 449 Bytes
-
https://huggingface.co/Ray121381/lora_ckp/resolve/main/lora_checkpoints/data/QiaoBan/split_data.py
- Command line
-
hf download hf://Ray121381/lora_ckp/lora_checkpoints/data/QiaoBan/split_data.py
-
curl -L -o split_data.py https://huggingface.co/Ray121381/lora_ckp/resolve/main/lora_checkpoints/data/QiaoBan/split_data.py
449 Bytes
| import json | |
| import numpy as np | |
| np.random.seed(0) | |
| data = [] | |
| with open("chat_train_data.json", "r") as fr: | |
| for line in fr.readlines(): | |
| data.append(line) | |
| test_size = 200 | |
| np.random.shuffle(data) | |
| train_data = data[:-test_size] | |
| test_data = data[-test_size:] | |
| with open("train_data.json", "w") as fw: | |
| for d in train_data: | |
| fw.write(f"{d}") | |
| with open("test_data.json", "w") as fw: | |
| for d in test_data: | |
| fw.write(f"{d}") |