Datasets:

Modalities:
Text
Formats:
json
Languages:
English
ArXiv:
Tags:
xzuyn commited on
Commit
665c86e
1 Parent(s): 503c96a

Upload limalpaca.py

Browse files
Files changed (1) hide show
  1. 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)