基于BERT的文本纠错模型,使用PyTorch实现
- 从 http://nlp.ee.ncu.edu.tw/resource/csc.html下载SIGHAN数据集
- 解压上述数据集并将文件夹中所有 ''.sgml'' 文件复制至 datasets/csc/ 目录
- 复制 ''SIGHAN15_CSC_TestInput.txt'' 和 ''SIGHAN15_CSC_TestTruth.txt'' 至 datasets/csc/ 目录
- 下载 https://github.com/wdimmy/Automatic-Corpus-Generation/blob/master/corpus/train.sgml 至 datasets/csc 目录
- 请确保以下文件在 datasets/csc 中
train.sgml B1_training.sgml C1_training.sgml SIGHAN15_CSC_A2_Training.sgml SIGHAN15_CSC_B2_Training.sgml SIGHAN15_CSC_TestInput.txt SIGHAN15_CSC_TestTruth.txt
运行以下命令以训练模型,首次运行会自动处理数据。
python tools/train_csc.py --config_file train_SoftMaskedBert.yml
可选择不同配置文件以训练不同模型,目前支持以下配置文件:
- train_bert4csc.yml
- train_macbert4csc.yml
- train_SoftMaskedBert.yml
component | sentence level acc | p | r | f |
---|---|---|---|---|
SoftMaskedBert Detection | 0.5045 | 0.8252 | 0.8416 | 0.8333 |
SoftMaskedBert Correction | 0.8055 | 0.9395 | 0.8748 | 0.9060 |
- Spelling Error Correction with Soft-Masked BERT
- http://ir.itc.ntnu.edu.tw/lre/sighan8csc.html
- https://github.com/wdimmy/Automatic-Corpus-Generation
- transformers
- https://github.com/sunnyqiny/Confusionset-guided-Pointer-Networks-for-Chinese-Spelling-Check
- SoftMaskedBert-PyTorch
- Deep-Learning-Project-Template