中文分词任务就是把连续的汉字分隔成具有语言语义学意义的词汇。中文的书写方式不像英文等日耳曼语系语言词与词之前显式的用空格分隔。为了让计算机理解中文文本,通常来说中文信息处理的第一步就是进行文本分词。 中文分词样例: 本方法采用char-BiLSTM-CRF模型,word-embeddig使用Chiese-Word-Vectors。序列标注标签体系(B、I、E、S),四个标签分别表示单字处理单词的起始、中间、终止位置或者该单字独立成词。char-BiLSTM-CRF模型具体结构可以参考论文Neural Architectures for Named Etity Recogitio 本模型主要用于给输入中文句子产出分词结果。用户可以自行尝试输入中文句子。具体调用方式请参考代码示例。 在安装ModelScope完成之后即可使用chiese-word-segmetatio(中文分词)的能力, 默认单句长度不超过默认单句长度不超过126。如需增加单句的切分长度,可以修改TokeClassificatioTrasformersPreprocessor中的最大sequece长度。 本模型基于PKU数据集(通用新闻领域)上训练,在垂类领域中文文本上的分词效果会有降低,请用户自行评测后决定如何使用。 本模型采用新闻领域分词标注数据集PKU标注训练。 PKU数据集标注数据样例: 数据预处理成(B、I、E、S)标签体系的数据格式, 每一个独立的单字对应一个独立的标签, 预处理后数据样例如下: 模型采用1张NVIDIA V100机器训练, 超参设置如下: 模型在PKU测试数据评估结果: char-BiLSTM-CRF模型可以参考下列论文LSTM通用领域中文分词模型介绍
模型描述
期望模型使用方式以及适用范围
如何使用
代码范例
from modelscope.models import Model
from modelscope.pipelies import pipelie
from modelscope.utils.costat import Tasks
from modelscope.preprocessors import TokeClassificatioTrasformersPreprocessor
model_id = 'damo/lp_lstmcrf_word-segmetatio_chiese-ews'
model = Model.from_pretraied(model_id)
tokeizer = TokeClassificatioTrasformersPreprocessor(model.model_dir)
pipelie_is = pipelie(task=Tasks.word_segmetatio, model=model, preprocessor=tokeizer)
result = pipelie_is(iput="今天天气不错,适合出去游玩")
prit (result)
# {'output': '今天 天气 不错 , 适合 出去 游玩'}
模型局限性以及可能的偏差
## 训练数据介绍
模型训练流程
预处理
有心 栽 得 梧桐树 , 自 有 远方 凤凰 来 。
在 这 辞 旧 迎 新 的 美 好 时 刻 , 我 祝 大 家 新 年 快 乐 , 家 庭 幸 福 !
S-CWS S-CWS B-CWS I-CWS I-CWS E-CWS S-CWS B-CWS E-CWS B-CWS E-CWS S-CWS S-CWS S-CWS B-CWS E-CWS B-CWS E-CWS B-CWS E-CWS S-CWS B-CWS E-CWS B-CWS E-CWS S-CWS
训练
trai_epochs=10
max_sequece_legth=256
batch_size=125
learig_rate=5e-5
optimizer=AdamW
数据评估及结果
Model
Precisio
Recall
F1
Iferece speed o CPU
BAStructBERT-Base
96.44
97.31
96.87
1.0x
BAStructBERT-Lite
96.66
95.59
96.12
2.91x
LSTMCRF
95.68
94.83
95.16
13.16x
论文引用
@iproceedigs{lample-etal-2016-eural,
title = "Neural Architectures for Named Etity Recogitio",
author = "Lample, Guillaume ad
Ballesteros, Miguel ad
Subramaia, Sadeep ad
Kawakami, Kazuya ad
Dyer, Chris",
booktitle = "Proceedigs of the 2016 Coferece of the North {A}merica Chapter of the Associatio for Computatioal Liguistics: Huma Laguage Techologies",
moth = ju,
year = "2016",
address = "Sa Diego, Califoria",
publisher = "Associatio for Computatioal Liguistics",
url = "https://aclathology.org/N16-1030",
doi = "10.18653/v1/N16-1030",
pages = "260--270",
}
点击空白处退出提示







评论