Tonic commited on
Commit
5423466
·
1 Parent(s): 98d6dab

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +117 -0
README.md CHANGED
@@ -1,3 +1,120 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language:
4
+ - en
5
+ tags:
6
+ - not-for-all-audiences
7
+ - chemistry
8
+ - biology
9
+ - finance
10
+ - legal
11
+ - music
12
+ - art
13
+ - code
14
+ - climate
15
+ - medical
16
+ pretty_name: Well Reddits
17
+ size_categories:
18
+ - 100M<n<1B
19
+ task_categories:
20
+ - question-answering
21
  ---
22
+
23
+
24
+ # 🙋🏻‍♂️Welcome to 🧑🏻‍🚀Tonic's🚀🚰Well🔴Reddit🔥!
25
+
26
+ This is every "best reddit_question_best_answers" appended and produced according to the following template :
27
+
28
+ ```json
29
+ {"prompt": "This is the first prompt", "completion": "This is the first completion"}
30
+ {"prompt": "This is the second prompt", "completion": "This is the second completion"}
31
+ ```
32
+
33
+ 🤔The point is to make it easy to train models with a single correctly formatted dataset of
34
+
35
+ - 54,367,153 rows
36
+
37
+ Probably there's a big problem with the token count on these long answers 😉
38
+
39
+ good luck !🧑🏻‍🚀🚀
40
+
41
+ # Original Dataset :
42
+
43
+ [nreimers/reddit_question_best_answers](https://huggingface.co/datasets/nreimers/reddit_question_best_answers)
44
+
45
+ # Processing
46
+
47
+ ```python
48
+ import json
49
+ import os
50
+ import gzip
51
+ import logging
52
+ import re
53
+ import random
54
+
55
+ # Setup basic logging
56
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
57
+
58
+ def clean_string(s):
59
+ """Remove special characters, keeping only alphanumeric characters and spaces."""
60
+ if isinstance(s, list):
61
+ # Extract text from each dictionary in the list and join into a single string
62
+ s = " ".join([d.get("body", "") if isinstance(d, dict) else str(d) for d in s])
63
+ return re.sub(r'[^A-Za-z0-9 ]+', '', s)
64
+
65
+ def process_file(input_file, output_file):
66
+ try:
67
+ dataset = []
68
+ with gzip.open(input_file, 'rt') as infile:
69
+ for line in infile:
70
+ # Parse the JSON line
71
+ try:
72
+ data = json.loads(line)
73
+ except json.JSONDecodeError:
74
+ logging.error(f"Invalid JSON format in {input_file}: {line}")
75
+ continue
76
+
77
+ # Extract and clean the 'body' and 'answers' fields
78
+ prompt = clean_string(data.get("body", ""))
79
+ completion = clean_string(data.get("answers", ""))
80
+
81
+ # For each body found, make a new row and duplicate the prompt for it
82
+ if isinstance(data.get("body", ""), list):
83
+ for body in data.get("body", []):
84
+ cleaned_body = clean_string(body)
85
+ dataset.append({"prompt": cleaned_body, "completion": completion})
86
+ else:
87
+ dataset.append({"prompt": prompt, "completion": completion})
88
+
89
+ # Shuffle the dataset
90
+ random.shuffle(dataset)
91
+
92
+ # Write the shuffled dataset to the output file
93
+ with open(output_file, 'a') as outfile:
94
+ for item in dataset:
95
+ json.dump(item, outfile)
96
+ outfile.write('\n')
97
+
98
+ logging.info(f"Processed file: {input_file}")
99
+
100
+ except Exception as e:
101
+ logging.error(f"Error processing file {input_file}: {e}")
102
+
103
+ def process_files(file_list, output_dir):
104
+ # Ensure the output directory exists
105
+ if not os.path.exists(output_dir):
106
+ os.makedirs(output_dir)
107
+
108
+ # Create a single output file path
109
+ output_file = os.path.join(output_dir, 'synthesized_dataset.jsonl')
110
+
111
+ for input_file in file_list:
112
+ process_file(input_file, output_file)
113
+
114
+ # Update with your list of .gz file paths
115
+ file_list = [r'C:\Users\MeMyself\reddit_question_best_answers\RS_2010-01.jsonl.gz', r'C:\Users\MeMyself\reddit_question_best_answers\RS_2010-02.jsonl.gz', r"C:\Users\MeMyself\reddit_question_best_answers\RS_2010-03.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2010-04.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2010-05.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2010-06.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2010-07.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2010-08.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2010-09.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2010-10.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2010-11.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2010-12.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2011-01.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2011-02.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2011-03.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2011-04.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2011-05.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2011-06.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2011-07.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2011-08.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2011-09.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2011-10.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2011-11.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2011-12.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2012-01.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2012-02.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2012-03.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2012-04.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2012-05.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2012-06.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2012-07.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2012-08.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2012-09.jsonl.gz",r"C:\Users\MeMyself\reddit_question_best_answers\RS_2012-10.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2012-11.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2012-12.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2013-01.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2013-02.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2013-03.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2013-04.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2013-05.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2013-06.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2013-07.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2013-08.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2013-09.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2013-10.jsonl.gz", r"c:\Users\MeMyself\reddit_question_best_answers\RS_2013-11.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2013-12.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2014-01.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2014-02.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2014-03.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2014-04.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2014-05.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2014-06.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2014-07.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2014-08.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2014-09.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2014-10.jsonl.gz",r"C:\Users\MeMyself\reddit_question_best_answers\RS_2014-11.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2014-12.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2015-01.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2015-02.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2015-03.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2015-04.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2015-05.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2015-06.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2015-07.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2015-08.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2015-09.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2015-10.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2015-11.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2015-12.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2016-01.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2016-02.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2016-03.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2016-04.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2016-05.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2016-06.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2016-07.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2016-08.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2016-09.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2016-10.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2016-11.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2016-12.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2017-01.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2017-02.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2017-03.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2017-04.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2017-05.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2017-06.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2017-07.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2017-08.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2017-09.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2017-10.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2017-11.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2017-12.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2018-01.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2018-02.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2018-03.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2018-04.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2018-05.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2018-06.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2018-07.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2018-08.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2018-09.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2018-10.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2018-11.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2018-12.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2019-01.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2019-02.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2019-03.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2019-04.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2019-05.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2019-06.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2019-07.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2019-08.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2019-09.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2019-10.jsonl.gz", r"c:\Users\MeMyself\reddit_question_best_answers\RS_2019-11.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2019-12.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2020-01.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2020-02.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2020-03.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2020-04.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2020-05.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2020-06.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2020-07.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2020-08.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2020-09.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2020-10.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2020-11.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2020-12.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2021-01.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2021-02.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2021-03.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2021-04.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2021-05.jsonl.gz", r"C:\Users\MeMyself\reddit_question_best_answers\RS_2021-06.jsonl.gz" ] # Update with your list of .gz file paths
116
+ output_dir = r'C:\Users\MeMyself\reddit_question_best_answers\processed'
117
+ process_files(file_list, output_dir)
118
+
119
+
120
+ ```