web novel
Browse files- README.md +55 -1
- data/webnovel_0.jsonl +3 -0
- data/webnovel_1.jsonl +3 -0
- data/webnovel_2.jsonl +3 -0
- data/webnovel_3.jsonl +3 -0
- data/webnovel_4.jsonl +3 -0
- data/webnovel_5.jsonl +3 -0
- data/webnovel_6.jsonl +3 -0
- data/webnovel_7.jsonl +3 -0
- data/webnovel_8.jsonl +3 -0
- data/webnovel_9.jsonl +3 -0
README.md
CHANGED
@@ -9,4 +9,58 @@ tags:
|
|
9 |
- pretrain
|
10 |
size_categories:
|
11 |
- 1B<n<10B
|
12 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
- pretrain
|
10 |
size_categories:
|
11 |
- 1B<n<10B
|
12 |
+
---
|
13 |
+
|
14 |
+
## 简介
|
15 |
+
|
16 |
+
搜集网络上的网文小说,清洗,分割后,用于训练大语言模型,共计9000本左右,大约5B左右token。
|
17 |
+
|
18 |
+
## 使用
|
19 |
+
|
20 |
+
### 格式说明
|
21 |
+
|
22 |
+
采用`jsonl`格式存储,分为三个字段:
|
23 |
+
|
24 |
+
- `title` :小说名称
|
25 |
+
- `chapter`:章节
|
26 |
+
- `text`:正文内容
|
27 |
+
|
28 |
+
示例:
|
29 |
+
|
30 |
+
```json
|
31 |
+
{"title": "斗破苍穹", "chapter": " 第一章 陨落的天才", "text": "“斗之力,三段!”\n望着测验魔石碑上面闪亮得甚至有些刺眼的五个大字,少年面无表情,唇角有着一抹自嘲,紧握的手掌,因为大力,而导致略微尖锐的指甲深深的刺进了掌心之中,带来一阵阵钻心的疼痛……\n“萧炎,斗之力,三段!级别:低级!”测验魔石碑之旁,一位中年男子,看了一眼碑上所显示出来的信息,语气漠然的将之公布了出来……\n"}
|
32 |
+
|
33 |
+
```
|
34 |
+
|
35 |
+
### 示例代码
|
36 |
+
|
37 |
+
```python
|
38 |
+
def process_webnovel(input_dir, tokenizer):
|
39 |
+
for subdir, dirs, files in os.walk(input_dir):
|
40 |
+
all_tokens = []
|
41 |
+
for idx, file in enumerate(files):
|
42 |
+
# 只处理txt文件
|
43 |
+
if file.endswith('.jsonl'):
|
44 |
+
# 获取当前文件的绝对路径
|
45 |
+
file_path = os.path.join(subdir, file)
|
46 |
+
# 读取jsonl文件
|
47 |
+
with open(file_path, 'r', encoding='utf-8') as infile:
|
48 |
+
lines = infile.readlines()
|
49 |
+
|
50 |
+
for line in lines:
|
51 |
+
json_obj = json.loads(line) # 解析json字符串为python对象
|
52 |
+
text = json_obj['text']
|
53 |
+
tokens = tokenizer.encode(text, add_special_tokens=False)
|
54 |
+
tokens.append(tokenizer.special_tokens['<eos>'])
|
55 |
+
if len(tokens) > 5:
|
56 |
+
all_tokens += tokens
|
57 |
+
|
58 |
+
arr = np.array(all_tokens, dtype = np.uint16)
|
59 |
+
with open('./data/webnovel_{idx}.bin','wb') as f:
|
60 |
+
f.write(arr.tobytes())
|
61 |
+
```
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
|
data/webnovel_0.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a485ec75b943ff58d268fe285aeb74bc21b729c30f4e1e219bc98e41bf391d3f
|
3 |
+
size 4183415364
|
data/webnovel_1.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:49008fcf3cfb189ee60b5861bf858a6d56950d7a28acbbb9d6479586dd1a0e6c
|
3 |
+
size 4198277512
|
data/webnovel_2.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:79e8655c48d1731e358c23388c69a6423539968211c13cc0d5d3e5ba19c29264
|
3 |
+
size 4191247565
|
data/webnovel_3.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:086050a420e20b9c4a7852c854fcf3a32b6516d556c92fe891d9c4cd64cd6f7d
|
3 |
+
size 4191434074
|
data/webnovel_4.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d92438b444d3899282a8fa6e177ac2d5bc7b428e9d5ce67d3b9f3a6525da8ddb
|
3 |
+
size 4190892198
|
data/webnovel_5.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6026dab18df246df5a4b4ee797690959e5e780c15aaba16fd4a5791ccad9d568
|
3 |
+
size 4187266263
|
data/webnovel_6.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b609b9223726f8dd272cd4ddc1e4a592cbb451e42c3459a3f2961955da7a4dc7
|
3 |
+
size 4187251877
|
data/webnovel_7.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c868d069f7adc10713db0264bcf49e2518a1662a490dd233eb410551939ec7c2
|
3 |
+
size 4206169131
|
data/webnovel_8.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0b774bac2c2e9a7313092cb3b8809541e8d459a1cc721f07b9db7abf2fc90141
|
3 |
+
size 4219093606
|
data/webnovel_9.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:32b1e5eb45332be1f8c51fd43a6dac638eeebab6de14f4f292c2bf855bb5bb2a
|
3 |
+
size 1234998491
|