shibing624
commited on
Commit
·
32144f9
1
Parent(s):
8a450b3
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,107 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- zh
|
4 |
+
tags:
|
5 |
+
- bart
|
6 |
+
- pytorch
|
7 |
+
- zh
|
8 |
+
- Text2Text-Generation
|
9 |
+
license: "apache-2.0"
|
10 |
+
widget:
|
11 |
+
- text: "辰导中引述她的话说:核子间题的解决之道系于克什米尔纷争。"
|
12 |
+
|
13 |
---
|
14 |
+
|
15 |
+
# Bart for Chinese Spelling Correction(bart4csc) Model
|
16 |
+
BART中文拼写纠错模型
|
17 |
+
|
18 |
+
`bart4csc-base-chinese` evaluate SIGHAN2015 test data:
|
19 |
+
|
20 |
+
Sentence Level: acc:0.81
|
21 |
+
|
22 |
+
case:
|
23 |
+
|
24 |
+
|input_text|target_text|pred|
|
25 |
+
|:-- |:--- |:--- |
|
26 |
+
|辰导中引述她的话说:核子间题的解决之道系于克什米尔纷争。|报导中引述她的话说:核子问题的解决之道系于克什米尔纷争。|报导中引述她的话说:核子问题的解决之道系于克什米尔纷争。|
|
27 |
+
|报导并末说明事故发生的原因。|报导并未说明事故发生的原因。|报导并未说明事故发生的原因。|
|
28 |
+
|
29 |
+
训练使用了SIGHAN+Wang271K中文纠错数据集,在SIGHAN2015的测试集上达到接近SOTA水平。
|
30 |
+
|
31 |
+
|
32 |
+
## Usage
|
33 |
+
|
34 |
+
本项目开源在文本生成项目:[textgen](https://github.com/shibing624/textgen),可支持Bart模型,通过如下命令调用:
|
35 |
+
|
36 |
+
Install package:
|
37 |
+
```shell
|
38 |
+
pip install -U textgen
|
39 |
+
```
|
40 |
+
|
41 |
+
```python
|
42 |
+
from textgen import BartSeq2SeqModel
|
43 |
+
tokenizer = BertTokenizerFast.from_pretrained('shibing624/bart4csc-base-chinese')
|
44 |
+
model = BartSeq2SeqModel(
|
45 |
+
encoder_type='bart',
|
46 |
+
encoder_decoder_type='bart',
|
47 |
+
encoder_decoder_name='shibing624/bart4csc-base-chinese',
|
48 |
+
tokenizer=tokenizer)
|
49 |
+
sentences = ["少先队员因该为老人让坐"]
|
50 |
+
print(model.predict(sentences))
|
51 |
+
# ['少先队员应该为老人让座']
|
52 |
+
```
|
53 |
+
|
54 |
+
|
55 |
+
模型文件组成:
|
56 |
+
```
|
57 |
+
bart4csc-base-chinese
|
58 |
+
├── config.json
|
59 |
+
├── model_args.json
|
60 |
+
├── pytorch_model.bin
|
61 |
+
├── special_tokens_map.json
|
62 |
+
├── tokenizer_config.json
|
63 |
+
├── spiece.model
|
64 |
+
└── vocab.txt
|
65 |
+
```
|
66 |
+
|
67 |
+
|
68 |
+
### 训练数据集
|
69 |
+
#### SIGHAN+Wang271K中文纠错数据集
|
70 |
+
|
71 |
+
|
72 |
+
| 数据集 | 语料 | 下载链接 | 压缩包大小 |
|
73 |
+
| :------- | :--------- | :---------: | :---------: |
|
74 |
+
| **`SIGHAN+Wang271K中文纠错数据集`** | SIGHAN+Wang271K(27万条) | [百度网盘(密码01b9)](https://pan.baidu.com/s/1BV5tr9eONZCI0wERFvr0gQ)| 106M |
|
75 |
+
| **`原始SIGHAN数据集`** | SIGHAN13 14 15 | [官方csc.html](http://nlp.ee.ncu.edu.tw/resource/csc.html)| 339K |
|
76 |
+
| **`原始Wang271K数据集`** | Wang271K | [Automatic-Corpus-Generation dimmywang提供](https://github.com/wdimmy/Automatic-Corpus-Generation/blob/master/corpus/train.sgml)| 93M |
|
77 |
+
|
78 |
+
|
79 |
+
SIGHAN+Wang271K中文纠错数据集,数据格式:
|
80 |
+
```json
|
81 |
+
[
|
82 |
+
{
|
83 |
+
"id": "B2-4029-3",
|
84 |
+
"original_text": "晚间会听到嗓音,白天的时候大家都不会太在意,但是在睡觉的时候这嗓音成为大家的恶梦。",
|
85 |
+
"wrong_ids": [
|
86 |
+
5,
|
87 |
+
31
|
88 |
+
],
|
89 |
+
"correct_text": "晚间会听到噪音,白天的时候大家都不会太在意,但是在睡觉的时候这噪音成为大家的恶梦。"
|
90 |
+
},
|
91 |
+
]
|
92 |
+
```
|
93 |
+
|
94 |
+
|
95 |
+
- 如果需要训练Bart模型,请参考[https://github.com/shibing624/textgen/blob/main/examples/seq2seq/training_bartseq2seq_zh_demo.py](https://github.com/shibing624/textgen/blob/main/examples/seq2seq/training_bartseq2seq_zh_demo.py)
|
96 |
+
- 了解更多纠错模型,请移步:[https://github.com/shibing624/pycorrector](https://github.com/shibing624/pycorrector)
|
97 |
+
|
98 |
+
## Citation
|
99 |
+
|
100 |
+
```latex
|
101 |
+
@software{textgen,
|
102 |
+
author = {Xu Ming},
|
103 |
+
title = {textgen: Implementation of Text Generation models},
|
104 |
+
year = {2022},
|
105 |
+
url = {https://github.com/shibing624/textgen},
|
106 |
+
}
|
107 |
+
```
|