A Chinese named entity recognition method based on hierarchical label enhanced contrastive learning
Through the hierarchical label enhanced contrastive learning method, the problems of dictionary dependence and low efficiency in traditional Chinese named entity recognition are solved, and efficient and accurate Chinese named entity recognition is achieved, which is suitable for large-scale text processing.
Patent Information
- Application Number
- CN202411335890.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2044-09-24
AI Technical Summary
Traditional Chinese named entity recognition methods rely on dictionaries, resulting in high cost and low efficiency, and insufficient context understanding, making it difficult to accurately identify entity boundaries in the case of polysemous words and homophones.
A contrastive learning method based on hierarchical label enhancement is adopted. Characters and labels are encoded through a pre-trained language model, and deep fusion is performed using a cross-modal Transformer network. Combined with sentence-level and word-level contrastive learning, a loss function is constructed to improve the model's semantic understanding and recognition accuracy.
The model improves the recognition accuracy and inference speed of Chinese entity boundaries, enhances the classification accuracy and robustness on diverse corpora, and is suitable for large-scale text processing.
Smart Images

Figure CN119272774B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an improved method for Chinese named entity recognition (NER) technology in the field of natural language processing. Specifically, the present invention proposes a hierarchical label enhancement method based on contrastive learning.
[0002] Contrastive Learning (HLCL) is used to improve the accuracy and inference speed of named entity recognition in Chinese text. Background Art
[0003] Named Entity Recognition (NER) task is a sequence labeling problem. Given a text sequence ,in Indicates the The task is to identify named entities in the text and assign corresponding labels to each entity, that is, to predict the corresponding label sequence. Chinese named entity recognition (NER) is a key task in natural language processing (NLP). It aims to automatically identify entities such as names of people, places, and organizations from unstructured text. Unlike Western languages, Chinese text does not have clear word boundaries, which poses significant challenges to the Chinese NER task.
[0004] Traditional Chinese named entity recognition methods usually rely on dictionaries or word segmentation tools to define word boundaries, but these methods have the following problems: (1) Strong dictionary dependence. Dictionary-based NER methods need to rely on high-quality dictionaries for word matching. However, the construction and maintenance costs of dictionaries are high. When encountering new words, proper nouns, or rare words, the risk of matching failure increases, resulting in model recognition errors. (2) Low reasoning efficiency. The calculation process of using dictionaries for word matching and word segmentation is complex and time-consuming. Especially in large-scale corpora, the processing speed is significantly reduced, making it difficult to meet the real-time and efficiency requirements of practical applications. (3) Insufficient context dependence. Traditional word segmentation and NER methods find it difficult to fully capture the contextual information in the sentence, which leads to ambiguity when dealing with polysemous words or homophones, further affecting the accuracy of recognition.
[0005] With the development of deep learning technology, especially the introduction of the Character-Word Lattice Structure, some progress has been made in the Chinese NER task. By integrating lexical information from a dictionary into character sequences, this structure can, to some extent, address the issue of unclear word boundaries in Chinese. However, this structure still relies on a dictionary, has a complex construction process, slow inference speed, and limited generalization capabilities. Summary of the Invention
[0006] In order to solve the problems of dictionary dependence, low reasoning efficiency and insufficient context understanding in Chinese named entity recognition (NER), the present invention provides a Chinese named entity recognition method based on hierarchical label enhanced contrastive learning, which is expected to achieve accurate recognition of Chinese entity boundaries and types without relying on lattice structure, thereby improving model recognition performance while increasing entity recognition reasoning speed.
[0007] In order to achieve the above technical objectives, the present invention adopts the following technical solutions:
[0008] The Chinese named entity recognition method based on hierarchical label enhanced contrastive learning of the present invention is characterized in that it is performed according to the following steps:
[0009] Step 1: Obtain a Chinese named entity recognition dataset, and a plurality of samples in the Chinese named entity recognition dataset, wherein each sample comprises a sentence text and a corresponding entity category label in an encoded form, wherein the sentence text consists of a plurality of Chinese words, and the entity category label in the encoded form is represented by different English abbreviations;
[0010] Performing natural language processing on all entity category encoding labels in the Chinese named entity recognition dataset to obtain entity category labels in natural language form consisting of several Chinese words;
[0011] Step 2: Use the pre-trained language model PLM to encode the labels and characters in the named entity recognition task, and obtain the corresponding character representation matrix and label representation matrix ;
[0012] Step 3: Transform the character representation matrix through the cross-modal Transformer network With label representation matrix Perform deep fusion to obtain the label-enhanced character representation matrix Y:
[0013] Step 4: Construct similarity loss by maximizing the similarity between matching sentences and labels and minimizing the similarity between mismatching sentences and labels through sentence-level contrastive learning. ;
[0014] Step 5: Minimize the difference between character representation and label enhanced representation through word-level contrastive learning, and then use formula (7) to construct the loss function of word-level contrastive learning :
[0015] (7)
[0016] In formula (7), represents the cosine similarity function, is the second temperature parameter, for The i-th word in The character representation of is the enhanced character representation of the i-th label in Y, Enhanced character representation for the cth label in Y;
[0017] Step 6: Encode and decode and Process and obtain The predicted label sequence and The predicted label sequence , thereby constructing the character conditional likelihood loss function and label-enhanced character conditional likelihood loss function ;
[0018] Step 7: Use formula (11) to construct the total loss function , thereby using the Adamx optimizer to train the entire network from step 2 to step 6 and calculate the total loss function To update the network parameters, stop training when the number of training reaches the set threshold, and thus obtain a Chinese named entity recognition model for entity recognition of unlabeled Chinese sentences;
[0019] (11).
[0020] The Chinese named entity recognition method based on hierarchical label enhanced contrastive learning described in the present invention is also characterized in that step 2 is performed as follows:
[0021] Step 2.1: Use the pre-trained language model PLM to input the sentence text in any sample Encode and generate character representation matrix ,in, express The i-th word in express Character representation, d is a fixed dimension; n represents the sentence text The number of words;
[0022] Step 2.2: Use PLM to encode the entity category labels in the natural language form of any sample and generate The corresponding label represents the sequence , thus obtaining the sentence text The corresponding label representation matrix ,in, express The embedding vector of the kth word in ; K represents the total number of words in the entity category label of each natural language form.
[0023] Furthermore, step 3 is performed as follows:
[0024] Step 3.1: Use formula (1) to get the weight of the zth parallel attention head , thus obtaining the weights of M parallel attention heads { , ,… ,…, };
[0025] (1)
[0026] In formula (1), Represent the query projection matrix to be trained, the key projection matrix to be trained, and the value projection matrix to be trained, respectively. represents the activation function, T represents the transposition, is the scaling factor;
[0027] Step 3.2, replace { , ,… ,…, }After splicing, the weight matrix of the linear transformation Multiply to get the label character fusion feature ;
[0028] Step 3.3: Generate enhanced label character fusion features using formula (2) :
[0029] (2)
[0030] In formula (2), Representation layer normalization operation, represents the feedforward network, the second represents residual connection;
[0031] Step 3.4: Generate the label-enhanced character representation matrix Y using formula (3) :
[0032] (3)
[0033] In formula (3), Linear represents the fully connected layer, Represents a splicing operation.
[0034] Furthermore, step 4 is performed as follows:
[0035] Step 4.1: Use equations (4) and (5) to obtain the character representation matrix with enhanced features. and the feature-enhanced label representation matrix :
[0036] (4)
[0037] (5)
[0038] In formula (4) and formula (5), and Are two parameter matrices to be trained; is the activation function;
[0039] Step 4.2: Use formula (6) to construct the loss function of sentence-level contrastive learning :
[0040] (6)
[0041] In formula (6), represents the cosine similarity function, For the pooling operation, is the first temperature parameter, Represents the character representation matrix of the feature enhancement of the sentence text in the qth sample, Represents the label representation matrix of the feature enhancement of the sentence text in the qth sample, The label representation matrix represents the feature enhancement of the sentence text in the jth sample, and B represents the number of samples in a batch.
[0042] Furthermore, step 6 is performed as follows:
[0043] Step 6.1: and Input them into BiLSTM network for processing respectively, and generate character hidden layer representation matrix respectively Character hidden layer representation matrix enhanced with labels ;
[0044] Step 6.2: Input into the CRF network for processing and output The predicted label sequence ,in, represents the predicted label of the i-th word;
[0045] Step 6.3: Use Equation (8) to construct the character conditional likelihood loss function :
[0046] (8)
[0047] In formula (8), represents the probability of a given label sequence, and has:
[0048] (9)
[0049] In formula (9), for The i-th row element of express The predicted label of the i-1th word in ; G represents the value set of the predicted label sequence of the sentence text C on all label categories; Indicates that G is any predicted label sequence value; express The predicted label of the i-1th word in ; express The predicted label of the i-th word in ; It is from arrive transfer score; It is from arrive of transfer score and has:
[0050] (10)
[0051] (11)
[0052] In formula (10) and formula (11), are the prediction weights and prediction biases to be trained, 、 Represents the weight of the value set to be trained and the bias term of the value set, and exp represents the exponential function;
[0053] Step 6.4: Follow the process of steps 5.2 and 5.3 to Processing is performed to construct the character conditional likelihood loss function for label enhancement. ,in, Representatives will The predicted label sequence output after inputting the CRF network.
[0054] The electronic device of the present invention includes a memory and a processor, and is characterized in that the memory is used to store a program that supports the processor to execute the Chinese named entity recognition method, and the processor is configured to execute the program stored in the memory.
[0055] The present invention provides a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and the computer program executes the steps of the Chinese named entity recognition method when the computer program is executed by a processor.
[0056] Compared with the prior art, the present invention has the following beneficial effects:
[0057] 1. This paper enhances the model's ability to capture the unique semantic features of each entity category by introducing sentence-level contrastive learning that aligns with label semantics during model training. This step effectively combats the confusion that traditional NER models experience when faced with semantically similar entities but different categories, improving the model's classification accuracy and robustness on diverse corpora.
[0058] 2. By combining a pre-trained language model with hierarchical label information, this invention enables each label to function not only independently of a single character or word, but also integrates information at a broader semantic level, effectively improving the model's ability to understand context. This technical feature addresses the information loss that can result from single-label representation in existing techniques, significantly enhancing the accuracy of named entity boundary recognition.
[0059] 3. Unlike traditional NER methods, this invention achieves efficient named entity recognition without a dictionary through comparative learning, significantly reducing the dependence on and construction cost of dictionaries. As a result, the model inference speed is significantly improved, making it suitable for practical application scenarios of large-scale text processing.
[0060] 4. This paper introduces a contrastive learning framework, combined with label augmentation techniques, to effectively improve the model's adaptability in diverse contexts. Through contrastive learning at the sentence and word level, the model can better understand the differences and similarities between various labels, overcoming the generalization issues of existing models and achieving excellent performance across multiple datasets. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 This is an example diagram of the present invention using PRM coding;
[0062] Figure 2 This is a diagram of the CrossTransformer network structure used in the present invention;
[0063] Figure 3 It is a schematic diagram of the overall framework of the present invention;
[0064] Figure 4 This is a performance experiment comparison chart of the present invention and the existing method;
[0065] Figure 5 This is a comparison chart of the reasoning speed experiments of the present invention and the existing methods. DETAILED DESCRIPTION
[0066] In this embodiment, a hierarchical label-enhanced contrastive learning method suitable for Chinese named entity recognition is to first encode the input characters and natural language labels through a pre-trained language model to generate high-dimensional representations of characters and labels. And use Cross-Transformer to further combine the representations of characters and labels to generate label-enhanced character representations. Then, sentence-level contrastive learning is used to maximize the global mutual information between sentence and label representations, thereby enhancing the model's understanding of global semantics. At the same time, the gap between character representation and label-enhanced character representation is narrowed through character-level contrastive learning to enhance the model's capture of local semantic information. Finally, the sequence is modeled and decoded through the BiLSTMCRF model to ensure that the model can accurately identify the boundaries and type information of the entity, thereby improving the efficiency and accuracy of Chinese named entity recognition. Specifically, the method includes:
[0067] Step 1: Get a Chinese named entity recognition dataset, and several samples in the Chinese named entity recognition dataset, where each sample contains a sentence text (sentence) and the corresponding encoded entity category label (label), where the sentence text consists of several Chinese words, and the encoded entity category label is represented by different English abbreviations, such as Figure 3 O, B-PER, M-PER, and E-PER shown in the lower left corner;
[0068] All entity category encoding labels in the Chinese named entity recognition dataset are processed into natural language to obtain entity category labels in natural language form consisting of several Chinese words.
[0069] Step 2: Use the pre-trained language model PLM to encode the labels and characters in the named entity recognition task, and obtain the corresponding character representation matrix and label representation matrix ;
[0070] Step 2.1: The present invention uses the BERT model as the pre-trained language model PLM to input the sentence text in any sample Encode and generate character representation matrix ,in, express The i-th word in express Character representation, d is a fixed dimension; n represents the sentence text In this way, the model can convert discrete characters into continuous vector representations, which is convenient for subsequent model processing.
[0071] Step 2.2: Use PLM to encode the entity category labels in the natural language form of any sample and generate The corresponding label represents the sequence , thus obtaining the sentence text The corresponding label representation matrix ,in, express The embedding vector of the kth word in ; K represents the total number of words in the entity category label of each natural language form;
[0072] Specifically, Figure 1 The example shown in the figure uses the label "BPER.NOM", which indicates that the character belongs to the beginning of a person's name entity. The present invention converts it into a natural language representation: "person general reference start word", and sends it to the PLM for encoding to obtain its vector representation. ,The generated label representation and character representation will be used in the ,contrast learning module later.
[0073] Step 3: Transform the character representation matrix through the cross-modal Transformer network With label representation matrix Perform deep fusion to obtain the label-enhanced character representation matrix Y:
[0074] Step 3.1: Use formula (1) to get the weight of the zth parallel attention head (Multi-head Attention) , thus obtaining the weights of M parallel attention heads { , ,… ,…, };
[0075] (1)
[0076] In formula (1), Represent the query projection matrix to be trained, the key projection matrix to be trained, and the value projection matrix to be trained, respectively. represents the activation function, T represents the transposition, is the scaling factor;
[0077] Step 3.2, replace { , ,… ,…, }After splicing, the weight matrix of the linear transformation Multiply to get the label character fusion feature ;
[0078] Step 3.3: Generate enhanced label character fusion features using formula (2) :
[0079] (2)
[0080] In formula (2), Represents layer normalization operation (LayerNorm), Represents the feed-forward network (Feed-ForwardNetwork), the second represents residual connection;
[0081] Step 3.4: Generate the label-enhanced character representation matrix Y using formula (3) :
[0082] (3)
[0083] In formula (3), Linear represents the fully connected layer, Represents a splicing operation;
[0084] Figure 2 The visual structure of CrossTransformer is shown.
[0085] Step 4: Construct similarity loss by maximizing the similarity between matching sentences and labels and minimizing the similarity between mismatching sentences and labels through sentence-level contrastive learning. (Sentence-level ContrastiveLeaming):
[0086] Using formula (4) and formula (5) respectively, we can get the character representation matrix of feature enhancement: and the feature-enhanced label representation matrix :
[0087] (4)
[0088] (5)
[0089] In formula (4) and formula (5), and Are two parameter matrices to be trained; is the activation function.
[0090] Step 4.2: Use formula (6) to construct the loss function of sentence-level contrastive learning :
[0091] (6)
[0092] In formula (6), represents the cosine similarity function, For the pooling operation, is the first temperature parameter, Represents the character representation matrix of the feature enhancement of the sentence text in the qth sample, Represents the label representation matrix of the feature enhancement of the sentence text in the qth sample, The label representation matrix represents the feature enhancement of the sentence text in the jth sample, and B represents the number of samples in a batch.
[0093] Step 5: Minimize the difference between the character representation and the label enhanced representation through token-level contrastive learning, and then use formula (7) to construct the loss function of token-level contrastive learning :
[0094] (7)
[0095] In formula (7), is the second temperature parameter, for The i-th word in The character representation of is the enhanced character representation of the i-th label in Y, is the enhanced character representation of the cth label in Y, n is a matrix The characters contained in represent the total number.
[0096] Figure 3 The workflow of sentence-level contrastive learning and character-level contrastive learning is shown in detail in
[15] . First, the characters in the sentence are generated by the PLM encoder. , while the labels are generated by the same PLM encoder In sentence-level contrastive learning, positive pairs (i.e., the character representation matrix of the same sample and the corresponding label representation matrix) are optimized by maximizing similarity, while negative pairs (i.e., the character representation and label representation of different samples) are trained by minimizing similarity. In character-level contrastive learning, CrossTransformer generates , these representations are then used to compute the token-level contrastive learning loss In word-level contrastive learning, the positive sample is any character representation and the corresponding label representation in the same sample, and the negative sample is any character representation and the non-corresponding label representation in the same sample.
[0097] Step 6: Obtain the final entity category probability through encoding and decoding
[0098] Step 6.1: and Input them into BiLSTM network for processing respectively, and generate character hidden layer representation matrix respectively Character hidden layer representation matrix enhanced with labels ;
[0099] Step 6.2: Input into the CRF network for processing and output The predicted label sequence ,in, represents the predicted label of the i-th word;
[0100] Step 6.3: Use Equation (8) to construct the character conditional likelihood loss function :
[0101] (8)
[0102] In formula (8), represents the probability of a given label sequence, and has:
[0103] (9)
[0104] In formula (9), for The i-th row element of express The predicted label for the i-1th word in ; in particular, specify is the sentence start label, G represents the value set of the predicted label sequence of the sentence text C on all label categories, covering all label assignments on the given input sequence; Represents any predicted label sequence value in G; express The predicted label of the i-1th word in ; express The predicted label of the i-th word in ; It is from arrive transfer score; It is from arrive of transfer score and has:
[0105] (10)
[0106] (11)
[0107] In formula (10) and formula (11), are the prediction weights and prediction biases to be trained, 、 Represents the weights and biases of the value set to be trained, and exp represents the exponential function;
[0108] Step 6.4: Follow the process of steps 5.2 and 5.3 to Processing is performed to construct the character conditional likelihood loss function for label enhancement. ,in Representatives will Input the output prediction label sequence of the CRF network;
[0109] Step 7: Construct loss function and train the model;
[0110] Use formula (11) to construct the total loss function , thereby using the Adamx optimizer to train the entire network from step 2 to step 6 and calculate the total loss function The network parameters are updated and the training is stopped when the number of training times reaches the set threshold, thereby obtaining a Chinese named entity recognition model for entity recognition of unlabeled Chinese sentences.
[0111] (11).
[0112] In this embodiment, an electronic device includes a memory and a processor, wherein the memory is used to store a program that supports the processor to execute the above method, and the processor is configured to execute the program stored in the memory.
[0113] In this embodiment, a computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are executed.
[0114] In summary, the method of the present invention integrates label semantics into character representation through hierarchical contrastive learning, avoiding the complexity and inefficiency of word lattice structure-based methods, thereby improving reasoning speed and recognition accuracy.
[0115] Figure 4In this paper, we compare the proposed model HLCL with almost all lexicon-enhanced models and classic dictionary-free methods. The results show that HLCL performs well on all four datasets (OntoNotes, MSRA, Resume, Weibo), achieving F1 scores of 82.96, 95.86, 96.69, and 71.12, respectively. It achieves the best results on two datasets and the second best result on one dataset. Compared with the best results of lexicon-enhanced models such as Lattice LSTM, LRCNN, LGN, CGN, FLAT, LEBERT, LAN, and SoftLexicon (LSTM), HLCL improves the F1 scores by 0.15% and 0.61% on the OntoNotes and Resume datasets, respectively. Furthermore, compared to the classic no-dictionary approach BERT + LSTM + CRF, HLCL demonstrates stronger performance improvements on the OntoNotes, MSRA, Resume, and Weibo datasets, improving F1 scores by 1.14%, 1.03%, 0.43%, and 3.79%, respectively. HLCL's improvement on the Weibo dataset is particularly significant. This is because the Weibo dataset contains a large number of spoken characters and special symbols, which pose challenges to the BERT + LSTM + CRF model. HLCL effectively overcomes these difficulties, demonstrating its strength in processing complex text.
[0116] Figure 5The inference efficiency of different models was evaluated in
[15] . This paper compared the inference time (Inference-Time) of test sets of different datasets on i9 12900k CPU and RTX 3090 GPU, with the batch size set to 16. We used two dictionaries: "YJ" represents the dictionary used in reference [Y. Zhang and J. Yang, "Chinese ner using lattice lstm," arXiv preprint arXiv:1805.02023, 2018.], which contains 704.4K entries; and "Ten" represents the dictionary used in reference [Y. Song, S. Shi, J. Li, and H. Zhang, "Directional skipgram: Explicitly distinguishing left and right context for word embeddings," in Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2 (Short Papers), 2018, pp. 175–180.], which contains 8824.3K entries. SoftLexicon also uses the BiLSTM CRF model for NER learning, so we used it as the baseline model for comparison. Experimental results show that HLCL and SoftLexicon achieve similar inference time performance on the Resume and Weibo datasets. However, as the test set size increases, SoftLexicon's inference time increases significantly, while HLCL's inference time remains low. Furthermore, when using the larger dictionary "Ten," SoftLexicon's inference time rises significantly, highlighting the complexity and time-consuming nature of dictionary matching when processing large-scale dictionaries. In contrast, HLCL, because it does not rely on complex dictionary structures, effectively reduces inference time and demonstrates greater efficiency when processing large-scale data.
Claims
1. A Chinese named entity recognition method based on hierarchical label enhanced contrastive learning, characterized in that: The steps are as follows: Step 1: Obtain a Chinese named entity recognition dataset, and a plurality of samples in the Chinese named entity recognition dataset, wherein each sample comprises a sentence text and a corresponding entity category label in an encoded form, wherein the sentence text consists of a plurality of Chinese words, and the entity category label in the encoded form is represented by different English abbreviations; Performing natural language processing on all entity category encoding labels in the Chinese named entity recognition dataset to obtain entity category labels in natural language form consisting of several Chinese words; Step 2: Use the pre-trained language model PLM to encode the labels and characters in the named entity recognition task, and obtain the corresponding character representation matrix and label representation matrix ; Step 3: Transform the character representation matrix through the cross-modal Transformer network With label representation matrix Perform deep fusion to obtain the label-enhanced character representation matrix Y: Step 4: Construct similarity loss by maximizing the similarity between matching sentences and labels and minimizing the similarity between mismatching sentences and labels through sentence-level contrastive learning. ; Step 5: Minimize the difference between character representation and label enhanced representation through word-level contrastive learning, and then use formula (7) to construct the loss function of word-level contrastive learning : (7) In formula (7), represents the cosine similarity function, is the second temperature parameter, for The i-th word in The character representation of is the enhanced character representation of the i-th label in Y, Enhanced character representation for the cth label in Y; Step 6: Encode and decode and Process and obtain The predicted label sequence and The predicted label sequence , thereby constructing the character conditional likelihood loss function and label-enhanced character conditional likelihood loss function ; Step 7: Use formula (11) to construct the total loss function , thereby using the Adamx optimizer to train the entire network from step 2 to step 6 and calculate the total loss function To update the network parameters, stop training when the number of training reaches the set threshold, and thus obtain a Chinese named entity recognition model for entity recognition of unlabeled Chinese sentences; (11)。 2. The Chinese named entity recognition method based on hierarchical label enhanced contrastive learning according to claim 1 is characterized in that: Described step 2 is carried out as follows: Step 2.1: Use the pre-trained language model PLM to input the sentence text in any sample Encode and generate character representation matrix ,in, express The i-th word in express Character representation, d is a fixed dimension; n represents the sentence text The number of words; Step 2.2: Use PLM to encode the entity category labels in the natural language form of any sample and generate The corresponding label represents the sequence , thus obtaining the sentence text The corresponding label representation matrix ,in, express The embedding vector of the kth word in ; K represents the total number of words in the entity category label of each natural language form.
3. The Chinese named entity recognition method based on hierarchical label enhanced contrastive learning according to claim 2 is characterized in that: Described step 3 is carried out as follows: Step 3.1: Use formula (1) to get the weight of the zth parallel attention head , thus obtaining the weights of M parallel attention heads { , ,… ,…, }; (1) In formula (1), Represent the query projection matrix to be trained, the key projection matrix to be trained, and the value projection matrix to be trained, respectively. represents the activation function, T represents the transposition, is the scaling factor; Step 3.2, replace { , ,… ,…, }After splicing, the weight matrix of the linear transformation Multiply to get the label character fusion feature ; Step 3.3: Generate enhanced label character fusion features using formula (2) : (2) In formula (2), Representation layer normalization operation, represents the feedforward network, the second represents residual connection; Step 3.4: Generate the label-enhanced character representation matrix Y using formula (3) : (3) In formula (3), Linear represents the fully connected layer, Represents a splicing operation.
4. The Chinese named entity recognition method based on hierarchical label enhanced contrastive learning according to claim 3 is characterized in that: Described step 4 is carried out as follows: Step 4.1: Use equations (4) and (5) to obtain the character representation matrix with enhanced features. and the feature-enhanced label representation matrix : (4) (5) In formula (4) and formula (5), and Are two parameter matrices to be trained; is the activation function; Step 4.2: Use formula (6) to construct the loss function of sentence-level contrastive learning : (6) In formula (6), represents the cosine similarity function, For the pooling operation, is the first temperature parameter, Represents the character representation matrix of the feature enhancement of the sentence text in the qth sample, Represents the label representation matrix of the feature enhancement of the sentence text in the qth sample, The label representation matrix represents the feature enhancement of the sentence text in the jth sample, and B represents the number of samples in a batch.
5. The Chinese named entity recognition method based on hierarchical label enhanced contrastive learning according to claim 4 is characterized in that: Described step 6 is carried out as follows: Step 6.1: and Input them into BiLSTM network for processing respectively, and generate character hidden layer representation matrix respectively Character hidden layer representation matrix enhanced with labels ; Step 6.2: Input into the CRF network for processing and output The predicted label sequence ,in, represents the predicted label of the i-th word; Step 6.3: Use Equation (8) to construct the character conditional likelihood loss function : (8) In formula (8), represents the probability of a given label sequence, and has: (9) In formula (9), for The i-th row element of express The predicted label of the i-1th word in ; G represents the value set of the predicted label sequence of the sentence text C on all label categories; Indicates that G is any predicted label sequence value; express The predicted label of the i-1th word in ; express The predicted label of the i-th word in ; It is from arrive transfer score; It is from arrive of transfer score and has: (10) (11) In formula (10) and formula (11), are the prediction weights and prediction biases to be trained, 、 Represents the weight of the value set to be trained and the bias term of the value set, and exp represents the exponential function; Step 6.4: Follow the process of steps 5.2 and 5.3 to Processing is performed to construct the character conditional likelihood loss function for label enhancement. ,in, Representatives will The predicted label sequence output after inputting the CRF network.
6. An electronic device comprising a memory and a processor, characterized in that: The memory is used to store a program that supports the processor to execute the Chinese named entity recognition method according to any one of claims 1 to 5, and the processor is configured to execute the program stored in the memory.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the Chinese named entity recognition method according to any one of claims 1 to 5 are executed.