shuyuej commited on
Commit
9be9357
·
1 Parent(s): 5a078e2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +30 -1
README.md CHANGED
@@ -2,5 +2,34 @@
2
  license: mit
3
  ---
4
 
5
- # GSM8K Training set
6
  The original answer is "\n#### Value" and now is "\n#### Value\nThe answer is: Value", which is consistent with the answer format with "meta-math/MetaMathQA".
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: mit
3
  ---
4
 
5
+ # GSM8K training set
6
  The original answer is "\n#### Value" and now is "\n#### Value\nThe answer is: Value", which is consistent with the answer format with "meta-math/MetaMathQA".
7
+
8
+ # Dataset modification codes
9
+ ```python
10
+ # coding=utf-8
11
+
12
+ import jsonlines
13
+ from datasets import load_dataset, Features, Value
14
+
15
+ # Retrieve the path of training and testing databases
16
+ context_feat = Features({"question": Value(dtype='string', id=None), "answer": Value(dtype='string', id=None)})
17
+ train_set = load_dataset('json', data_files='train.jsonl', split='train', features=context_feat)
18
+
19
+ data = []
20
+ for example in train_set:
21
+ # Get the label answer --> gsm8k_answers
22
+ number = example['answer'].split('#### ')[1]
23
+ number = int(number.replace(',', ''))
24
+ append = "\nThe answer is: " + str(number)
25
+ answer = example['answer'] + append
26
+ question = example['question']
27
+ data.append({"question": question, "answer": answer})
28
+
29
+ # Save the modified data to a jsonl file
30
+ output_file = 'gsm8k_train.jsonl'
31
+ with jsonlines.open(output_file, 'w') as writer:
32
+ writer.write_all(data)
33
+
34
+ print(f"Modified data saved to {output_file}")
35
+ ```