v2ray commited on
Commit
bfae27f
·
1 Parent(s): fb889bc

Uploaded dataset.

Browse files
.gitattributes CHANGED
@@ -57,3 +57,5 @@ saved_model/**/* 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
 
 
 
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
60
+ *.json filter=lfs diff=lfs merge=lfs -text
61
+ *.jsonl filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ task_categories:
4
+ - text-generation
5
+ language:
6
+ - en
7
+ size_categories:
8
+ - 10K<n<100K
9
+ ---
10
+ # 4chan
11
+ This dataset is [lesserfield/4chan-datasets](https://huggingface.co/datasets/lesserfield/4chan-datasets) converted to a better format.
boards/a.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c44fca4fcb9cf1d836842d2fc2bb22d80efc206cb6b8cf2492860c4eb8c673dd
3
+ size 32702059
boards/b.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:32d5459b1e5a7e3fe3eb91245d5cbad73d3544c30127a9e333f65a60c160009e
3
+ size 13258810
boards/bant.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e9950e6061272de947b61837e97d0e5506a3fa9660501f036a275354d58db31
3
+ size 7206919
boards/biz.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5817fa6d8e08ea64622f09b936c37ed7a9798579cd417227de569a8962b207f6
3
+ size 17485190
boards/ck.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a2a43dc54fcd058209fe3c6b9d5a16cf4f5b4912e9ca5ffb91019d09b571342
3
+ size 9457996
boards/co.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:17a525f7b19ae9e82453a42c83e7f579d0a6fce94580257a4c8991e669b99fb7
3
+ size 26061648
boards/diy.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c96e3cb8de222451a27f2f2eed15ac206584ed5b5e9739acd76370e243c1078c
3
+ size 4432034
boards/fit.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e447e110a14b72a15047ceb66c9557246a0dbde65b8888da23a084e75b7dd1f0
3
+ size 17070863
boards/g.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8c2564294dceb6871555544ad4508b5e601bba6f11a29dbdd7252c6f91af188
3
+ size 41173302
boards/his.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e5d65724c80f78b7dfa9592e2f8e2f340118eae9b840ec1cbbc1c0100aab94aa
3
+ size 14338382
boards/int.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1cae8ce5bcd5203ef02f55c466cc8672d97f511b142b4242a5f50310fecdee8d
3
+ size 46113932
boards/jp.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2616854cf7bdc5221ccadc162ba8f6419e75671f9f58431a41265654a160a387
3
+ size 12655890
boards/k.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f8fd69f1ff11afd0d45be29ca112c712e71506e9fb4571828f62d6b3182a6615
3
+ size 27928435
boards/lit.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b3d5231671f54b680de65c540a65f0fb76e807a67aa062076f60fdac85a9c16c
3
+ size 15027449
boards/m.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18e40d403baac0f1af9c829ab1b76d37f59b50ee7a8d347a5b4612e99c30e5cb
3
+ size 10306791
boards/mu.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60f6cff77af92d8b0bb3492dcec0fba4c0bbfb8de4136528b198ec6145ccbe83
3
+ size 11128010
boards/out.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6bb51f66d7707f703671aa3e37c506ef6726802b6c33b800b8aab699aed4265d
3
+ size 3764037
boards/r9k.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f084d13ba48e508a5febfb42eff0ed5ecd6b053ed63db6e76e1e2f9ccd3b0965
3
+ size 34360724
boards/sci.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb14b0f807a860ea2c8961df842dc832435e770cb59322a352a36b9dd7025885
3
+ size 10234842
boards/trash.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:87712a9661105e0194e340fe2bf5ae7c203511d2489ee6ad1b57cd2eb56957c7
3
+ size 26702413
boards/v.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f78976305704c7967993b989a55fea04d319e9877b4ec4e90ea43e5565c4a91b
3
+ size 67921235
boards/vg.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd0241b3b266238875e6d25186f16d2121108e0f4f1e5dc8216008b9f3e8db0f
3
+ size 117231582
boards/vmg.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34bdcfe04fd7fcccb42019a3bbebfda224e1d82b0c60b2a8d28e0590edfc99b7
3
+ size 6491962
boards/vt.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9996c4ef914bfad0d96ef34ac3c85eea24bd76eeb58901861c5303b179e202a7
3
+ size 28696178
condense.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import re
3
+ import sys
4
+ import json
5
+
6
+ MESSAGE_SPLIT_PATTERN = re.compile(r"\n--- (?=\d+ *\n)")
7
+ REPLY_ID_PATTERN = re.compile(r">>(\d+)")
8
+
9
+ def main():
10
+ for folder in os.listdir():
11
+ if not os.path.isdir(folder) or folder.startswith("."):
12
+ continue
13
+ board_result = []
14
+ for file in os.listdir(folder):
15
+ if not file.endswith(".txt"):
16
+ continue
17
+ file = os.path.join(folder, file)
18
+ if not os.path.isfile(file):
19
+ continue
20
+ with open(file, "r", encoding="utf8") as f:
21
+ content = f.read()[5:]
22
+ content = MESSAGE_SPLIT_PATTERN.split(content)
23
+ result = []
24
+ orig_to_norm = {}
25
+ i = 1
26
+ for message in content:
27
+ message = message.strip()
28
+ if not message:
29
+ continue
30
+ j = 0
31
+ message_content = ""
32
+ message_has_content = False
33
+ for line in message.split("\n"):
34
+ line = line.strip()
35
+ if j == 0:
36
+ try:
37
+ message_id = int(line)
38
+ except Exception:
39
+ raise RuntimeError(f"Failed to parse message ID for \"{line}\" in \"{file}\"!")
40
+ orig_to_norm[message_id] = i
41
+ else:
42
+ replace_count = 0
43
+ def replace_id(match):
44
+ nonlocal replace_count
45
+ replace_count += 1
46
+ return f">>{orig_to_norm.get(int(match.group(1)), "unknown")}"
47
+ line = REPLY_ID_PATTERN.sub(replace_id, line)
48
+ if not message_has_content and replace_count == 0 and line.strip():
49
+ message_has_content = True
50
+ if j != 1:
51
+ message_content += "\n"
52
+ message_content += line
53
+ j += 1
54
+ if j == 0:
55
+ raise RuntimeError(f"This message \"{message}\" in \"{file}\" doesn't start with a message ID!")
56
+ if not message_has_content:
57
+ orig_to_norm.pop(message_id)
58
+ continue
59
+ result.append({"id": i, "content": message_content})
60
+ i += 1
61
+ board_result.append(result)
62
+ with open(f"{folder}.json", "w", encoding="utf8") as f:
63
+ json.dump(board_result, f, ensure_ascii=False)
64
+
65
+ if __name__ == "__main__":
66
+ try:
67
+ main()
68
+ except KeyboardInterrupt:
69
+ print("\nScript interrupted by user, exiting...")
70
+ sys.exit(1)
merge.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ import json
4
+ import tqdm
5
+ import argparse
6
+ import transformers
7
+
8
+ def parse_args():
9
+ parser = argparse.ArgumentParser(description="Merge the boards into a single train set.")
10
+ parser.add_argument("-t", "--tokenizer-name-or-path", default="meta-llama/Llama-3.1-8B", help="The name or path for the tokenizer")
11
+ parser.add_argument("-l", "--limit", type=int, default=4096, help="Length limit in tokens for each post")
12
+ parser.add_argument("-i", "--id", default="<|start_header_id|>", help="Prefix token for message IDs")
13
+ parser.add_argument("-c", "--content", default="<|end_header_id|>", help="Prefix token for message contents")
14
+ return parser.parse_args()
15
+
16
+ def main():
17
+ args = parse_args()
18
+ tokenizer = transformers.AutoTokenizer.from_pretrained(args.tokenizer_name_or_path, legacy=True)
19
+ if args.id not in tokenizer.vocab:
20
+ print(f"The message ID prefix token \"{args.id}\" is not a token in \"{args.tokenizer_name_or_path}\", it will work but it's better to be a token in the tokenizer.")
21
+ if args.content not in tokenizer.vocab:
22
+ print(f"The message content prefix token \"{args.content}\" is not a token in \"{args.tokenizer_name_or_path}\", it will work but it's better to be a token in the tokenizer.")
23
+ boards_dir = "boards"
24
+ with open("merged_strings_train.jsonl", "w", encoding="utf8") as output:
25
+ for board_path in tqdm.tqdm(os.listdir(boards_dir), desc="Boards"):
26
+ board_name, ext = os.path.splitext(board_path)
27
+ if ext != ".json":
28
+ continue
29
+ board_path = os.path.join(boards_dir, board_path)
30
+ if not os.path.isfile(board_path):
31
+ continue
32
+ with open(board_path, "r", encoding="utf8") as f:
33
+ board = json.load(f)
34
+ for post in tqdm.tqdm(board, desc="Posts"):
35
+ post_content = board_name
36
+ post_token_count = len(tokenizer.encode(post_content, add_special_tokens=False)) + 2 # Add 2 for the start of string and end of string tokens.
37
+ for message in post:
38
+ formatted = f"{args.id}{message["id"]}{args.content}{message["content"]}"
39
+ formatted_token_count = len(tokenizer.encode(formatted, add_special_tokens=False))
40
+ post_token_count += formatted_token_count
41
+ if post_token_count > args.limit:
42
+ break
43
+ post_content += formatted
44
+ json.dump({"input": "", "output": post_content}, output, ensure_ascii=False)
45
+ output.write("\n")
46
+
47
+ if __name__ == "__main__":
48
+ try:
49
+ main()
50
+ except KeyboardInterrupt:
51
+ print("\nScript interrupted by user, exiting...")
52
+ sys.exit(1)
merged_strings_train.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4e9106e7892f1e37dc81737b8cd96f994e8fcdb8056a03b9bd47fe13818d488
3
+ size 361276051