You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
直接从句子中学习分词方式的手法。提出的背景在于像英语这样的语言有空格可以作为分词的依据,但中文,日语,韩语等语言则没有空格。针对这些语言,为了做到语言独立性,提出了SentencePiece的方法。主要实现了 byte-pairencoding (BPE) (Sennrich et al., 2016) 和 unigram language model (Kudo, 2018)两种subword segmentation算法。
预处理操作上的不同,会影响最终的模型效果。比如NFKC normalization may yield different results depending on the Unicode version. 为了减少影响,sentencepiece的model里不仅包含了vocabulary和segementation parameters,还包含了用于charecter normalization的状态转换器。也就是说,sentencepiece的结果只取决于model file。
Summary:
直接从句子中学习分词方式的手法。提出的背景在于像英语这样的语言有空格可以作为分词的依据,但中文,日语,韩语等语言则没有空格。针对这些语言,为了做到语言独立性,提出了SentencePiece的方法。主要实现了 byte-pairencoding (BPE) (Sennrich et al., 2016) 和 unigram language model (Kudo, 2018)两种subword segmentation算法。
Resource:
Paper information:
Notes:
日语里的拉丁字母有全角和半角之分,这里使用Unicode NFKC normalization来进行处理。
3.5 Self-contained models
预处理操作上的不同,会影响最终的模型效果。比如NFKC normalization may yield different results depending on the Unicode version. 为了减少影响,sentencepiece的model里不仅包含了vocabulary和segementation parameters,还包含了用于charecter normalization的状态转换器。也就是说,sentencepiece的结果只取决于model file。
3 subword algorithms help to improve your NLP model performance: 这篇文章做了一个很好的总结。
而SentencePiece则是包含了BPE和 Unigram Language Model两种分词方法的工具包。其中默认的分词方法是 Unigram Language Model。
用法:
下面的训练的部分,使用的训练数据data.txt应该是不包含test数据才对的。data.txt的格式应该是一行一句话。
执行完晚上的部分,应该能得到trained_model.model和trained_model.vocab两个文件夹。后者保存了subword和对应的emission log probabilities,其id就是所在的行号。
使用方法
其他一些和sentencepiece相关的文章:
使用上面训练得到的sentencepiece模型来进行分解的结果。可以看到应该是文字设定的太大了,结果分割非常细。
其他一些和sentencepiece相关的文章:
比较不同分词手法结果:
Model Graph:
Result::
Thoughts:
Next Reading:
The text was updated successfully, but these errors were encountered: