Chinese named entity recognition method based on hierarchical label enhancement contrast learning
By adopting a hierarchical tag enhanced contrast learning method in Chinese named entity recognition task, combining pre-trained language model and Transformer network, the problems of dictionary dependence and inference efficiency are solved, efficient Chinese named entity recognition is achieved, and recognition is improved Accuracy and speed.
Patent Information
- Application Number
- CN202411335890.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-09-24
AI Technical Summary
There are problems in the Chinese named entity recognition task such as strong dictionary dependence, low inference efficiency and insufficient contextual understanding, resulting in poor recognition accuracy and speed.
Using a contrast learning method based on hierarchical tag enhancement, characters and tags are encoded through pre-trained language models, combined with cross-modal Transformer network and sentence-level comparison learning, tag-enhanced character representation is constructed to achieve efficient naming entity recognition without dictionaries.
It improves the model's accurate identification ability of entity boundaries and types, improves the inference speed and classification accuracy, is suitable for large-scale text processing scenarios, and overcomes the problems of insufficient dictionary dependence and generalization ability of traditional methods.
Smart Images

Figure CN119272774A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an improved method in the 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] The named entity recognition (NER) task is a sequence labeling problem. Given a text sequence ,in Indicates 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 is a key task in natural language processing, which 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 a significant challenge 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, which is difficult to meet the requirements of real-time and efficiency in practical applications. (3) Insufficient context dependence. Traditional word segmentation and NER methods are difficult to fully capture the contextual information in the sentence, which leads to ambiguity when dealing with polysemous words or homonyms, further affecting the accuracy of recognition.
[0005] With the development of deep learning technology, especially the introduction of CharacterWord LatticeStructure, Chinese NER tasks have made some progress. The lattice structure can solve the problem of unclear boundaries of Chinese words to a certain extent by integrating vocabulary information in the dictionary into the character sequence. However, this structure still relies on the dictionary, and the construction process is complex, the reasoning speed is slow, and the generalization ability is limited. 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, so as to achieve accurate recognition of Chinese entity boundaries and types without relying on lattice structure, thereby improving the model recognition performance and the 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 is composed 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 a number of Chinese words;
[0011] Step 2: Use the pre-trained language model PLM to encode the labels and characters in the named entity recognition task respectively, 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 a similarity loss by maximizing the similarity between matching sentences and labels and minimizing the similarity between unmatched 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 p-th character of the p-th word in represents, is the enhanced character representation of the i-th label in Y, is the enhanced character representation of 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 times reaches the set threshold, thereby obtaining 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 the step 2 is performed according to the following steps:
[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 The character representation of , d is a fixed dimension; n represents the sentence text The number of words in
[0022] Step 2.2: Use PLM to encode the entity category labels in the natural language form in any sample and generate The corresponding labels represent 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] Further, the 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, key and value projection matrices to be trained, respectively. represents the activation function, T represents the transposition, is the scaling factor;
[0027] Step 3.2: , ,… ,…, }After concatenation, 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 a 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 concatenation operation.
[0034] Further, step 4 is performed as follows:
[0035] Step 4.1: Use equations (4) and (5) to obtain the character representation matrix with feature enhancement: 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, The label representation matrix representing 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] Further, step 6 is performed as follows:
[0043] Step 6.1: and Input them into the BiLSTM network for processing and generate the 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 prediction label sequence value; express The predicted label of the i-1th word in ; express The predicted label of the i-th word in ; is from arrive transfer score; is from arrive of transfer score and have:
[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 formula (11) to construct the character conditional likelihood loss function for label enhancement ,in, Representatives will The predicted label sequence output after input into the CRF network.
[0054] An electronic device of the present invention includes a memory and a processor, wherein 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 invention strengthens the model's ability to capture the unique semantic features of each entity category by introducing sentence-level contrastive learning that is aligned with label semantics during model training. This step method effectively combats the confusion problem of traditional NER models when facing entities with similar semantics but different categories, and improves the classification accuracy and robustness of the model on diverse corpora.
[0058] 2. By combining the pre-trained language model and hierarchical label information, the present invention enables each label to not only act independently on a single character or word, but also to fuse information at a broader semantic level, effectively improving the model's ability to understand the context. This technical feature solves the problem of information loss that may be caused by single label representation in the prior art, thereby significantly enhancing the boundary recognition accuracy of named entities.
[0059] 3. Different from the traditional NER method, the present invention realizes efficient named entity recognition without dictionary through comparative learning, which significantly reduces the dependence and construction cost of dictionary. Therefore, the model inference speed is significantly improved, which is suitable for practical application scenarios of large-scale text processing.
[0060] 4. The present invention effectively improves the adaptability of the model in different contexts by introducing a contrastive learning framework and combining it with label enhancement technology. Through contrastive learning at the sentence and word level, the model can better understand the differences and similarities of various labels, overcoming the problem of insufficient generalization ability of the model in the prior art, and performing well on multiple different data sets. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 is an example diagram of the present invention using PRM coding;
[0062] Figure 2 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 It is a performance experiment comparison diagram of the present invention and the existing method;
[0065] Figure 5 This is a comparison chart of the reasoning speed experiment between the present invention and the existing method. 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 a high-dimensional representation of the characters and labels. And use Cross-Transformer to further combine the representation 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 a corresponding entity category label (label) in encoded form, where the sentence text consists of several Chinese words, and the entity category label in encoded form 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 respectively, and obtain the corresponding character representation matrix and label representation matrix ;
[0070] Step 2.1: The present invention uses the BERT model as a 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 The character representation of , 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 in any sample and generate The corresponding labels represent 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 example uses the label "BPER.NOM", which indicates that the character belongs to the beginning part of the name entity. The present invention converts it into a natural language representation form: "the beginning word of the general person name", 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 subsequent contrastive learning module.
[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, key and value projection matrices to be trained, respectively. represents the activation function, T represents the transposition, is the scaling factor;
[0077] Step 3.2: , ,… ,…, }After concatenation, 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, 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 a similarity loss by maximizing the similarity between matching sentences and labels and minimizing the similarity between unmatched sentences and labels through sentence-level contrastive learning. (Sentence-level ContrastiveLeaming):
[0086] Using equations (4) and (5), we can get the character representation matrix with 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, The label representation matrix representing 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 pth word in The pth character of represents, 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 indicate the total number.
[0096] Figure 3 The workflow of sentence-level contrastive learning and character-level contrastive learning is shown in detail in . First, the characters in the sentence are generated by the PLM encoder , and 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 ,The positive sample in word-level contrastive learning 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 the BiLSTM network for processing and generate the 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 a 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 ; is from arrive transfer score; is from arrive of transfer score and have:
[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 formula (11) 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 on the computer-readable storage medium, and the computer program executes the steps of the above method when executed by a processor.
[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, the proposed model HLCL is compared with almost all lexicon enhancement 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, with the best results on two datasets and the second best result on one dataset. Compared with the best results of lexicon enhancement 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. In addition, compared with the classic dictionary-free method BERT + LSTM + CRF, HLCL shows stronger performance improvement on the OntoNotes, MSRA, Resume, and Weibo datasets, improving the F1 score by 1.14%, 1.03%, 0.43%, and 3.79%, respectively. Especially on the Weibo dataset, the improvement of HLCL is significantly higher than that of other datasets. 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, while HLCL effectively overcomes these difficulties and demonstrates its advantages in processing complex texts.
[0116] Figure 5The inference efficiency of different models was evaluated in the paper. The present invention compared the inference time (Inference-Time) of test sets of different data sets on the i9 12900k CPU and RTX 3090 GPU, and the batch size was set to 16. The present invention uses two dictionaries: "YJ" represents the dictionary used in the reference [Y. Zhang and J. Yang, "Chinese ner usinglattice lstm," arXiv preprint arXiv:1805.02023, 2018.], which contains 704.4K entries; "Ten" represents the dictionary used in the reference [Y. Song, S. Shi, J. Li, and H. Zhang, "Directionalskipgram: Explicitly distinguishing left and right context for wordembeddings," in Proceedings of the 2018 Conference of the North AmericanChapter of the Association for Computational Linguistics: Human LanguageTechnologies, Volume 2 (Short Papers), 2018, pp. 175–180.], which contains 8824.3K entries. SoftLexicon also uses the BiLSTMCRF model for NER learning, so the present invention uses it as a baseline model for comparison. Experimental results show that HLCL and SoftLexicon have similar inference time performance on the Resume and Weibo datasets. However, as the size of the test set increases, the inference time of SoftLexicon increases significantly, while the inference time of HLCL remains low. In addition, when using a larger dictionary "Ten", the inference time of SoftLexicon rises significantly, showing the complexity and time-consuming problem of dictionary matching operations when dealing with large-scale dictionaries. In contrast, HLCL can effectively reduce the inference time and show higher efficiency when dealing with large-scale data because it does not rely on complex dictionary structures.
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 is composed 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 a number of Chinese words; Step 2: Use the pre-trained language model PLM to encode the labels and characters in the named entity recognition task respectively, 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 a similarity loss by maximizing the similarity between matching sentences and labels and minimizing the similarity between unmatched 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 p-th character of the p-th word in represents, is the enhanced character representation of the i-th label in Y, is the enhanced character representation of 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 times reaches the set threshold, thereby obtaining a Chinese named entity recognition model for entity recognition of unlabeled Chinese sentences; (11)。 2. According to claim 1, a Chinese named entity recognition method based on hierarchical label enhanced contrastive learning 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 The character representation of , 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 in any sample and generate The corresponding labels represent 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. According to claim 2, a Chinese named entity recognition method based on hierarchical label enhanced contrastive learning is characterized in that: The 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, key and value projection matrices to be trained, respectively. represents the activation function, T represents the transposition, is the scaling factor; Step 3.2: , ,… ,…, }After concatenation, 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 a 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 concatenation operation.
4. According to claim 3, a Chinese named entity recognition method based on hierarchical label enhanced contrastive learning 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 feature enhancement: 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, The label representation matrix representing 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. According to claim 4, a Chinese named entity recognition method based on hierarchical label enhanced contrastive learning is characterized in that: The step 6 is carried out as follows: Step 6.1: and Input them into the BiLSTM network for processing and generate the 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 prediction label sequence value; express The predicted label of the i-1th word in ; express The predicted label of the i-th word in ; is from arrive transfer score; is from arrive of transfer score and have: (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 formula (11) to construct the character conditional likelihood loss function for label enhancement ,in, Representatives will The predicted label sequence output after input into 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 described in any one of claims 1-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 described in any one of claims 1 to 5 are executed.
Citation Information
Patent Citations
Small sample named entity identification method for entity level information enhanced prototype representation
CN116451691A
Label enhancement-based implicit discourse relation identification method for double-view hierarchical contrast learning
CN117350300A
Chinese microblog named entity recognition method based on tag semantic enhancement
CN117521657A
Techniques for training and deploying a named entity recognition model
US20240062108A1
Cited By
Coal geology field sentence semantic embedding modeling method based on multi-task learning
CN120297289A
Text data automatic labeling method and system integrating pre-training NLP model
CN120407775A
Text entity recognition model construction method and equipment based on large model data enhancement
CN120995985A