摘 要:目前中文命名實體識別模型在識別具有嵌套結構的實體時存在誤差,無法準確識別。基于跨度的方法能夠找出嵌套實體,但在識別過程中經常生成不包含實體的跨度,無法明確劃分跨度邊界,增加模型負擔。針對此問題,提出了基于詞匯融合與跨度邊界檢測的中文嵌套命名實體識別模型。該模型使用多詞融合方法達到文本特征增強的目的,在設計的注入模塊中將目標語句中字符相關的多個詞匯信息進行合并,之后融入到BERT中,以此獲得更全面的上下文信息,提供更好的跨度表示;其次添加跨度邊界檢測模塊,通過感知分類器預測跨度的首尾字符來劃分跨度邊界。在公共數據集上的實驗表明,該模型可有效提升識別準確率。
關鍵詞:中文嵌套命名實體識別; BERT模型; 多詞融合; 跨度邊界檢測
中圖分類號:TP391 文獻標志碼:A
文章編號:1001-3695(2023)08-021-2382-05
doi:10.19734/j.issn.1001-3695.2022.11.0767
Chinese nested named entity recognition based onvocabulary fusion and span detection
Chen Shuzhen Dou Quansheng Tang Huanling Jiang Ping
(1.School of Computer Science amp; Technology, Shandong Technology amp; Business University, Yantai Shandong 264000, China; 2.Shandong Future Intelligent Computing Collaborative Innovation Center, Yantai Shandong 264000, China; 3.Key Laboratory of Intelligent Information Processing in Universities of Shandong, Yantai Shandong 264000, China)
Abstract:At present, Chinese named entity recognition model has errors in recognizing entities with nested structures, so it can not be recognized accurately. The method based on span can find nested entities, but when detecting text, it often gene-rates span without entities, and can not clearly define the span boundary, which increases the model burden. To solve this problem, this paper proposed a Chinese nested named entity recognition model based on vocabulary fusion and span boundary detection. The model used multi-word fusion method to enhance text features, and it merged multiple lexical information rela-ted to the characters in the target sentence in the designed injection module. Ant then it integrated into BERT to obtain more comprehensive context information, and provided better span representation. Secondly, it added a span boundary detection method to divide the span boundary by predicting the first and last characters of the span by perceptual classifier. Experiments on public data sets show that the model can effectively improve the recognition accuracy.
Key words:Chinese nested named entity recognition; BERT model; multi-word fusion; span boundary detection
0 引言
命名實體識別(named entity recognition,NER)是自然語言處理(natural language processing,NLP)的核心任務之一[1],其目的是識別并標注出文本中的特殊含義實體,包括人名、地名、機構組織名等實體[2],識別效果對文本分類[3]、機器翻譯[4]、情感分析[5]和構建知識圖譜[6]等后續工作起著關鍵性作用。
當前nested NER模型大致分為兩種,第一種是基于轉換的模型(transformation-based models):通過映射或分層的方法將嵌套結構轉換成平面結構再使用序列標記模型進行實體類型預測。Ju等人[7]提出了多層LSTM-CRF(long short term memory-"conditional random fields)模型,從嵌套結構中動態迭代地提取出內部實體;Luo等人[8]使用BiLSTM(bidirectional long short-term memory)和圖卷積網絡共同學習最外層實體與內部約束關系,提出了一種二分平面圖網絡模型來識別嵌套實體;周俊生等人[9]提出層疊條件隨機場模型,利用低層條件隨機場對實體進行識別并為高層條件隨機場提供決策信息。另一種是基于跨度的模型(span-based models),即通過將語句中的跨度(子序列)進行分類來識別出嵌套實體。Xu等人[10]利用局部檢測法對每個可能的子序列進行分類;Sohrab等人[11]提出了一種神經管道方法,該模型通過基于上下文跨度表示的枚舉法來獲取BiLSTM輸出的語義信息,在識別化學領域的嵌套實體時取得了不錯的成績;Yu等人[12]利用BERT(bidirectional encoder representations from transformers)獲取目標跨度的上下文信息來改進嵌套語言的跨度表示;Liu等人[13]微調BERT后對文本信息進行編碼得到跨度表示,結合多任務學習方法將nested NER任務分為實體識別任務和實體分類任務。
基于轉換的模型需要復雜的變換與解碼操作,識別過程中可能會導致錯誤并且計算成本高;基于跨度的模型缺乏對跨度邊界的明確劃分,導致產生一些不必要的跨度,如不包含實體的跨度和不是實體的跨度為不必要跨度,但其不受嵌套層數量和不同嵌套實體類別的限制且可以較容易地找出不同跨度中的實體。因此本文選擇了基于跨度的方法,為解決跨度邊界劃分問題,提出了一種基于多詞融合和跨度邊界檢測(span boundary detection model with multiword fusion,SwM)的中文嵌套命名實體識別模型。其主要貢獻如下:
a)提出了一種多詞融合方法并設計了注入模塊Syringe。其功能是匹配與目標語句中字符最相關的詞組并將其融合后注入到BERT中,獲取更全面的上下文信息。
b)提出了一種基于字符的跨度邊界檢測方法,用來預測跨度的首字符和尾字符,找出句中所有可能的跨度,減少不必要跨度的產生,提高模型性能。
綜上所述,本文提出了SwM模型,后續在《人民日報》、Weibo、Resume和MSRA數據集上的實驗結果證明了此模型的有效性。
1 問題描述
本文采用了基于跨度的方法,但此方法對準確劃分跨度邊界要求較高,如何解決此問題成為本文的重點。以下就跨度劃分給出形式化說明。
2 SwM模型
2.1 注入模塊
本文將注入模塊命名為Syringe,譯為注射器,其結構如圖3所示。Syringe的工作分為兩個步驟:a)準備工作,為目標語句中每個字符匹配所有可能的詞匯并組成詞組,再將字符與詞組作為模型的輸入;b)字詞融合,將每個詞組中的詞匯按照其相應權重進行融合得到融合詞向量,再與相應字符進行融合獲得最終字詞融合向量并注入到BERT中,進行編碼。
2.1.1 字詞匹配
2.1.2 字詞融合
2.2 SYBERT
2.3 跨度邊界檢測層
2.4 跨度分類層
3 實驗與分析
由于中文嵌套實體數據集較少,且進行對比實驗的模型也較少,為了更全面地對本文所提模型進行評估,本章不僅在中文嵌套實體數據集上與其他CNNER模型進行了對比實驗,也在中文命名實體數據集上與其他用于中文命名實體識別的模型進行了對比實驗,來驗證本文所提模型的有效性。
3.1 數據集
3.2 實驗設置
3.3 實驗
3.3.1 消融實驗
3.3.2 對比實驗
3.3.3 中文命名實體識別對比實驗
3.4 實例分析
本文以“一名新生在北京大學翻閱新生入學手冊”為例進行實例分析,將該語句送入模型,得到結果如圖7所示。
模型不僅識別出[北京大學]這個組織,同時識別出地點實體[北京],可認為模型有能力將所有[XX大學]都識別出來,此時的模型學習到的是一種模式,并非一種具體情況,模型提取出來的額外信息可作為輔助特征,增強其他任務效果,如智能語音、問答系統等。
4 結束語
本文提出了一種基于多詞融合和跨度邊界檢測的CNNER模型SwM。通過模型中的注入模塊Syringe將字符相關多個詞匯按照權重進行融合得到詞向量,與通過BERT嵌入層的字符向量進行再次融合得到字詞融合向量,并與BERT中多層編碼器充分交互,獲取更好的跨度表示。在跨度邊界檢測方面,提出了基于字符的跨度邊界檢測方法,使用MLP分類器來預測跨度首字符和尾字符,在一定程度上減少了模型計算負擔。在《人民日報》數據集上,與現存的四種模型相比,取得了最佳的結果。目前SwM模型存在結構復雜、訓練周期較長等問題,在未來的工作中,本文將進一步研究使用輕量型模型架構對CNNER任務的影響,探索輕量型模型的可能。
參考文獻:
[1]McCallum A, Li Wei. Early results for named entity recognition with conditional random fields, feature induction and Web-Enhanced lexicons[J]. Association for Computational Linguistics, 2003,4:188-191.
[2]Sang E F, De Meulder F. Introduction to the CoNLL-2003 shared task:language-independent named entity recognition[EB/OL]. (2003-06-12). https://arXiv.org/abs/cs/0306050.
[3]Tao Hanqing, Tong Shiwei, Zhao Hongke, et al. A radical-aware attention-based model for Chinese text classification[C]//Proc of the AAAI Conference on Artificial Intelligence. 2019:5125-5132.
[4]Zhang Jiajun,Zong Chengqing. Neural machine translation:challenges, progress and future[J]. Science China Technological Sciences, 2020,63: 2028-2050.
[5]Li Hao, Fan Jiancong. Chinese text emotional analysis based on Bi-LSTM model fusing emotional features[M]//Advances in Intelligent Data Analysis and Applications. Singapore:Springer, 2022: 225-241.
[6]Yan Hehua, Yang Jun, Wan Jiafu. KnowIME: a system to construct a knowledge graph for intelligent manufacturing equipment[J]. IEEE Access, 2020,8: 41805-41813.
[7]Ju Meizhi,Miwa M,Ananiadou S. A neural layered model for nested named entity recognition[C]//Proc of the Conference of the North Ame-rican Chapter of the Association for Computational Linguistics: Human Language Technologies. 2018:1446-1459.
[8]Luo Ying, Zhao Hai. Bipartite flat-graph network for nested named entity recognition[EB/OL]. (2020-05-01). https://arXiv.org/abs/2005.00436.
[9]周俊生, 戴新宇, 尹存燕, 等. 基于層疊條件隨機場模型的中文機構名自動識別[J]. 電子學報, 2006,34(5):804-809. (Zhou Junsheng, Dai Xinyu, Yin Cunyan, et al. Automatic recognition of Chinese organization name based on cascaded conditional random fields[J]. Acta Electronica Sinica, 2006,34(5): 804-809.)
[10]Xu Mingbin, Jiang Hui, Watcharawittayakul S. A local detection approach for named entity recognition and mention detection[C]//Proc of the 55th Annual Meeting of the Association for Computational Linguistics. 2017: 1237-1247.
[11]Sohrab M G, Pham M T, Miwa M, et al. A neural pipeline approach for the pharmaconer shared task using contextual exhaustive models[C]//Proc of the 5th Workshop on BioNLP Open Shared Tasks. 2019: 47-55.
[12]Yu Juntao, Bohnet B, Poesio M. Named entity recognition as dependency parsing[EB/OL]. (2020-06-13). https://arXiv.org/abs/2005. 07150.
[13]Liu Chenxu, Fan Hongjie, Liu Junfei. Span-based nested named entity recognition with pretrained language model[C]//Proc of International Conference on Database Systems for Advanced Applications. Berlin:Springer, 2021: 620-628.
[14]Li Fei, Wang Zheng, Hui S, et al. A segment enhanced span-based model for nested named entity recognition[J]. Neuro Computing, 2021,465: 26-37.
[15]Regéciová D, Kolárˇ D, Milkovicˇ M. Pattern matching in YARA: improved Aho-Corasick algorithm[J]. IEEE Access, 2021,9: 62857-62866.
[16]李雁群, 何云琪, 錢龍華, 等. 中文嵌套命名實體識別語 料庫的構建[J]. 中文信息學報, 2018, 32(8): 19-26. (Li Yanqun, He Yunqi, Qian Longhua, et al. Chinese nested named entity recognition corpus construction[J]. Journal of Chinese Information Proces-sing, 2018,32(8):19-26.)
[17]Devlin J, Chang M W, Lee K, et al. BERT: pre-training of deep bidirectional transformers for language understanding[EB/OL]. (2019-05-24). https://arxiv.org/abs/1810.04805.
[18]尹迪, 周俊生, 曲維光. 基于聯合模型的中文嵌套命名實體識別[J]. 南京師大學報: 自然科學版, 2014,37(3): 29-35. (Yin Di, Zhou Junsheng, Qu Weiguang. Chinese nested named entity re-cognition using a joint model[J]. Journal of Nanjing Normal University:Natural Science Edition, 2014,37(3): 29-35.)
[19]金彥亮, 謝晉飛, 吳迪嘉. 基于分層標注的中文嵌套命名實體識別[J]. 上海大學學報: 自然科學版, 2022,28(2): 270-280. (Jin Yanliang, Xie Jinfei, Wu Dijia. Chinese nested named entity recognition based on hierarchical tagging[J]. Journal of Shanghai University: Natural Science Edition, 2022,28(2): 270-280.)
[20]李寶昌,郭衛斌. 詞典信息分層調整的中文命名實體識別方法[J/OL]. 華東理工大學學報:自然科學版. (2022-01-27)[2022-04-07]. https://kns.cnki.net/kcms/detail/31.1691. TQ.20220125.0906.001.html. (Li Baochang,Guo Weibin. Research on Chinese named entity recognition based on hierarchical adjustment of lexicon information[J/OL]. Journal of East China University of Science and Technology: Natural Science Edition. (2022-01-27)[2022-04-07]. https://kns.cnki.net/kcms/detail/31.1691. TQ.20220125.0906.001.html.)
[21]Ma Ruotian, Peng Minlong, Zhang Qi, et al. Simplify the usage of lexicon in Chinese NER[C]//Proc of the 58th Annual Meeting of the Association for Computational Linguistics. Stroudsburg, PA:Association for Computational Linguistics ,2020: 5951-5960.
[22]Li Xiaonan, Yan Hang, Qiu Xipeng, et al. FLAT: Chinese NER using flat-lattice transformer[EB/OL]. (2020-05-23). https://arxiv.org/abs/2004.11795.
[23]Gu Yingjie, Qu Xiaoye, Wang Zhefeng, et al. Delving deep into re-gularity: a simple but effective method for chinese named entity recognition[EB/OL]. (2022-04-18). https://arxiv.org/abs/2204.05544.