Commit
·
158150b
1
Parent(s):
462acb6
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,98 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- zh
|
4 |
+
tags:
|
5 |
+
- t5
|
6 |
+
- pytorch
|
7 |
+
- zh
|
8 |
+
license: "apache-2.0"
|
9 |
---
|
10 |
+
|
11 |
+
# T5 for Chinese Spelling Correction Model
|
12 |
+
中文拼写纠错模型
|
13 |
+
|
14 |
+
`shibing624/mengzi-t5-base-chinese-correction` evaluate SIGHAN2015 test data:
|
15 |
+
|
16 |
+
- Sentence Level: precision:0.8321, recall:0.6390, f1:0.7229
|
17 |
+
|
18 |
+
由于训练使用的数据使用了SIGHAN2015的训练集(复现paper),在SIGHAN2015的测试集上达到接近SOTA水平。
|
19 |
+
|
20 |
+
|
21 |
+
未改动模型结构,finetune中文纠错数据集,评估纠错效果很好,模型潜力巨大。
|
22 |
+
|
23 |
+
## Usage
|
24 |
+
|
25 |
+
本项目开源在中文文本纠错项目:[pycorrector](https://github.com/shibing624/pycorrector),可支持t5模型,通过如下命令调用:
|
26 |
+
|
27 |
+
```python
|
28 |
+
from pycorrector.t5.t5_corrector import T5Corrector
|
29 |
+
nlp = T5Corrector("shibing624/mengzi-t5-base-chinese-correction").batch_t5_correct
|
30 |
+
i = "今天新情很好"
|
31 |
+
print(i, ' => ', nlp([i]))
|
32 |
+
```
|
33 |
+
|
34 |
+
|
35 |
+
output:
|
36 |
+
```shell
|
37 |
+
今天新情很好 => 今天心情很好 [('新', '心', 2, 3)]
|
38 |
+
```
|
39 |
+
|
40 |
+
模型文件组成:
|
41 |
+
```
|
42 |
+
mengzi-t5-base-chinese-correction
|
43 |
+
|-- config.json
|
44 |
+
|-- pytorch_model.bin
|
45 |
+
|-- special_tokens_map.json
|
46 |
+
|-- spiece.model
|
47 |
+
|-- tokenizer_config.json
|
48 |
+
`-- tokenizer.json
|
49 |
+
```
|
50 |
+
|
51 |
+
### 训练数据集
|
52 |
+
#### SIGHAN+Wang271K中文纠错数据集
|
53 |
+
|
54 |
+
|
55 |
+
| 数据集 | 语料 | 下载链接 | 压缩包大小 |
|
56 |
+
| :------- | :--------- | :---------: | :---------: |
|
57 |
+
| **`SIGHAN+Wang271K中文纠错数据集`** | SIGHAN+Wang271K(27万条) | [百度网盘(密码01b9)](https://pan.baidu.com/s/1BV5tr9eONZCI0wERFvr0gQ)| 106M |
|
58 |
+
| **`原始SIGHAN数据集`** | SIGHAN13 14 15 | [官方csc.html](http://nlp.ee.ncu.edu.tw/resource/csc.html)| 339K |
|
59 |
+
| **`原始Wang271K数据集`** | Wang271K | [Automatic-Corpus-Generation dimmywang提供](https://github.com/wdimmy/Automatic-Corpus-Generation/blob/master/corpus/train.sgml)| 93M |
|
60 |
+
|
61 |
+
|
62 |
+
SIGHAN+Wang271K中文纠错数据集,数据格式:
|
63 |
+
```json
|
64 |
+
[
|
65 |
+
{
|
66 |
+
"id": "B2-4029-3",
|
67 |
+
"original_text": "晚间会听到嗓音,白天的时候大家都不会太在意,但是在睡觉的时候这嗓音成为大家的恶梦。",
|
68 |
+
"wrong_ids": [
|
69 |
+
5,
|
70 |
+
31
|
71 |
+
],
|
72 |
+
"correct_text": "晚间会听到噪音,白天的时候大家都不会太在意,但是在睡觉的时候这噪音成为大家的恶梦。"
|
73 |
+
},
|
74 |
+
]
|
75 |
+
```
|
76 |
+
|
77 |
+
```shell
|
78 |
+
macbert4csc
|
79 |
+
├── config.json
|
80 |
+
├── pytorch_model.bin
|
81 |
+
├── special_tokens_map.json
|
82 |
+
├── tokenizer_config.json
|
83 |
+
└── vocab.txt
|
84 |
+
```
|
85 |
+
|
86 |
+
如果需要训练t5-correction,请参考[https://github.com/shibing624/pycorrector/tree/master/pycorrector/t5](https://github.com/shibing624/pycorrector/tree/master/pycorrector/t5)
|
87 |
+
|
88 |
+
|
89 |
+
## Citation
|
90 |
+
|
91 |
+
```latex
|
92 |
+
@software{pycorrector,
|
93 |
+
author = {Xu Ming},
|
94 |
+
title = {pycorrector: Text Error Correction Tool},
|
95 |
+
year = {2021},
|
96 |
+
url = {https://github.com/shibing624/pycorrector},
|
97 |
+
}
|
98 |
+
```
|