mrfakename Fizzarolli commited on
Commit
84da019
·
0 Parent(s):

Duplicate from allura-forge/expr-rp-sft-mix

Browse files

Co-authored-by: Fizz 🏳️‍⚧️ <Fizzarolli@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
12
+ *.mds filter=lfs diff=lfs merge=lfs -text
13
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
14
+ *.model filter=lfs diff=lfs merge=lfs -text
15
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
16
+ *.npy filter=lfs diff=lfs merge=lfs -text
17
+ *.npz filter=lfs diff=lfs merge=lfs -text
18
+ *.onnx filter=lfs diff=lfs merge=lfs -text
19
+ *.ot filter=lfs diff=lfs merge=lfs -text
20
+ *.parquet filter=lfs diff=lfs merge=lfs -text
21
+ *.pb filter=lfs diff=lfs merge=lfs -text
22
+ *.pickle filter=lfs diff=lfs merge=lfs -text
23
+ *.pkl filter=lfs diff=lfs merge=lfs -text
24
+ *.pt filter=lfs diff=lfs merge=lfs -text
25
+ *.pth filter=lfs diff=lfs merge=lfs -text
26
+ *.rar filter=lfs diff=lfs merge=lfs -text
27
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
28
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
29
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
30
+ *.tar filter=lfs diff=lfs merge=lfs -text
31
+ *.tflite filter=lfs diff=lfs merge=lfs -text
32
+ *.tgz filter=lfs diff=lfs merge=lfs -text
33
+ *.wasm filter=lfs diff=lfs merge=lfs -text
34
+ *.xz filter=lfs diff=lfs merge=lfs -text
35
+ *.zip filter=lfs diff=lfs merge=lfs -text
36
+ *.zst filter=lfs diff=lfs merge=lfs -text
37
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
38
+ # Audio files - uncompressed
39
+ *.pcm filter=lfs diff=lfs merge=lfs -text
40
+ *.sam filter=lfs diff=lfs merge=lfs -text
41
+ *.raw filter=lfs diff=lfs merge=lfs -text
42
+ # Audio files - compressed
43
+ *.aac filter=lfs diff=lfs merge=lfs -text
44
+ *.flac filter=lfs diff=lfs merge=lfs -text
45
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
46
+ *.ogg filter=lfs diff=lfs merge=lfs -text
47
+ *.wav filter=lfs diff=lfs merge=lfs -text
48
+ # Image files - uncompressed
49
+ *.bmp filter=lfs diff=lfs merge=lfs -text
50
+ *.gif filter=lfs diff=lfs merge=lfs -text
51
+ *.png filter=lfs diff=lfs merge=lfs -text
52
+ *.tiff filter=lfs diff=lfs merge=lfs -text
53
+ # Image files - compressed
54
+ *.jpg filter=lfs diff=lfs merge=lfs -text
55
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
56
+ *.webp filter=lfs diff=lfs merge=lfs -text
57
+ # Video files - compressed
58
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
59
+ *.webm filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ dataset_info:
3
+ features:
4
+ - name: conversations
5
+ list:
6
+ - name: from
7
+ dtype: string
8
+ - name: value
9
+ dtype: string
10
+ splits:
11
+ - name: train
12
+ num_bytes: 617948242
13
+ num_examples: 46586
14
+ download_size: 369997405
15
+ dataset_size: 617948242
16
+ configs:
17
+ - config_name: default
18
+ data_files:
19
+ - split: train
20
+ path: data/train-*
21
+ ---
data/train-00000-of-00002.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bb058ca314289efee09d52abafe64bfbcd2b41e905e6b4aa9d26632e663e083d
3
+ size 185764459
data/train-00001-of-00002.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0245478c1157097b5041fffbc6cfe7914d9f5809d5478f211da514147b25ccc9
3
+ size 184232946
main.py ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datasets import load_dataset, concatenate_datasets, Features, Value
2
+ from huggingface_hub import HfApi
3
+ from functools import partial
4
+
5
+ def convert_openai_to_sharegpt(sample):
6
+ convo = []
7
+ for msg in sample["conversations"]:
8
+ if msg["content"] == "":
9
+ continue
10
+ match msg["role"]:
11
+ case "user":
12
+ convo.append({
13
+ "from": "human",
14
+ "value": msg["content"]
15
+ })
16
+ case "assistant":
17
+ convo.append({
18
+ "from": "gpt",
19
+ "value": msg["content"]
20
+ })
21
+ case other:
22
+ convo.append({
23
+ "from": other,
24
+ "value": msg["content"]
25
+ })
26
+ return {"conversations": convo}
27
+
28
+ def convert_openai_to_sharegpt_thonking_added(sample):
29
+ convo = [{"from": "system", "value": "When responding, think step by step in a set of XML tags (<think> and </think>) and consider your response deeply, then close the </think> tag and write the rest of your response normally."}]
30
+ for msg in sample["conversations"]:
31
+ if msg["content"] == "":
32
+ continue
33
+ match msg["role"]:
34
+ case "user":
35
+ convo.append({
36
+ "from": "human",
37
+ "value": msg["content"]
38
+ })
39
+ case "assistant":
40
+ convo.append({
41
+ "from": "gpt",
42
+ "value": msg["content"]
43
+ })
44
+ case other:
45
+ convo.append({
46
+ "from": other,
47
+ "value": msg["content"]
48
+ })
49
+ return {"conversations": convo}
50
+
51
+ def convert_ruozhiba_to_sharegpt(sample):
52
+ return {
53
+ "conversations": [
54
+ {
55
+ "from": "human",
56
+ "value": sample["instruction"]
57
+ },
58
+ {
59
+ "from": "gpt",
60
+ "value": sample["output"]
61
+ }
62
+ ]
63
+ }
64
+
65
+ def convert_zh_to_sharegpt(sample):
66
+ conversation = sample["conversations"]
67
+ conversation.insert(0, {
68
+ "from": "system",
69
+ "value": sample["system_prompt"]
70
+ })
71
+ return {
72
+ "conversations": conversation
73
+ }
74
+
75
+ def convert_opencai(sample):
76
+ convo = []
77
+ for idx, msg in enumerate(sample["conversations"]):
78
+ convo.append({
79
+ "from": "human" if idx % 2 == 0 else "gpt",
80
+ "value": f"{msg['author']}: {msg['message']}"
81
+ })
82
+ return {"conversations": convo}
83
+
84
+ def convert_opc_sft_stage1(sample):
85
+ return {
86
+ "conversations": [
87
+ {
88
+ "from": "human",
89
+ "value": sample["instruction"]
90
+ },
91
+ {
92
+ "from": "gpt",
93
+ "value": sample["output"]
94
+ }
95
+ ]
96
+ }
97
+
98
+ def convert_original_s1k(sample, think_key, attempt_key):
99
+ return {
100
+ "conversations": [
101
+ {"from": "system", "value": "When responding, think step by step in a set of XML tags (<think> and </think>) and consider your response deeply, then close the </think> tag and write the rest of your response normally."},
102
+ {
103
+ "from": "human",
104
+ "value": sample["question"]
105
+ },
106
+ {
107
+ "from": "gpt",
108
+ "value": f"""<think>\n{sample[think_key]}\n</think>\n{sample[attempt_key]}"""
109
+ }
110
+ ]
111
+ }
112
+
113
+ def convert_freedom_medical(sample):
114
+ return {
115
+ "conversations": [
116
+ {"from": "system", "value": "When responding, think step by step in a set of XML tags (<think> and </think>) and consider your response deeply, then close the </think> tag and write the rest of your response normally."},
117
+ {
118
+ "from": "human",
119
+ "value": sample["question"]
120
+ },
121
+ {
122
+ "from": "gpt",
123
+ "value": f"""<think>\n{sample["reasoning (reasoning_content)"]}\n</think>\n{sample["response (content)"]}"""
124
+ }
125
+ ]
126
+ }
127
+
128
+ def convert_chinese_deepseek_r1_distill_data(sample):
129
+ return {
130
+ "conversations": [
131
+ {
132
+ "from": "human",
133
+ "value": sample["input"]
134
+ },
135
+ {
136
+ "from": "gpt",
137
+ "value": f"""{sample['content'].strip()}"""
138
+ }
139
+ ]
140
+ }
141
+
142
+ def filter_synthkink(sample):
143
+ # Make a copy of the story and check if it contains <think> tags
144
+ story = sample["story"].strip()
145
+
146
+ # If the story contains <think> tags, strip them out
147
+ if "<think>" in story and "</think>" in story:
148
+ # Find the positions of the tags
149
+ think_start = story.find("<think>")
150
+ think_end = story.find("</think>") + len("</think>")
151
+
152
+ # Remove the tags and everything between them
153
+ final_response = story[:think_start] + story[think_end:]
154
+
155
+ # Clean up any extra newlines that might be left
156
+ final_response = final_response.strip()
157
+ else:
158
+ # If no think tags, use the original story
159
+ final_response = story
160
+
161
+ # Check if the final response is longer than 500 characters
162
+ return len(final_response) > 500
163
+
164
+ def convert_synthkink(sample):
165
+ story = sample["story"].strip()
166
+ # If the story contains <think> tags, strip them out
167
+ if "<think>" in story and "</think>" in story:
168
+ # Find the positions of the tags
169
+ think_start = story.find("<think>")
170
+ think_end = story.find("</think>") + len("</think>")
171
+
172
+ # Remove the tags and everything between them
173
+ final_response = story[:think_start] + story[think_end:]
174
+
175
+ # Clean up any extra newlines that might be left
176
+ final_response = final_response.strip()
177
+ else:
178
+ # If no think tags, use the original story
179
+ final_response = story
180
+
181
+ return {
182
+ "conversations": [
183
+ {
184
+ "from": "human",
185
+ "value": sample["prompt"]
186
+ },
187
+ {
188
+ "from": "gpt",
189
+ "value": final_response
190
+ }
191
+ ]
192
+ }
193
+
194
+ def convert_helpsteer(sample):
195
+ context = [{"from": "human" if msg["role"] == "user" else "gpt", "value": msg["content"]} for msg in sample["context"]]
196
+ if sample["overall_preference"] > 0:
197
+ return {
198
+ "conversations": context + [
199
+ {
200
+ "from": "gpt",
201
+ "value": sample["response2"]
202
+ }
203
+ ]
204
+ }
205
+ else:
206
+ return {
207
+ "conversations": context + [
208
+ {
209
+ "from": "gpt",
210
+ "value": sample["response1"]
211
+ }
212
+ ]
213
+ }
214
+
215
+ datasets = [
216
+ # general
217
+ (
218
+ load_dataset("QuixiAI/SystemChat-2.0", split="train", data_files={"train": "SystemChat_filtered.jsonl"})
219
+ .rename_column("messages", "conversations")
220
+ .map(convert_openai_to_sharegpt),
221
+ 1.0
222
+ ),
223
+
224
+ # claude
225
+ (
226
+ load_dataset("anthracite-org/kalo-opus-instruct-22k-no-refusal", split="train").map(lambda x: {"conversations": [{"from": "system", "value": "You are Luna, a helpful and harmless language model by Allura."}] + x["conversations"][1:]}).map(lambda x: {"conversations": [{"from": msg["from"], "value": msg["value"].replace("Claude", "Luna").replace("claude", "luna")} for msg in x["conversations"]]}),
227
+ None
228
+ ),
229
+
230
+
231
+ # rp
232
+ (
233
+ load_dataset("Delta-Vector/Orion-OpenCAI-ShareGPT", split="train"),
234
+ None
235
+ ),
236
+ (
237
+ load_dataset("Delta-Vector/Orion-PIPPA-Cleaned-V2", split="train"),
238
+ None
239
+ ),
240
+ (
241
+ load_dataset("grimulkan/LimaRP-augmented", split="train").remove_columns(["id"]),
242
+ None
243
+ ),
244
+ (
245
+ load_dataset("Delta-Vector/Orion-PIPPA-Cleaned-V2", split="train"),
246
+ None
247
+ ),
248
+ (
249
+ load_dataset("grimulkan/LimaRP-augmented", split="train").remove_columns(["id"]),
250
+ None
251
+ ),
252
+ (
253
+ load_dataset("Delta-Vector/Orion-Personamaxx-Logs-21K", split="train").map(lambda x: {"conversations": [{"from":msg["from"],"value":msg["value"]} for msg in x["conversations"]]}, features=Features({
254
+ "conversations": [{"from": Value("string"), "value": Value("string")}]
255
+ # add other columns you want to keep
256
+ })),
257
+ 1.0
258
+ ),
259
+
260
+ # story
261
+ (
262
+ load_dataset("Delta-Vector/Orion-Fiction-Writer", split="train"),
263
+ None
264
+ ),
265
+ (
266
+ load_dataset("Delta-Vector/Orion-Praxis-Co-Writer", split="train"),
267
+ None
268
+ ),
269
+
270
+ # beep boop
271
+ (
272
+ load_dataset("allura-forge/luna-hardcoded-expr", split="train")
273
+ .rename_column("messages", "conversations")
274
+ .map(convert_openai_to_sharegpt),
275
+ None
276
+ ),
277
+ (
278
+ load_dataset("allura-forge/luna-hardcoded-expr", split="train")
279
+ .rename_column("messages", "conversations")
280
+ .map(convert_openai_to_sharegpt),
281
+ None
282
+ ),
283
+ (
284
+ load_dataset("allura-forge/luna-hardcoded-expr", split="train")
285
+ .rename_column("messages", "conversations")
286
+ .map(convert_openai_to_sharegpt),
287
+ None
288
+ ),
289
+ (
290
+ load_dataset("allura-forge/luna-hardcoded-expr", split="train")
291
+ .rename_column("messages", "conversations")
292
+ .map(convert_openai_to_sharegpt),
293
+ None
294
+ ),
295
+ (
296
+ load_dataset("allura-forge/luna-hardcoded-expr", split="train")
297
+ .rename_column("messages", "conversations")
298
+ .map(convert_openai_to_sharegpt),
299
+ None
300
+ ),
301
+
302
+ ]
303
+
304
+ # Get the minimum number of entries across all datasets, and truncate all datasets to this length so we don't overrepresent any dataset
305
+ #max_entries = float('inf')
306
+ #for dataset in datasets:
307
+ # if len(dataset) < max_entries:
308
+ # max_entries = len(dataset)
309
+
310
+ # Use the first dataset as the benchmark for the number of entries
311
+ # max_entries = len(datasets[0])
312
+
313
+ # Fuck you, set it manually
314
+ max_entries = 5000
315
+
316
+ processed_datasets = []
317
+ for dataset, multiplier in datasets:
318
+ if multiplier is not None:
319
+ dataset = dataset.select(range(int(max_entries * multiplier)))
320
+ processed_datasets.append(dataset)
321
+
322
+ print(f"Datasets truncated to {max_entries} entries")
323
+
324
+ # Concatenate all datasets
325
+ dataset = concatenate_datasets(processed_datasets)
326
+
327
+ print("Final dataset size:", len(dataset))
328
+
329
+ # Shuffle the dataset
330
+ dataset = dataset.shuffle(seed=42)
331
+
332
+ dataset.push_to_hub("allura-forge/expr-rp-sft-mix")
333
+
334
+ # Also upload this file as source code
335
+ with open(__file__, "rb") as f:
336
+ HfApi().upload_file(
337
+ path_or_fileobj=f,
338
+ path_in_repo="main.py",
339
+ repo_id="allura-forge/expr-rp-sft-mix",
340
+ repo_type="dataset"
341
+ )