Tonic commited on
Commit
57d0d96
·
1 Parent(s): 3bdb95c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +45 -0
README.md CHANGED
@@ -32,6 +32,10 @@ This is every "best reddit_question_best_answers" appended and produced accordin
32
  {"prompt": "This is the second prompt", "completion": "This is the second completion"}
33
  ```
34
 
 
 
 
 
35
  🤔The point is to make it easy to train models with a single correctly formatted dataset of
36
 
37
  - 54,367,153 rows
@@ -72,6 +76,47 @@ for _ in range(10): # Combine 10 times as an example
72
 
73
  ```
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  # Pre-Processing
76
 
77
  ```python
 
32
  {"prompt": "This is the second prompt", "completion": "This is the second completion"}
33
  ```
34
 
35
+
36
+ - 🌟 This dataset is internally consistent
37
+
38
+
39
  🤔The point is to make it easy to train models with a single correctly formatted dataset of
40
 
41
  - 54,367,153 rows
 
76
 
77
  ```
78
 
79
+ Or try combining rows line by line to save memory :
80
+
81
+ ```python
82
+
83
+ # see selectbyline.py
84
+
85
+ import os
86
+ import random
87
+
88
+ # Directory containing the shard JSONL files
89
+ shard_directory = "/path/to/shard/directory"
90
+
91
+ # Get a list of all JSONL files in the directory
92
+ shard_files = [f for f in os.listdir(shard_directory) if f.endswith('.jsonl')]
93
+
94
+ # Function to read a random number of lines (between min_lines and max_lines) from a file
95
+ def read_random_lines(filename, min_lines, max_lines):
96
+ selected_lines = []
97
+ num_lines = random.randint(min_lines, max_lines)
98
+
99
+ with open(filename, 'r') as file:
100
+ lines = list(file)
101
+ if len(lines) <= num_lines:
102
+ return lines
103
+ selected_lines = random.sample(lines, num_lines)
104
+
105
+ return selected_lines
106
+
107
+ # Function to combine shards
108
+ def combine_shards(output_filename, num_combinations):
109
+ with open(output_filename, 'w') as output_file:
110
+ for _ in range(num_combinations):
111
+ selected_shard_file = random.choice(shard_files)
112
+ lines = read_random_lines(os.path.join(shard_directory, selected_shard_file), 5000, 10000)
113
+ output_file.writelines(lines)
114
+
115
+ # Example usage
116
+ combine_shards("/path/to/output/combined_shards.jsonl", 10)
117
+
118
+ ```
119
+
120
  # Pre-Processing
121
 
122
  ```python