Please wait a minute...
Journal of ZheJiang University (Engineering Science)  2027, Vol. 61 Issue (1): 154-164    DOI: 10.3785/j.issn.1008-973X.2027.01.015
Computer Technology     
Chinese word segmentation based on Transformer and CapsNet
Yiming Liu1(),Jingyi Fu2,Zhiruo Wang2,Wenfang Zhang2,*()
1. School of Computer and Artificial Intelligence, Southwest Jiaotong University, Chengdu 611756, China
2. School of Information Science and Technology, Southwest Jiaotong University, Chengdu 611756, China
Download: HTML     PDF(1801KB) HTML
Export: BibTeX | EndNote (RIS)      

Abstract  

A small-scale sensitive-word dataset was constructed and an innovative Transformer-CapsNet-CRF (TC-CRF) model was proposed, aiming to address the difficulty of obtaining task-specific data and the demand for improved efficiency in Chinese word segmentation. The global feature extraction capability of Transformer, the local feature extraction advantage of Capsule Network (CapsNet), and the sequence optimization and prediction ability of Conditional Random Field (CRF) were integrated. Experiments were conducted on the CTB6 dataset. Results showed that the TC-CRF model achieved an F1 score of 97.5% when combined with BERT pre-training. On the small-scale sensitive-word dataset, the TC-CRF model achieved an F1 score of 86.9% without using any pre-trained model, demonstrating strong segmentation performance and verifying its ability to effectively utilize limited data. The experimental results indicated that the proposed model effectively combined the advantages of global and local feature extraction, providing a new solution for Chinese word segmentation. The main innovation of this study lay in combining Capsule Network with Transformer and applying the BERT pre-training module to Chinese word segmentation. The integration of these methods improved the accuracy and generalization ability of the model.



Key words: natural language processing      Chinese word segmentation      dataset construction      Transformer      Capsule Network (CapsNet)     
Received: 11 April 2025      Published: 25 November 2026
CLC:  TP 391  
Corresponding Authors: Wenfang Zhang     E-mail: 2022112413@my.swjtu.edu.cn;wfzhang@swjtu.edu.cn
Cite this article:

Yiming Liu,Jingyi Fu,Zhiruo Wang,Wenfang Zhang. Chinese word segmentation based on Transformer and CapsNet. Journal of ZheJiang University (Engineering Science), 2027, 61(1): 154-164.

URL:

https://www.zjujournals.com/eng/10.3785/j.issn.1008-973X.2027.01.015     OR     https://www.zjujournals.com/eng/Y2027/V61/I1/154


基于Transformer和胶囊网络的中文分词方法

针对中文分词任务中特定数据获取困难及效率提升的需求,构建小规模敏感词数据集,并提出创新的Transformer-CapsNet-CRF(TC-CRF)模型. 该模型融合了Transformer的全局特征提取能力、胶囊网络(CapsNet)的局部特征提取优势以及条件随机场(CRF)的序列优化预测能力. 在CTB6数据集上进行实验验证,结果表明,TC-CRF模型在结合BERT预训练的情况下,F1分数达到97.5%. 在小规模敏感词数据集上,TC-CRF模型在不使用任何预训练的情况下,F1分数达到86.9%,显示出卓越的分词效果,验证了其对有限数据的高效利用能力. 研究结果表明,该模型有效地结合了全局和局部特征提取的优势,为中文分词提供了新的解决方案. 本研究创新点在于将胶囊网络与Transformer相结合,并在中文分词中应用BERT预训练模块,上述方法的结合提高了模型的准确性和泛化能力.


关键词: 自然语言处理,  中文分词,  数据集构建,  Transformer,  胶囊网络(CapsNet) 
Fig.1 Overall architecture of TC-CRF model
Fig.2 Structure of Transformer encoder module
Fig.3 Workflow of capsule-based local feature modeling
Fig.4 Category distribution of sensitive terms dataset
Fig.5 Performance on CTB6 validation set under different Dropout rates
参数取值参数取值
Seq_len250input_caps_dim16
Dropout0.2input_caps8
Batch32output_caps_dim16
transformer_hidden_size256output_caps8
Table 1 Experimental hyperparameter settings
Fig.6 Hyperparameter tuning results of Capsule Network
模型名称input_capsinput_caps_dimoutput_capsoutput_caps_dim
Group_A168168
Group_B8888
Group_C16161616
Group_D816816
Table 2 Hyperparameter combinations of Capsule Network
模型名称F1分数/%
BERT+L-SAN-CRF97.30
BERT+BiLSTM-CRF97.25
BERT+TC-CRF97.52
Table 3 F1 Score comparison between TC-CRF and baseline models on CTB6 test set
模型名称para/106
L-SAN+CRF10.9
BiLSTM+CRF10.7
Transfomrer_CRF4.9
Capsule_CRF6.5
TC-CRF9.2
Table 4 Comparison of number of model parameters
模型名称v/(st·s?1)
训练集验证集测试集
Transformer_CRF217.20410.64475.36
TC-CRF260.33465.35388.09
BERT+Transformer_CRF96.69230.11190.61
BERT+TC-CRF92.82210.05169.24
Table 5 Speed comparison of different branch models under same single-A100-GPU environment
模型名称F1分数/%
Transformer_CRF93.73
Capsule_CRF93.75
TC-CRF93.43
BERT+Transformer_CRF97.48
BERT+Capsule_CRF97.49
BERT+TC-CRF97.52
Table 6 Ablation study results for different model component combinations on CTB6
Fig.7 Performance comparison between TC-CRF and Transformer-CRF on sensitive word datasets of different sizes
模型名称F1分数/%
PKUMSRCTB6
L-SAN+CRF+BERT96.598.497.3
BiLSTM+CRF+BERT96.398.497.3
AM-GSD[16]96.698.4?
WE-CONV-SEG[18]96.597.5?
BERT_NGRAM[33]97.196.0?
TENER+CLSEG(LS)[34]96.498.2?
ACNNC[35]96.296.4?
BERT+capsule+CRF96.798.497.5
BERT+TC-CRF96.798.497.5
Table 7 F1 Score comparison of different Chinese word segmentation models on single A100 GPU
Fig.8 Similarity heat map between TC-CRF tag scores
Fig.9 Similarity heat map between Transformer tag scores
[1]   Cai D, Zhao H, Zhang Z, et al. Fast and accurate neural word segmentation for Chinese [C]//Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics. Vancouver: ACL, 2017: 608–615.
[2]   Du G. Research advanced in Chinese word segmentation methods and challenges. Applied and Computational Engineering, 2024, 37 (1): 16- 22.
doi: 10.54254/2755-2721/37/20230464
[3]   Sun W, Xu J. Enhancing Chinese word segmentation using unlabeled data [C]// Proceedings of the 2011 Conference on Empirical Methods in Natural Language Processing. Edinburgh: Association for Computational Linguistics, 2011: 970–979.
[4]   Xu J, Sun X. Dependency-based gated recursive neural network for Chinese word segmentation [C]// Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics. Berlin: ACL, 2016: 567–572.
[5]   Zhang Y, Clark S. Chinese segmentation with a word-based perceptron algorithm [C]// Proceedings of the 45th Annual Meeting of the Association of Computational Linguistics. Prague: Association for Computational Linguistics, 2007: 840–847.
[6]   Zhang H P, Liu Q, Cheng X Q, et al. Chinese lexical analysis using hierarchical hidden Markov model [C]//Proceedings of the Second SIGHAN Workshop on Chinese Language Processing -. Sapporo. ACL, 2003: 63–70.
[7]   Lafferty J D, Mccallum A, Pereira F. Conditional random fields: probabilistic models for segmenting and labeling sequence data [C]// Proceedings of the Eighteenth International Conference on Machine Learning (IC ML '01). San Francisco: Morgan Kaufmann Publishers Inc. , 2001: 282–289.
[8]   Cai D, Zhao H. Neural word segmentation learning for Chinese [C]//Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics. Berlin: ACL, 2016: 409–420.
[9]   Yang J, Zhang Y, Dong F. Neural word segmentation with rich pretraining [C]// Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics. Vancouver: ACL, 2017: 839–849.
[10]   Zhang M, Zhang Y, Fu G. Transition-based neural word segmentation [C]// Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics. Berlin: ACL, 2016: 421–431.
[11]   Zhou H, Yu Z, Zhang Y, et al. Word-context character embeddings for Chinese word segmentation [C]// Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing. Copenhagen: ACL, 2017: 760–766.
[12]   袁里驰. 基于BiLSTM-CRF的中文分词和词性标注联合方法. 中南大学学报(自然科学版), 2023, 54 (8): 3145- 3153.
Yuan Lichi. A joint method for Chinese word segmentation and part-of-speech tagging based on BiLSTM-CRF. Journal of Central South University (Science and Technology), 2023, 54 (8): 3145- 3153.
doi: 10.11817/j.issn.1672-7207.2023.08.018
[13]   程博, 李卫红, 童昊昕. 基于BiLSTM-CRF的中文层级地址分词. 地球信息科学学报, 2019, 21 (8): 1143- 1151.
Cheng Bo, Li Weihong, Tong Haoxin. Chinese address segmentation based on BiLSTM-CRF. Journal of Geo-Information Science, 2019, 21 (8): 1143- 1151.
[14]   Li X, Pu X. Semantic role labeling based on highway-BiLSTM-CRF model. International Journal of Computer Trends and Technology, 2021, 69 (10): 23- 27.
doi: 10.14445/22312803/ijctt-v69i10p103
[15]   Vaswani A, Shazeer N, Parmar N, et al. Attention Is All You Need [C]// Proceedings of the 31st Conference on Neural Information Processing Systems. Long Beach: Curran Associates Inc. , 2017: 6000–6010.
[16]   周保途. 句法依存引导的自注意力机制的中文分词. 计算机系统应用, 2023, 32 (9): 265- 271.
Zhou Baotu. Chinese Word Segmentation of Self-attention Mechanisms Guided by Syntactic Dependence. Computer Systems and Applications, 2023, 32 (9): 265- 271.
doi: 10.15888/j.cnki.csa.009221
[17]   Gan L, Zhang Y. Investigating self-attention network for Chinese word segmentation [C]// Proceedings of the IEEE/ACM Transactions on Audio, Speech, and Language Processing. [S. l. ]: IEEE, 2020: 2933–2941.
[18]   Wang C, Xu B. Convolutional neural network with word embeddings for Chinese word segmentation [C]// Proceedings of the Eighth International Joint Conference on Natural Language Processing (Volume 1: Long Papers). Taipei: Asian Federation of Natural Language Processing, 2017: 163–172.
[19]   Wei H, Guo X. BWSC: BERT-based N-gram enhanced word segmentation for Chinese [C]// 6th International Conference on Frontier Technologies of Information and Computer. Qingdao: IEEE, 2024: 496–502.
[20]   Sabour S, Frosst N, Hinton G E. Dynamic routing between capsules [C]// Proceedings of the 31st International Conference on Neural Information Processing Systems. Long Beach: Curran Associates Inc. , 2017: 3859–3869.
[21]   荆沁璐, 冯林, 王旭, 等. 改进路由机制的元学习少样本研究本分类模型. 小型微型计算机系统, 2023, 44 (11): 2392- 2400.
Jing Qinlu, Feng Lin, Wang Xu, et al. Few-shot text classification model based on meta-learning with improved routing mechanisms. Journal of Chinese Computer Systems, 2023, 44 (11): 2392- 2400.
doi: 10.20009/j.cnki.21-1106/TP.2022-0286
[22]   陈珊, 孙仁诚, 邵峰晶, 等. 基于胶囊网络的动态路由研究与改进. 计算机工程, 2022, 48 (5): 208- 214.
Chen Shan, Sun Rencheng, Shao Fengjing, et al. Research and improvement of dynamic routing based on capsule network. Computer Engineering, 2022, 48 (5): 208- 214.
doi: 10.19678/j.issn.1000-3428.0062928
[23]   麦范金, 王挺. 基于双向最大匹配和HMM的分词消歧模型. 数据分析与知识发现, 2008, 24 (8): 37- 41.
Mai Fanjin, Wang Ting. Sense disambiguation of Chinese segmentation based on bi-direction matching method and HMM. Data Analysis and Knowledge Discovery, 2008, 24 (8): 37- 41.
[24]   黄昌宁, 赵海. 中文分词十年回顾. 中文信息学报, 2007, 21 (3): 8- 19.
Huang Changning, Zhao Hai. Chinese word segmentation: a decade review. Journal of Chinese Information Processing, 2007, 21 (3): 8- 19.
doi: 10.3969/j.issn.1003-0077.2007.03.002
[25]   涂文博, 袁贞明, 俞凯. 无池化层卷积神经网络的中文分词方法. 计算机工程与应用, 2020, 56 (2): 120- 126.
Tu Wenbo, Yuan Zhenming, Yu Kai. Convolutional neural networks without pooling layer for Chinese word segmentation. Computer Engineering and Applications, 2020, 56 (2): 120- 126.
doi: 10.3778/j.issn.1002-8331.1809-0177
[26]   Chen X, Qiu X, Zhu C, et al. Gated recursive neural network for Chinese word segmentation [C]// Proceedings of the 53rd Annual Meeting of the Association for Computational Linguistics and the 7th International Joint Conference on Natural Language Processing. Beijing: ACL, 2015: 1744–1753.
[27]   Chen X, Qiu X, Zhu C, et al. Long short-term memory neural networks for Chinese word segmentation [C]// Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing. Lisbon: ACL, 2015: 1197–1206.
[28]   任智慧, 徐浩煜, 封松林, 等. 基于LSTM网络的序列标注中文分词法. 计算机应用研究, 2017, 34 (5): 1321- 1324,1341.
Ren Zhihui, Xu Haoyu, Feng Songlin, et al. Sequence labeling Chinese word segmentation method based on LSTM networks. Application Research of Computers, 2017, 34 (5): 1321- 1324,1341.
doi: 10.3969/j.issn.1001-3695.2017.05.009
[29]   Jin Y, Tao S, Liu Q, et al. A BiLSTM-CRF based approach to word segmentation in Chinese [C]// 2022 IEEE International Conference on Dependable, Autonomic and Secure Computing, IEEE International Conference on Pervasive Intelligence and Computing, IEEE International Conference on Cloud and Big Data Computing, IEEE International Conference on Cyber Science and Technology Congress (DASC/PiCom/CBDCom/CyberSciTech). Falerna: IEEE, 2022: 1–4.
[30]   贾旭东, 王莉. 基于多头注意力胶囊网络的文本分类模型. 清华大学学报 (自然科学版), 2020, 60 (5): 415- 421.
Jia Xudong, Wang Li. Text classification model based on multi-head attention capsule neworks. Journal of Tsinghua University (Science and Technology), 2020, 60 (5): 415- 421.
doi: 10.16511/j.cnki.qhdxxb.2020.26.006
[31]   Emerson T. The second international Chinese word segmentation bakeoff [C]// Proceedings of the 4th SIGHAN Workshop on Chinese Language Processing. Jeju Island: Association for Computational Linguistics, 2005.
[32]   Palmer M, Xue N, Xia F, et al. Chinese treebank 6.0 (Version 1.0) [DS/OL]. [2025−02−01]. https://catalog.ldc.upenn.edu/LDC2007T36.
[33]   陆斯悦, 张禄, 李香龙, 等. 基于BERT的电力领域无监督分词方法. 信息技术, 2024 (1): 96- 103.
Lu Siyue, Zhang Lu, Li Xianglong, et al. Unsupervised word segmentation method in power domain based on BERT. Information Technology, 2024 (1): 96- 103.
doi: 10.13274/j.cnki.hdzj.2024.01.015
[34]   Xu Z, Xiang Y. Improving Chinese word segmentation with character–lexicon class attention. Neural Computing and Applications, 2025, 37 (5): 3857- 3867.
doi: 10.1007/s00521-024-10693-2
[35]   张忠林, 余炜, 闫光辉, 等. 基于ACNNC模型的中文分词方法. 中文信息学报, 2022, 36 (8): 12- 19,28.
Zhang Zhonglin, Yu Wei, Yan Guanghui, et al. Chinese word segmentation based on ACNNC model. Journal of Chinese Information Processing, 2022, 36 (8): 12- 19,28.
doi: 10.3969/j.issn.1003-0077.2022.08.002
[1] Weiguo WAN,Kaichen ZHONG,Yingmei ZHANG,Li YAO,Shuhong BAO,Dawei GONG. Face photo-to-sketch synthesis based on spatially adaptive Transformer[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(9): 1953-1961.
[2] Shuaishuai GAO,Cheng WEI,Fei HUI,Jingcheng ZHANG,Hanchen SONG. Lane-changing intention prediction based on spatiotemporal feature and interaction modeling[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(9): 2031-2041.
[3] Kaiwei XU,Hafiz KHIZER BIN TALIB,Yanlong CAO,Yuanping XU,Zhijie XU,Jingchun SONG. Lightweight micro-expression recognition based on optical flow and convolutional vision Transformer[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(7): 1381-1391.
[4] Liming LIANG,Chengbin WANG,Yi ZHONG,Linjun CHEN,Jian WU. Retinal vessel segmentation based on lightweight high-frequency Transformer and feature complementary fusion[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(7): 1392-1403.
[5] Shaojiang DONG,Tao XIAO,Zhenming LV,Haoran XIA,Jiayuan LUO,Shizheng SUN,Xia ZHANG,Chao LIU. Small organism detection in underwater color-cast environments based on improved RT-DETR[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(7): 1404-1415.
[6] Yanchun YANG,Jialong LI. Multi-path collaboration-based and spatial-spectral prior-based hyperspectral and multispectral image fusion[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(7): 1427-1437.
[7] Wenjun ZHENG,Zhikun LI,Shoufei HAN. Aspect-based sentiment analysis via knowledge-enhanced graph Transformer[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(6): 1269-1276.
[8] Wenyuan BIAN,Jiuyuan HUO,Chen CHANG. Wind power data cleaning method based on improved imputation diffusion model and LSTM[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(5): 1016-1026.
[9] Jing PENG,Jiarong YAN,Jiaying LIU,Ziyi WEI,Shan BAI,Yahong DENG. Multi-scale residual learning combined with Dilformer for dual-stream medical image registration network[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(5): 1082-1091.
[10] Yuzhen HOU,Xiaohong SHEN,Li LI,Mingyuan YANG,Caiming ZHANG. Dual-stage deraining network based on mask and non-local attention[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(4): 791-799.
[11] Gang WAN,Xiaobo WANG,Gang SHI,Dezhen YE,Sisi ZHU,Fan SI. Underwater image enhancement algorithm based on feature refinement and attention-augmented reconstruction[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(4): 800-811.
[12] Yansong LI,Ning CHEN,Fengguang LIU,Pan CHEN,Xiaofeng HUANG,Huili GE. Large language model framework for event extraction based on staged semantic perception[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(3): 527-535.
[13] Yi PENG,Heng LI,Qingqing YANG,Hui LI,Jianming WANG. Image semantic communication based on CSI-guided attention and gated generation repair[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(12): 2694-2703.
[14] Yi PENG,Heng LI,Qingqing YANG,Hui LI,Jianming WANG. Multilevel semantic MIMO transmission of images based on Swin Transformer[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(11): 2462-2471.
[15] Xiao’an BAO,Shuyou PENG,Na ZHANG,Xiaomei TU,Qingqi ZHANG,Biao WU. Object detection algorithm based on multi-azimuth perception deep fusion detection head[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(1): 32-42.