KashiwaByte
commited on
Commit
•
fe1fffd
1
Parent(s):
a3bc496
add dataset
Browse files- Cosmosqa_train.jsonl +3 -0
- Read_Comperhension50k.csv +3 -0
- Read_Comperhension50k.json +3 -0
- Read_Comperhension50k.jsonl +3 -0
- TriviaQA_train25k.jsonl +3 -0
- Xtuner_Read_Comperhension50k.jsonl +3 -0
- jsonl2csv.py +21 -0
- jsonl2json.py +16 -0
- merge.py +18 -0
- xtunerformat.py +31 -0
Cosmosqa_train.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3429c45914ced38a9eceed7aac9cb4ee5227872fb92efa5106a28cb40b394f18
|
3 |
+
size 22909738
|
Read_Comperhension50k.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4cb65cb7de2ba4085551d69ae7db738d0bbcc01f6b5984723cdcb6905f4d852d
|
3 |
+
size 132615197
|
Read_Comperhension50k.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c8b6a7d52a0be1877451894c538b36b95f23f5b412462c3269cdfb2cbb01d171
|
3 |
+
size 135770699
|
Read_Comperhension50k.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:37aef0856d8d250cd6d1c99f39f8eac1fa71c8b845ca44d58f5cdf02bae44977
|
3 |
+
size 135770699
|
TriviaQA_train25k.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f50f71142db3bae44300704d28aea952b6048e79fc80710ee7eced0fb2e50e30
|
3 |
+
size 112860766
|
Xtuner_Read_Comperhension50k.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4bb6f8104fb0e35151e48a4483fedbb5a82374ba647b220fe09c58089896428a
|
3 |
+
size 135603261
|
jsonl2csv.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import csv
|
3 |
+
|
4 |
+
def convert_jsonl_to_csv(jsonl_file, csv_file):
|
5 |
+
with open(jsonl_file, 'r',encoding='utf-8') as file:
|
6 |
+
json_data = [json.loads(line) for line in file]
|
7 |
+
|
8 |
+
if len(json_data) > 0:
|
9 |
+
fields = list(json_data[0].keys())
|
10 |
+
|
11 |
+
with open(csv_file, 'w', newline='',encoding='utf-8') as file:
|
12 |
+
writer = csv.DictWriter(file, fieldnames=fields)
|
13 |
+
writer.writeheader()
|
14 |
+
|
15 |
+
for data in json_data:
|
16 |
+
writer.writerow(data)
|
17 |
+
|
18 |
+
# 使用示例
|
19 |
+
jsonl_file = 'Read_Comperhension50k.jsonl'
|
20 |
+
csv_file = 'Read_Comperhension50k.csv'
|
21 |
+
convert_jsonl_to_csv(jsonl_file, csv_file)
|
jsonl2json.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
|
3 |
+
def convert_jsonl_to_json(jsonl_file, json_file):
|
4 |
+
json_data = []
|
5 |
+
|
6 |
+
with open(jsonl_file, 'r') as file:
|
7 |
+
for line in file:
|
8 |
+
json_data.append(json.loads(line))
|
9 |
+
|
10 |
+
with open(json_file, 'w') as file:
|
11 |
+
json.dump(json_data, file)
|
12 |
+
|
13 |
+
# 使用示例
|
14 |
+
jsonl_file = 'Xtuner_Read_Comperhension50k.jsonl'
|
15 |
+
json_file = 'Xtuner_Read_Comperhension50k.json'
|
16 |
+
convert_jsonl_to_json(jsonl_file, json_file)
|
merge.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
|
3 |
+
input_file1 = 'Cosmosqa_train.jsonl'
|
4 |
+
input_file2 = 'TriviaQA_train25k.jsonl'
|
5 |
+
output_file = 'Read_Comperhension50k.jsonl'
|
6 |
+
|
7 |
+
with open(input_file1, 'r', encoding='utf-8') as f_input1, \
|
8 |
+
open(input_file2, 'r', encoding='utf-8') as f_input2, \
|
9 |
+
open(output_file, 'w', encoding='utf-8') as f_output:
|
10 |
+
for line in f_input1:
|
11 |
+
data = json.loads(line)
|
12 |
+
json.dump(data, f_output)
|
13 |
+
f_output.write('\n')
|
14 |
+
|
15 |
+
for line in f_input2:
|
16 |
+
data = json.loads(line)
|
17 |
+
json.dump(data, f_output)
|
18 |
+
f_output.write('\n')
|
xtunerformat.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import csv
|
2 |
+
import json
|
3 |
+
|
4 |
+
csv_file = 'Read_Comperhension50k.csv'
|
5 |
+
jsonl_file = 'Xtuner_Read_Comperhension50k.jsonl'
|
6 |
+
|
7 |
+
# 生成JSONL文件
|
8 |
+
messages = []
|
9 |
+
|
10 |
+
with open(csv_file, 'r', encoding='utf-8') as file:
|
11 |
+
reader = csv.reader(file)
|
12 |
+
next(reader) # 跳过标题行
|
13 |
+
|
14 |
+
for row in reader:
|
15 |
+
if len(row) >= 3:
|
16 |
+
insturction = row[0]
|
17 |
+
input= row[1]
|
18 |
+
output = row[2]
|
19 |
+
conversation = [
|
20 |
+
{
|
21 |
+
"system": insturction,
|
22 |
+
"input": input,
|
23 |
+
"output": output
|
24 |
+
}
|
25 |
+
]
|
26 |
+
messages.append({"conversation": conversation})
|
27 |
+
# 保存为JSONL文件
|
28 |
+
with open(jsonl_file, 'w', encoding='utf-8') as file:
|
29 |
+
for message in messages:
|
30 |
+
file.write(json.dumps(message, ensure_ascii=False) + '\n')
|
31 |
+
|