论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking

简要信息:

序号

属性


1

模型名称

SpellBERT

2

发表位置

EMNLP2021

3

所属领域

自然语言处理、中文拼写纠错

4

研究内容

中文拼写纠错

5

核心内容

预训练语言模型

6

GitHub源码

​​https://github.com/benbijituo/SpellBERT/​

7

论文PDF

​https://dl.acm.org/doi/10.1145/3404835.3463050​

一、动机

  • 中文含有超过3500个词组成的词表,搜索空间太大,且错误分布不均匀;
  • 中文的错误一般包含形似(Graphical)和音似(Phonetic)两种情况,如图所示:
  • 论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_中文拼写纠错

  • 先前的工作关注于confusion set的构建,而confusion set的质量会对纠错效果起到影响;

  Confusion set是指混淆集,简单地认为是一个字典,key表示目标字符,value则为一系列与Key存在字形或字音相似的字符集合。例如“自”的混淆集可以是“白”、“曰”等。

  • 本文依然利用视觉和语音方面信息,不同于先前工作,视觉部分,采用部首偏旁信息,语音部分,则将整个pinyin视为整体,而非序列;

二、方法

  提出SpellBERT模型,将CSC视为序列标注问题,即输入一个文本序列,输出等长的文本序列。模型如下图所示:

论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_深度学习_02

2.1 MLM

  backbone采用基于MLM的预训练语言模型(例如BERT)。BERT输入为一个待纠错的文本序列,输出部分是每个token对应的隐状态向量:

论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_中文拼写纠错_03

论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_自然语言处理_04

其中 论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_深度学习_05 表示第 论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_自然语言处理_06 个token的隐状态向量,将其与所有word embedding计算相似度,得到当前token预测的概率分布: 论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_自然语言处理_07

2.2 Visual & Phonetic Fusion

  视觉和语音信息是CSC中的关键,而confusion set无法完全包含所有的错误,本部分则探究如何将这视觉和语音方面的信息与word embedding进行融合;

  • Visual errors have similar shapes as correct characters while phonetic errors have similar pronunciation. 中文的拼写错误通常来源于相似字形或相似读音所导致。
  • These models relied on confusion set to filter candidates but the confusion set might be out-of-date or out-of-domain. 现有的工作直接构建固定的混淆集,使得很难确保所有的错误都能被涵盖;
  • Chinese characters can be decomposed into components namely radicals and visual errors often have overlap radicals with the correct character. Pinyin is a sequence of pronunciation descriptions for Chinese characters and phonetic errors often have overlap pinyin.

  因此,本文引入图网络实现信息融合,具体地说,采用Relational Graph Convolutional Network(R-GCN)。

(1)图的构建:

  • 对于一个文本,每个汉字(character)、偏旁部首以及pinyin都可以视为一个节点。如果某个偏旁或pinyin属于某个汉字,则它们之间有边相连
  • 如果两个汉字(character)相邻,则二者存在一条边;
  • 另外对于每个汉字,添加自环

  因此,整个图存在四种类型的边:

  • 字符与偏胖部首:如果一个字符包含某一个偏旁部首,则之间存在边;
  • 字符与拼音:如果一个字符存在某一个发音,则之间存在边;
  • 相邻字符:如果两个字符在一定窗口内共现,则之间存在边;
  • 自环:每个字符均与自己本身存在环边;

(2)节点初始化:

  • 每个汉字(character)节点,直接使用BERT word embedding;
  • 对于偏旁部首和汉字节点,将所有与之相关的character emebdding进行平均;

(3)迭代表征:

论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_ci_08


其中 论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_ci_09 表示汉字 论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_Soft_10论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_ci_11 表示与 论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_Soft_10 相邻的所有节点,最终得到的 论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_深度学习_13

论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_ci_14

2.3 Enhance Pre-training Tasks for CSC

  因为添加了一些新的模块,作者认为需要进行预训练来提高模型的泛化能力。因此新增radical predictionpinyin prediction两个预训练任务。
对于构建的图,随机mask掉汉字(character)节点与偏旁部首或pinyin相连的边,然后预测它们之间是否存在边,即相当于reconstruction connection。

Through reconstructing connections, the model can learn a better representation that contains not only contextual information but also visual and phonetic information.

随机挑选15%的character,其中:

  • 10%概率保持不变,预测character、radical和pinyin;
  • 60%被替换为[MASK],与其相连的所有边随机mask80%的边。预测被mask掉的character、radical和pinyin;
  • 30%概率从confusion set中随机采样一个错误的character,同时与其相连的所有边随机mask80%的边,预测被替换的character、radical和pinyin;

  因为图中的边没有embedding,因此将radical prediction和pinyin prediction视为token classification任务:

  • 对于某个character,取对应的某个radical和pinyin作为groud truth,并再取其他radical和pinyin作为负样本;
  • radical和pinyin embedding与character的BERT表征后的向量计算相似度。

2.4 Reducing Parameter

  作者认为,模型中既包含BERT,又包含GCN,参数量可能会很大,因此提出Reducing操作,即只使用4层的BERT作为backbone。实验也说明只需要4层的backbone就能达到很好效果。

三、实验

backbone:4层BERT

pre-training语料:https://zenodo.org/record/3402023#.YZs2n5BBy3K,随机挑选1M训练,max_len=128,batch_size=1024,lr=5e-5,step=10K,训练2天时间。

fine-tuning

数据集:SIGHAN14、SIGHAN15、OCR
(1)SIGHAN14、SIGHAN15
直接使用​​​https://github.com/ACL2020SpellGCN/SpellGCN/tree/master/data​​提供的数据,其中:

  • merged:表示SIGHAN13、SIGHAN14和SIGHAN15混合训练集(10K):
  • SIGHAN13、SIGHAN14、SIGHAN15:分别表示测试集

  同时获取《A Hybrid Approach to Automatic Corpus Generation for Chinese Spelling Check》
评价脚本:

(2)OCR
  使用《FASPell: A Fast, Adaptable, Simple, Powerful Chinese Spell Checker Based On DAE-Decoder Paradigm》构建的数据集:https://github.com/iqiyi/FASPell,总共4575句子

实验结果:

论文解读:SpellBERT:A Lightweight Pretrained Model for Chinese Spelling Checking_ci_15