Upload limalpaca.py
Browse files- limalpaca.py +24 -0
limalpaca.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
|
3 |
+
input_filename = "train.jsonl"
|
4 |
+
output_filename = "limalpaca.json"
|
5 |
+
|
6 |
+
data = []
|
7 |
+
|
8 |
+
with open(input_filename, "r", encoding="utf-8") as jsonl_file:
|
9 |
+
for line in jsonl_file:
|
10 |
+
line_data = json.loads(line)
|
11 |
+
conversations = line_data.get("conversations", [])
|
12 |
+
|
13 |
+
if conversations:
|
14 |
+
instruction = conversations[0]
|
15 |
+
output = "\n".join(conversations[1:])
|
16 |
+
|
17 |
+
data.append({
|
18 |
+
"instruction": instruction.strip(),
|
19 |
+
"input": "",
|
20 |
+
"output": output.strip()
|
21 |
+
})
|
22 |
+
|
23 |
+
with open(output_filename, "w", encoding="utf-8") as json_file:
|
24 |
+
json.dump(data, json_file, indent=4)
|