Entity recognition method, apparatus, device, storage medium and computer program product
Patent Information
- Application Number
- CN202211437185.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2042-11-15
AI Technical Summary
实体识别任务在搜索、推荐、知识图谱的构建等场景中有广泛应用,如何提高实体识别的准确性是当前的研究热点,但现有实体识别方法通常基于文本中各个字符对应的序列依赖特征来预测文本中所包含的实体,导致实体识别的准确性低
[0018] On one hand, embodiments of this application provide a computer program product, which includes a computer program stored in a computer storage medium; the processor of the entity recognition device reads the computer program from the computer storage medium and executes the computer program, causing the entity recognition device to perform the aforementioned entity recognition method.
Smart Images

Figure CN117010370B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence, and more particularly to an entity recognition method, apparatus, device, storage medium, and computer program product. Background Technology
[0002] Entity recognition tasks require the accurate prediction of entities contained in text. For example, if the text is "He is Li Bai," the entity contained in the text is "Li Bai." Entity recognition tasks require the accurate prediction of the entity contained in the text as "Li Bai," and not "he," "is," "is Li Bai," etc. Entity recognition tasks have wide applications in search, recommendation, and knowledge graph construction. Improving the accuracy of entity recognition is a current research hotspot. However, existing entity recognition methods typically predict the entities contained in the text based on the sequence dependency features corresponding to each character, resulting in low accuracy. Summary of the Invention
[0003] This application provides an entity recognition method, apparatus, device, storage medium, and computer program product, which can improve the accuracy of entity recognition.
[0004] On the one hand, embodiments of this application provide an entity recognition method, including:
[0005] Semantic feature encoding is performed on the target text to obtain the encoded semantic features corresponding to each character in the target text;
[0006] Sequence dependency feature extraction is performed on the encoded semantic features corresponding to each character to obtain the sequence dependency features corresponding to each character.
[0007] The encoded semantic features corresponding to each character are respectively fused with the corresponding sequence dependency features to obtain the fused features corresponding to each character;
[0008] Based on the fusion features corresponding to each character, the entities contained in the target text are predicted to obtain the target entities.
[0009] On one hand, embodiments of this application provide an entity recognition device, including:
[0010] The feature encoding unit is used to perform semantic feature encoding processing on the target text to obtain the encoded semantic features corresponding to each character in the target text.
[0011] The feature extraction unit is used to perform sequence dependency feature extraction processing on the encoded semantic features corresponding to each character to obtain the sequence dependency features corresponding to each character.
[0012] The feature fusion unit is used to perform feature fusion processing on the encoded semantic features and the corresponding sequence dependency features of each character respectively to obtain the fused features of each character;
[0013] The entity prediction unit is used to predict the entities contained in the target text based on the fusion features corresponding to each character, so as to obtain the target entities.
[0014] On one hand, embodiments of this application provide an entity recognition device, characterized in that the entity recognition device includes an input interface and an output interface, and further includes:
[0015] A processor, adapted to implement one or more instructions; and,
[0016] A computer storage medium storing one or more instructions adapted to be loaded by the processor and executed by the aforementioned entity recognition method.
[0017] On one hand, this application provides a computer storage medium, characterized in that the computer storage medium stores computer program instructions, which, when executed by a processor, are used to perform the above-described entity recognition method.
[0018] On one hand, embodiments of this application provide a computer program product, which includes a computer program stored in a computer storage medium; the processor of the entity recognition device reads the computer program from the computer storage medium and executes the computer program, causing the entity recognition device to perform the aforementioned entity recognition method.
[0019] In this embodiment, encoded semantic features and sequence dependency features corresponding to each character in the target text can be extracted. The encoded semantic features and sequence dependency features corresponding to each character are then fused to obtain fused features for each character. Based on these fused features, entities contained in the target text can be predicted to obtain the target entity. The feature fusion of encoded semantic features and sequence dependency features enables cross-layer feature fusion. Encoded semantic features corresponding to each character are introduced and interacted with on top of the sequence dependency features. This allows for the prediction of target entities based on the fused features, considering not only the sequence dependency features but also the encoded semantic features. In other words, the sequence relationships between characters and the deep semantic features of each character in the target text can be considered simultaneously, improving the accuracy of entity recognition. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a schematic diagram illustrating entity recognition based on a trained entity recognition model, provided in an embodiment of this application.
[0022] Figure 2 This is a flowchart illustrating an entity recognition method provided in an embodiment of this application;
[0023] Figure 3 This is a flowchart illustrating another entity recognition method provided in an embodiment of this application;
[0024] Figure 4 This is a schematic diagram illustrating another entity recognition method based on a trained entity recognition model provided in an embodiment of this application;
[0025] Figure 5 This is a schematic diagram of a process for training an entity recognition model according to an embodiment of this application;
[0026] Figure 6 This is a schematic diagram of the structure of the entity recognition device provided in the embodiments of this application;
[0027] Figure 7 This is a schematic diagram of the structure of the entity recognition device provided in the embodiments of this application. Detailed Implementation
[0028] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0029] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.
[0030] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision (CV), speech processing, natural language processing, and machine learning (ML) / deep learning (DL).
[0031] Natural Language Processing (NLP) is an important field within computer science and artificial intelligence. It studies the theories and methods for enabling effective communication between humans and computers using natural language. NLP is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language people use in daily life—and thus it has a close connection with linguistic research. NLP technologies typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs. Text processing can include part-of-speech tagging and sentence classification; semantic understanding can include lexical analysis, syntactic analysis, and semantic analysis; machine translation can include sentence generation and part-of-speech transformation; question answering can include question understanding and answer extraction; and knowledge graphs can include entity recognition, relation extraction, and knowledge completion.
[0032] Based on the aforementioned natural language processing techniques, this application provides an entity recognition scheme. This scheme encodes semantic features of the target text to obtain encoded semantic features corresponding to each character. It then extracts sequence dependency features from these encoded semantic features to obtain sequence dependency features for each character. Furthermore, it fuses the encoded semantic features of each character with the corresponding sequence dependency features to obtain fused features for each character. Finally, based on these fused features, it predicts the entities contained in the target text to obtain the target entities. The target text can be any text requiring entity recognition, such as an article title, article summary, article body, video title, etc.
[0033] In specific implementations, the aforementioned entity recognition scheme can be executed by an entity recognition device, which can be a terminal device or a server. The terminal device can include, but is not limited to, computers, smartphones, tablets, laptops, smart home appliances, in-vehicle terminals, and smart wearable devices. The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Further optionally, the aforementioned entity recognition scheme can also be executed individually or collaboratively by any computing-capable electronic device. This application embodiment does not impose limitations on this; however, subsequent embodiments of this application will use an entity recognition device as an example for illustration.
[0034] In one embodiment, the above entity recognition scheme can be implemented by calling a trained entity recognition model. The trained entity recognition model can be obtained by training an entity recognition model. The relevant process of training the entity recognition model will be described in subsequent embodiments and will not be described here. Further, the trained entity recognition model may include a semantic feature encoding module, a sequence dependency feature extraction module, a feature fusion module, and an entity prediction module. The semantic feature encoding module can be used to perform semantic feature encoding processing on the target text to obtain the encoded semantic features corresponding to each character in the target text. The sequence dependency feature extraction module can be used to perform sequence dependency feature extraction processing on the encoded semantic features corresponding to each character to obtain the sequence dependency features corresponding to each character. The feature fusion module can be used to perform feature fusion processing on the encoded semantic features corresponding to each character and the corresponding sequence dependency features to obtain the fused features corresponding to each character. The entity prediction module can be used to predict the entities contained in the target text based on the fused features corresponding to each character to obtain the target entities. Furthermore, the semantic feature encoding module can be any neural network model capable of performing semantic feature encoding processing on text, such as the language representation model BERT (Bidirectional Encoder Representations from Transformers), RoBERTa, etc.; the sequence dependency feature extraction module can be any neural network model capable of performing sequence dependency feature extraction processing, such as Long Short-Term Memory (LSTM) network, Bi-directional Long Short-Term Memory (BiLSTM) network, etc.; the neural network models used in the semantic feature encoding module and the sequence dependency feature extraction module can be selected or constructed according to specific needs, and this application embodiment does not impose any restrictions. In the subsequent embodiments of this application, BERT is used as the semantic feature encoding module and LSTM is used as the sequence dependency feature extraction module for illustrative purposes.
[0035] See Figure 1This diagram illustrates an entity recognition process based on a trained entity recognition model, as provided in this application embodiment. The entity recognition device can call the semantic feature encoding module in the trained entity recognition model to perform semantic feature encoding processing on the target text, obtaining the encoded semantic features corresponding to each character in the target text; call the sequence dependency feature extraction module in the trained entity recognition model to perform sequence dependency feature extraction processing on the encoded semantic features corresponding to each character, obtaining the sequence dependency features corresponding to each character; call the feature fusion module in the trained entity recognition model to perform feature fusion processing on the encoded semantic features corresponding to each character and the corresponding sequence dependency features, obtaining the fused features corresponding to each character; and call the entity prediction module in the trained entity recognition model to predict the entities contained in the target text based on the fused features corresponding to each character, obtaining the target entity.
[0036] It should be noted that in the specific implementation of this application, data related to the object is involved, such as target text being text uploaded by the object. When the embodiments of this application are applied to specific products or technologies, permission or consent from the object is required, and the collection, use and processing of related data must comply with local laws, regulations and standards.
[0037] Based on the above entity recognition scheme, this application provides an entity recognition method. See also... Figure 2 This is a flowchart illustrating an entity recognition method provided in an embodiment of this application. Figure 2 The entity recognition method shown can be executed by an entity recognition device. Figure 2 The entity recognition method shown may include the following steps:
[0038] S201, Perform semantic feature encoding on the target text to obtain the encoded semantic features corresponding to each character in the target text.
[0039] In one embodiment, semantic feature encoding of the target text can learn the deep semantic features of each character in the target text, which can be used as the feature embedding (i.e., embedding) of each character in the target text. In a specific implementation, the entity recognition device can call the semantic feature encoding module in the trained entity recognition model to perform semantic feature encoding of the target text and obtain the encoded semantic features corresponding to each character in the target text.
[0040] S202, perform sequence dependency feature extraction on the encoded semantic features corresponding to each character to obtain the sequence dependency features corresponding to each character.
[0041] In one embodiment, performing sequence dependency feature extraction processing on the encoded semantic features corresponding to each character can learn the sequence correlation between the encoded semantic features corresponding to each character, that is, it can learn the sequence correlation between each character in the target text and learn the context information of the target text. In a specific implementation, the entity recognition device can call the sequence dependency feature extraction module in the trained entity recognition model to perform sequence dependency feature extraction processing on the encoded semantic features corresponding to each character to obtain the sequence dependency features corresponding to each character.
[0042] S203, respectively, perform feature fusion processing on the encoded semantic features and the corresponding sequence dependency features corresponding to each character to obtain the fused features corresponding to each character.
[0043] In one embodiment, the encoded semantic features corresponding to each character are fused with the corresponding sequence dependency features to obtain the fused features corresponding to each character. This is to introduce the encoded semantic features corresponding to each character on the basis of the sequence dependency features corresponding to each character and perform feature interaction, so that when predicting the target entity based on the fused features corresponding to each character in the target text, the sequence dependency features corresponding to each character and the encoded semantic features corresponding to each character in the target text can be referenced at the same time. That is, the sequence correlation between each character in the target text and the deep semantic features of each character in the target text can be referenced at the same time.
[0044] S204. Based on the fusion features corresponding to each character, predict the entities contained in the target text to obtain the target entities.
[0045] In one embodiment, when predicting entities contained in target text, the entity annotation sequence corresponding to the target text can be predicted based on multiple entity annotation labels, and the target text can be extracted from the entity annotation sequence corresponding to the target text. That is, the predicted label corresponding to each character in the target text can be predicted from multiple entity annotation labels, and the sequence formed by the predicted labels corresponding to each character is the predicted entity annotation sequence corresponding to the target text. Then, characters whose predicted labels indicate entities can be selected from the target text as target entities. These multiple entity annotation labels can be used to annotate entities and non-entities in the text. These multiple entity annotation labels can include entity labels and non-entity labels, and the entity annotation labels can be set or selected according to specific needs. The number of entity annotation labels can vary depending on the selection. For example, multiple entity annotation labels "O|B|E|M" can be selected, where label "O" is a non-entity label, specifically representing a meaningless character used to annotate non-entities; label "B" is an entity label, specifically representing the beginning of an entity used to annotate the starting character of an entity; and label "M" is an entity label, specifically representing the beginning of an entity. In the middle, the labels are used to annotate the middle characters of entities. The label "E" is an entity label, specifically indicating the end of the entity, used to annotate the ending character of the entity. Alternatively, multiple entity label "B|I|O" can be selected, where the label "B" is an entity label, specifically indicating the beginning of the entity, used to annotate the starting character of the entity; the label "I" is an entity label, specifically indicating the middle of the entity, used to annotate the middle character of the entity; and the label "O" is a non-entity label, specifically indicating a meaningless character, used to annotate non-entities. Subsequent embodiments of this application will use "O|B|E|M" as an example. For instance, if the target text is "He is Li Shangyin", and the multiple entity label is "O|B|E|M", the predicted entity label sequence corresponding to the target text is "OOBME", then the target entity is "Li Shangyin".
[0046] In this embodiment, encoded semantic features and sequence dependency features corresponding to each character in the target text can be extracted. The encoded semantic features and sequence dependency features corresponding to each character are then fused to obtain fused features for each character. Based on these fused features, entities contained in the target text can be predicted to obtain the target entity. The feature fusion of encoded semantic features and sequence dependency features enables cross-layer feature fusion. Encoded semantic features corresponding to each character are introduced and interacted with on top of the sequence dependency features. This allows for the prediction of target entities based on the fused features, considering not only the sequence dependency features but also the encoded semantic features. In other words, the sequence relationships between characters and the deep semantic features of each character in the target text can be considered simultaneously, improving the accuracy of entity recognition.
[0047] Based on the aforementioned embodiments of entity recognition methods, this application provides another entity recognition method. See also... Figure 3 This is a flowchart illustrating another entity recognition method provided in an embodiment of this application. Figure 3 The entity recognition method shown can be executed by an entity recognition device. Figure 3 The entity recognition method shown may include the following steps:
[0048] S301, Perform semantic feature encoding processing on the target text to obtain the encoded semantic features corresponding to each character in the target text.
[0049] In one embodiment, the entity recognition device performs semantic feature encoding processing on the target text to obtain the encoded semantic features corresponding to each character in the target text. This can be achieved by calling the semantic feature encoding module in the trained entity recognition model. The encoded semantic feature corresponding to any character in the target text can be the encoded semantic vector corresponding to that character output by the semantic feature encoding module in the trained entity recognition model.
[0050] S302, perform sequence dependency feature extraction on the encoded semantic features corresponding to each character to obtain the sequence dependency features corresponding to each character.
[0051] In one embodiment, the entity recognition device performs sequence dependency feature extraction processing on the encoded semantic features corresponding to each character to obtain the sequence dependency features corresponding to each character. This can be achieved by calling the sequence dependency feature extraction module in the trained entity recognition model. The sequence dependency feature corresponding to any character can be the sequence dependency vector corresponding to that character output by the sequence dependency feature extraction module in the trained entity recognition model.
[0052] S303, respectively, perform feature fusion processing on the encoded semantic features and corresponding sequence dependency features corresponding to each character to obtain the fused features corresponding to each character.
[0053] In one embodiment, the entity recognition device can invoke the feature fusion module in the trained entity recognition model to perform feature fusion processing on the encoded semantic features and corresponding sequence dependency features corresponding to each character, thereby obtaining the fused features corresponding to each character. In a feasible implementation, the entity recognition device performing feature fusion processing on the encoded semantic features and corresponding sequence dependency features corresponding to each character to obtain the fused features corresponding to each character may include: for any character, performing feature concatenation processing on the encoded semantic features and corresponding sequence dependency features of that character to obtain the fused features corresponding to that character. Optionally, the feature concatenation processing on the encoded semantic features and corresponding sequence dependency features of that character can be implemented using a concatenation function, such as the `concat` function. In this case, the feature fusion module in the trained entity recognition model can be a `concat` layer.
[0054] In another feasible implementation, the entity recognition device performs feature fusion processing on the encoded semantic features and corresponding sequence dependency features corresponding to each character to obtain the fused features corresponding to each character. This may include: obtaining a fusion parameter matrix; the fusion parameter matrix includes at least one fusion parameter, which is used to indicate the fusion relationship between the encoded semantic features and corresponding sequence dependency features corresponding to each character; for any character among the characters, according to the fusion parameter matrix, tensor fusion processing is performed on the encoded semantic features and the sequence dependency features corresponding to that character to obtain the fused features corresponding to that character; wherein, the fusion parameter matrix is the model parameter in the trained entity recognition model, which can be learned by training the entity recognition model. In this case, the feature fusion module in the trained entity recognition model can be a tensor layer. Since the encoded semantic feature corresponding to any character can be the encoded semantic vector output by the semantic feature encoding module in the trained entity recognition model, and the sequence dependency feature corresponding to any character can be the sequence dependency vector output by the sequence dependency feature extraction module in the trained entity recognition model, both the encoded semantic feature and the sequence dependency feature are multi-dimensional feature vectors. Based on this, the entity recognition device performs tensor fusion processing on the encoded semantic feature and the sequence dependency feature corresponding to any character according to the fusion parameter matrix to obtain the fused feature corresponding to any character. This can include: multiplying the encoded semantic feature, the fusion parameter matrix, and the sequence dependency feature corresponding to any character using tensors to obtain the fused feature corresponding to any character. In other words, the fused feature corresponding to any character can be obtained based on tensor multiplication. Furthermore, if the target text includes N characters, where N is a positive integer, the encoded semantic vector corresponding to each character in the target text is represented as: T1, T2, ..., T... N The sequence dependency vectors corresponding to each character in the target text are represented as: L1, L2, ..., L N If the semantic feature encoding module in the trained entity recognition model is BERT, then the encoded semantic vector corresponding to each character in the target text can be represented as: T1, T2, ..., T N =BERT(text), where text represents the target text. If the sequence dependency feature extraction module in the trained entity recognition model is LSTM, then the sequence dependency vectors corresponding to each character in the target text are represented as: L1, L2, ..., L N =LSTM(T1,T2,…,T) N The encoded semantic vector T corresponding to the nth character in the target text. n And the sequence dependency vector L corresponding to the nth character. nFor example, where n is a positive integer less than or equal to N; if the encoded semantic vector T corresponding to the nth character in the target text n The dimension is 1*m, and the sequence dependency vector L corresponding to the nth character in the target text is... n If the dimension of the tensor layer is 1*h, then the dimension of the fusion parameter matrix can be m*h*d, where d is the number of neurons in the tensor layer, which can be set according to specific needs. The fusion feature corresponding to the nth character in the target text can then be represented as: F n =T n *W[1:d]*L n Where W[1:d] represents the fusion parameter matrix in the trained entity recognition model, and the dimension of the fusion feature corresponding to the nth character in the target text is 1*d. Optionally, when performing feature fusion processing on the encoded semantic feature corresponding to any character in the target text and the corresponding sequence dependency feature, other feature fusion methods can also be selected, such as the feature fusion method based on vector dot product. The above feature fusion methods are only illustrative examples.
[0055] S304. For any character among all characters, perform probability prediction processing on the fusion feature corresponding to any character to obtain the label prediction probability of any character being predicted as each entity label among multiple entity labels.
[0056] Among them, multiple entity annotation labels include entity labels and non-entity labels.
[0057] In one embodiment, when the entity recognition device performs probability prediction processing on the fusion feature corresponding to any character, it can perform probability mapping processing on the fusion feature corresponding to any character to each entity label in multiple entity labels to obtain the label prediction probability of any character being predicted as each entity label in multiple entity labels; optionally, the entity recognition device can call the fully connected layer in the trained entity recognition model to obtain the label prediction probability of any character being predicted as each entity label in multiple entity labels; further optionally, the fully connected layer can be included in the entity prediction module in the trained entity recognition model.
[0058] S305, based on the predicted probabilities of multiple labels corresponding to each character, determine the predicted label corresponding to each character from multiple entity label labels respectively; wherein, one character corresponds to one predicted label.
[0059] In one embodiment, the entity recognition device determines the predicted label corresponding to each character from multiple entity labels based on the predicted probabilities of multiple labels corresponding to each character. This can be achieved by calling the entity prediction module in the trained entity recognition model. If the target text includes N characters and the number of multiple entity labels is K, where N and K are positive integers, the entity recognition device determines the predicted label corresponding to each character from multiple entity labels based on the predicted probabilities of multiple labels corresponding to each character. This can include: for the nth character among the N characters, determining the maximum label prediction probability from the K label prediction probabilities corresponding to the nth character; selecting the entity label corresponding to the maximum label prediction probability from the K entity labels as the predicted label corresponding to the nth character, until the predicted label corresponding to each character is determined, where n is a positive integer less than or equal to N.
[0060] In one embodiment, if the target text includes N characters and the number of entity labels is K, where N and K are positive integers, when the entity recognition device determines the predicted label corresponding to each character from the multiple entity labels based on the predicted probabilities of the multiple labels corresponding to each character, it can be implemented using a Conditional Random Field (CRF) model. Specifically, this can include: constructing multiple candidate label sequences corresponding to the target text based on the K entity labels; each candidate label sequence includes N candidate labels, and each candidate label is selected from the K entity labels; evaluating the multiple candidate label sequences based on the predicted probabilities of the K labels corresponding to each character to obtain the evaluation score of each candidate label sequence; and determining each candidate label in the candidate label sequence indicated by the maximum evaluation score as the predicted label corresponding to the corresponding character; wherein, the candidate label sequence indicated by the maximum evaluation score is the predicted entity label sequence corresponding to the target text.
[0061] For example, if the target text is "He is Li Shangyin", and the multiple entity annotation labels are "O|B|E|M", then the candidate label sequence corresponding to the target text constructed based on the K entity annotation labels can include, for example, the following: "BBBBB", "BMBBB", "BBMBB", "BBBMB", etc. Further, the entity recognition device evaluates the multiple candidate label sequences based on the predicted probabilities of the K labels corresponding to each character, obtaining an evaluation score for each candidate label sequence. This can include: obtaining the label transition probability of the nth candidate label in any candidate label sequence; the label transition probability indicates the probability of transitioning from the (n-1)th candidate label in any candidate label sequence to the nth candidate label, where n is a positive integer less than or equal to N; determining the evaluation score of the nth character based on the predicted label probability of the nth character in the target text being predicted as the nth candidate label, and the label transition probability; and determining the evaluation score of any candidate label sequence based on the evaluation scores of each character.
[0062] Where n=1, i.e., for the first candidate label in any candidate label sequence, the label transition probability of the first candidate label is used to indicate the probability of transitioning from the special label "START" to the first candidate label, where the special label "START" can represent the beginning of the text. For example, if the target text is "He is Li Shangyin", and the multiple entity labels are "O|B|E|M", and if any candidate label sequence is "BMBBB", when n=1, the first candidate label is "B", and the label transition probability of the first candidate label is the probability of transitioning from the special label "START" to the label "B". When n=2, the second candidate label is "M", and the label transition probability of the second candidate label is the probability of transitioning from the label "B" to the label "M". When n=3, the third candidate label is "B", and the label transition probability of the third candidate label is... : The probability of transitioning from label "M" to label "B"; If any candidate label sequence is "OOBME", when n=1, the first candidate label is "O", and the label transition probability of the first candidate label is: the probability of transitioning from the special label "START" to label "O". When n=2, the second candidate label is "O", and the label transition probability of the second candidate label is: the probability of transitioning from label "O" to label "O". When n=3, the third candidate label is "B", and the label transition probability of the third candidate label is: the probability of transitioning from label "O" to label "B". The label transition probability of any candidate label can be obtained from the label transition probability matrix, which is a model parameter in the trained entity recognition model and can be learned through training the entity recognition model. This label transition probability matrix primarily learns the dependencies between entity labels. For example, when multiple entity labels are "O|B|E|M", the requirement is that the entity label corresponding to the first character in the text should be label "O" or label "B", and not label "M" or label "E". Therefore, when learning the label transition probability matrix... When learning the label transition probability matrix, it is expected that the probability of transitioning from the special label "START" to label "O" or label "B" should be relatively high, and the probability of transitioning from the special label "START" to label "M" or label "E" should be relatively low. For example, if it is required that the next label after label "O" can be label "B" or label "O", but not label "M" or label "E", then when learning the label transition probability matrix, it is expected that the probability of transitioning from label "O" to label "B" or label "O" should be relatively high, and the probability of transitioning from label "O" to label "M" or label "E" should be relatively low.
[0063] Furthermore, when determining the evaluation score of the nth character based on the label prediction probability and label transition probability of the nth character in the target text being predicted as the nth candidate label, the entity recognition device can perform summation, multiplication, etc. This application embodiment uses summation as an example. For instance, if the target text is "He is Li Shangyin", and multiple entity labels are "O|B|E|M", and any candidate label sequence is "OOBME", when n=1, the first candidate label is "O". The label transition probability of the first candidate label is the probability of transitioning from the special label "START" to the label "O". The label prediction probability of the nth character in the target text being predicted as the nth candidate label is the label prediction probability of the first character "he" in the target text being predicted as the label "O". Furthermore, the entity recognition device determines the evaluation score of any candidate label sequence based on the evaluation score of each character. It can perform summation, multiplication, and other processing on the evaluation scores of each character. This application embodiment will be described using the summation processing method.
[0064] S306, Select the characters in the target text whose corresponding predicted labels are entity labels as target entities.
[0065] See Figure 4This diagram illustrates another entity recognition method based on a trained entity recognition model, as provided in this application embodiment. The semantic feature encoding module of this trained entity recognition model is BERT, the sequence dependency feature extraction module is LSTM, and the entity prediction module includes a Conditional Random Field (CRF) model. The entity recognition device can use the BERT semantic feature encoding module in the trained entity recognition model to perform semantic feature encoding on the target text, obtaining the encoded semantic features corresponding to each character in the target text; and use the LSTM sequence dependency feature extraction module in the trained entity recognition model to perform sequence dependency feature extraction on the encoded semantic features corresponding to each character, obtaining the sequence dependency features corresponding to each character; and use the LSTM sequence dependency feature extraction module in the trained entity recognition model to perform sequence dependency feature extraction on the encoded semantic features corresponding to each character; and use the LSTM sequence dependency feature extraction module in the trained entity recognition model to perform sequence dependency feature extraction on the encoded semantic features corresponding to each character. The FusionModule fuses the encoded semantic features and sequence dependency features of each character to obtain the fused features for each character. Then, through the fully connected layer of the entity prediction module in the trained entity recognition model, it performs probability prediction on the fused features of any given character to obtain the prediction probability of that character being predicted as one of the various entity labels. Using a Conditional Random Field (CRF) model, it determines the predicted labels for each character from the multiple entity labels based on the predicted probabilities. Finally, it selects the characters in the target text whose predicted labels are entity labels as the target entities. Specifically, when determining the predicted labels for each character from the multiple entity labels using the CRF model, it constructs multiple candidate label sequences for the target text based on the multiple entity labels. It then evaluates these candidate label sequences based on their predicted probabilities, obtaining evaluation scores for each sequence. Finally, it identifies the candidate labels in the sequence with the highest evaluation score as the predicted labels for the corresponding characters. Optionally, since BERT introduces a special marker [cls] during the semantic feature encoding process of the target text, it obtains the encoded semantic features corresponding to the special marker [cls] and the encoded semantic features corresponding to each character in the target text. Furthermore, the encoded semantic features corresponding to the special marker [cls] can be used as part of the encoded semantic features corresponding to each character in the target text, and then passed together through the sequence dependency feature extraction module to achieve the subsequent process.
[0066] In one embodiment, the trained entity recognition model can be obtained by training an entity recognition model. The entity recognition model and the trained entity recognition model have the same model structure, but different model parameters. See also... Figure 5This is a flowchart illustrating the training process of an entity recognition model according to an embodiment of this application; S501, obtaining sample text and reference labels corresponding to each sample character in the sample text; the reference label corresponding to any sample character is selected from multiple entity labeling labels; S502, using the entity recognition model, performing semantic feature encoding processing on the sample text to obtain the encoded semantic features corresponding to each sample character in the sample text; S503, performing sequence dependency feature extraction processing on the encoded semantic features corresponding to each sample character to obtain the sequence dependency features corresponding to each sample character; S504, performing feature fusion processing on the encoded semantic features corresponding to each sample character and the corresponding sequence dependency features respectively to obtain the fused features corresponding to each sample character; S505, for any sample character among the sample characters, performing probability prediction processing on the fused features corresponding to that sample character to obtain the label prediction probability that the sample character is predicted as each entity label among multiple entity labeling labels; S506, based on the difference between the reference label corresponding to each sample character and the corresponding label prediction probability, training the entity recognition model to obtain the trained entity recognition model.
[0067] The process of training the entity recognition model can be performed by the entity recognition device or by any computing-capable electronic device alone or in collaboration. This embodiment uses an entity recognition device as an example. The reference label corresponding to any sample character is used to indicate the entity label of that sample character. The processes of steps S502 to S505 are similar to those of S301 to S304 described above, and will not be repeated here. Furthermore, when training the entity recognition model based on the difference between the reference label and the corresponding label prediction probability for each sample character, the entity recognition device can use a target loss function. Specifically, the value of the target loss function can be determined based on the reference label and the corresponding label prediction probability for each sample character, and the model parameters of the entity recognition model can be adjusted in the direction of reducing the value of the target loss function. For example, the parameter fusion matrix and the label transition probability matrix can be adjusted. Optionally, the target loss function can be set according to specific needs. An exemplary target loss function proposed in this application can be shown by the following formula 1:
[0068]
[0069] Where N′ represents the number of sample characters included in the sample text, K represents the number of entity annotation labels, and if the entity annotation labels are “O|B|E|M”, then K = 4, i and j are independent variables, where i is a positive integer less than or equal to N′, and j is a positive integer less than or equal to K; y ijUsed to indicate the reference label corresponding to the i-th sample character in the sample text, when y ij When y = 0, it means that the reference label corresponding to the i-th sample character in the sample text is not the j-th entity label among the K entity label labels. ij When a = 1, it means that the reference label corresponding to the i-th sample character in the sample text is the j-th entity label among the K entity label labels; ij This represents the label prediction probability that the i-th sample character in the sample text is predicted to be the j-th entity label among K entity labels.
[0070] In another optional implementation, when training the entity recognition model based on the difference between the reference label and the corresponding label prediction probability for each sample character, the entity recognition device can also construct multiple candidate label sequences corresponding to the sample text based on K entity annotation labels; evaluate the multiple candidate label sequences corresponding to the sample text based on the K label prediction probabilities corresponding to each sample character to obtain the evaluation score of each candidate label sequence corresponding to the sample text; and then train the entity recognition model in the direction of increasing the proportion of the evaluation score of the target candidate label sequence in the evaluation score of each candidate label sequence corresponding to the sample text. The target candidate label sequence is the sequence that is equal to the sequence formed by the reference labels corresponding to each sample character in the sample text among the candidate label sequences corresponding to the sample text. The process by which the entity recognition device constructs multiple candidate label sequences corresponding to the sample text based on K entity annotation labels and predicts the probabilities of the K labels corresponding to each sample character to obtain the evaluation score of each candidate label sequence corresponding to the sample text is similar to the process described above, which constructs multiple candidate label sequences corresponding to the target text based on K entity annotation labels and predicts the probabilities of the K labels corresponding to each character to obtain the evaluation score of each candidate label sequence corresponding to the target text. Therefore, it will not be described in detail here.
[0071] Furthermore, the trained entity recognition model can be obtained by iteratively training the entity recognition model based on one or more sample texts; further optionally, the semantic feature encoding module in the entity recognition model can be a pre-trained neural network model, such as a pre-trained BERT. In this case, the entity recognition model can be fine-tuned (i.e., fine-tuned) based on one or more sample texts to obtain the trained entity recognition model, which can save the training time of the entity recognition model.
[0072] In this embodiment, the encoded semantic features corresponding to each character in the target text are fused with the corresponding sequence dependency features to achieve cross-layer feature fusion. This allows the introduction of the encoded semantic features corresponding to each character on top of the sequence dependency features, enabling feature interaction. When predicting target entities based on the fused features corresponding to each character, not only the sequence dependency features of each character in the target text can be referenced, but also the encoded semantic features. That is, both the sequence correlation between characters in the target text and the deep semantic features of each character in the target text can be considered simultaneously. Furthermore, when fusing the encoded semantic features with the sequence dependency features, a tensor multiplication-based feature fusion method can be used. This tensor multiplication-based feature fusion method is a second-order fusion, which, compared to other feature fusion methods, can strengthen the interaction between the encoded semantic features and the sequence dependency features, thereby improving the accuracy of entity recognition.
[0073] Based on the embodiments related to the above entity recognition methods, this application provides an entity recognition device. See also... Figure 6 This is a schematic diagram of the structure of an entity recognition device provided in an embodiment of this application. The entity recognition device may include a feature encoding unit 601, a feature extraction unit 602, a feature fusion unit 603, and an entity prediction unit 604. Figure 6 The entity recognition device shown can be used to perform the following operations:
[0074] The feature encoding unit 601 is used to perform semantic feature encoding processing on the target text to obtain the encoded semantic features corresponding to each character in the target text.
[0075] The feature extraction unit 602 is used to perform sequence dependency feature extraction processing on the encoded semantic features corresponding to each character to obtain the sequence dependency features corresponding to each character.
[0076] The feature fusion unit 603 is used to perform feature fusion processing on the encoded semantic features and the corresponding sequence dependency features of each character respectively to obtain the fused features of each character.
[0077] The entity prediction unit 604 is used to predict the entities contained in the target text based on the fusion features corresponding to each character, so as to obtain the target entities.
[0078] In one embodiment, when the feature fusion unit 603 performs feature fusion processing on the encoded semantic features and corresponding sequence dependency features corresponding to each character to obtain the fused features corresponding to each character, it specifically performs the following operations:
[0079] Obtain a fusion parameter matrix; the fusion parameter matrix includes at least one fusion parameter, which is used to indicate the fusion relationship between the encoded semantic features corresponding to each character and the corresponding sequence dependency features;
[0080] For any one of the characters, tensor fusion processing is performed on the encoded semantic features and sequence dependency features corresponding to the character according to the fusion parameter matrix to obtain the fusion feature corresponding to the character.
[0081] In one embodiment, the encoded semantic features corresponding to any character and the sequence dependency features corresponding to any character are multidimensional feature vectors;
[0082] When the feature fusion unit 603 performs tensor fusion processing on the encoded semantic features and sequence dependency features corresponding to any character according to the fusion parameter matrix to obtain the fused features corresponding to any character, it specifically performs the following operations:
[0083] The fusion feature corresponding to any character is obtained by multiplying the encoded semantic feature, the fusion parameter matrix, and the sequence dependency feature corresponding to any character by tensor multiplication.
[0084] In one embodiment, when the feature fusion unit 603 performs feature fusion processing on the encoded semantic features and corresponding sequence dependency features corresponding to each character to obtain the fused features corresponding to each character, it specifically performs the following operations:
[0085] For any one of the characters, the encoded semantic feature corresponding to the character and the sequence dependency feature corresponding to the character are concatenated to obtain the fused feature corresponding to the character.
[0086] In one embodiment, the entity prediction unit 604 performs prediction processing on the entities contained in the target text based on the fusion features corresponding to each character. When obtaining the target entity, the specific operation is as follows:
[0087] For any one of the characters, a probability prediction process is performed on the fusion feature corresponding to the character to obtain the label prediction probability of the character being predicted as each of the multiple entity label labels; the multiple entity label labels include entity labels and non-entity labels.
[0088] Based on the predicted probabilities of multiple labels corresponding to each character, the predicted label corresponding to each character is determined from the multiple entity annotation labels; wherein, one character corresponds to one predicted label;
[0089] The character in the target text whose predicted label is an entity label is selected as the target entity.
[0090] In one embodiment, the target text comprises N characters, and the number of the plurality of entity annotation tags is K, where N and K are positive integers;
[0091] When the entity prediction unit 604 determines the predicted label corresponding to each character from the multiple entity annotation labels based on the predicted probability of each character, it specifically performs the following operations:
[0092] Multiple candidate tag sequences corresponding to the target text are constructed based on K entity annotation labels; each candidate tag sequence includes N candidate tags, and each candidate tag is selected from the K entity annotation labels;
[0093] Based on the predicted probabilities of the K tags corresponding to each character, the multiple candidate tag sequences are evaluated to obtain the evaluation score of each candidate tag sequence.
[0094] Each candidate label in the candidate label sequence indicated by the maximum evaluation score is determined as the predicted label corresponding to the corresponding character.
[0095] In one embodiment, when the entity prediction unit 604 evaluates the multiple candidate label sequences based on the predicted probabilities of the K labels corresponding to each character and obtains the evaluation score of each candidate label sequence, it specifically performs the following operations:
[0096] For the nth candidate label in any candidate label sequence, obtain the label transition probability of the nth candidate label; the label transition probability is used to indicate the probability of transitioning from the (n-1)th candidate label in any candidate label sequence to the nth candidate label, where n is a positive integer less than or equal to N;
[0097] Based on the tag prediction probability of the nth character in the target text being predicted as the nth candidate tag, and the tag transition probability, the evaluation score of the nth character is determined.
[0098] The evaluation score of any candidate tag sequence is determined based on the evaluation score of each character.
[0099] In one embodiment, the target entity is predicted by calling a trained entity recognition model;
[0100] The entity recognition device is also used for:
[0101] Obtain the sample text and the reference label corresponding to each sample character in the sample text; the reference label corresponding to any sample character is selected from multiple entity annotation labels;
[0102] The sample text is semantically encoded using an entity recognition model to obtain the encoded semantic features corresponding to each sample character in the sample text.
[0103] Sequence dependency feature extraction is performed on the encoded semantic features corresponding to each sample character to obtain the sequence dependency features corresponding to each sample character.
[0104] The encoded semantic features and corresponding sequence dependency features corresponding to each sample character are respectively subjected to feature fusion processing to obtain the fused features corresponding to each sample character;
[0105] For any sample character among the sample characters, perform probability prediction processing on the fusion feature corresponding to the sample character to obtain the label prediction probability of the sample character being predicted as each entity label among the multiple entity labels.
[0106] The entity recognition model is trained based on the difference between the reference label and the corresponding label prediction probability for each sample character to obtain the trained entity recognition model.
[0107] According to one embodiment of this application, Figure 2 as well as Figure 3 The steps involved in the entity recognition method shown can be derived from... Figure 6 This is performed by the individual units in the entity recognition device shown. For example, Figure 2 The step S201 shown can be performed by Figure 6 The feature encoding unit 601 in the entity recognition device shown performs this function. Figure 2 The step S202 shown can be performed by Figure 6 The feature extraction unit 602 in the entity recognition device shown performs this operation. Figure 2 The step S203 shown can be performed by Figure 6 The feature fusion unit 603 in the entity recognition device shown performs this operation. Figure 2 The step S204 shown can be performed by Figure 6 The entity prediction unit 604 in the entity recognition device shown performs this operation. For example, Figure 3 The step S301 shown can be performed by Figure 6 The feature encoding unit 601 in the entity recognition device shown performs this function. Figure 3 The step S302 shown can be performed by Figure 6 The feature extraction unit 602 in the entity recognition device shown performs this operation. Figure 3The step S303 shown can be performed by Figure 6 The feature fusion unit 603 in the entity recognition device shown performs this operation. Figure 3 Steps S304 to S306 shown can be derived from... Figure 6 The entity prediction unit 604 in the entity recognition device shown performs this operation.
[0108] According to another embodiment of this application, Figure 6 The entities in the illustrated entity recognition device can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This achieves the same operation without affecting the technical effects of the embodiments of this application. The above units are based on logical function division. In practical applications, the function of one unit can also be implemented by multiple units, or the function of multiple units can be implemented by one unit. For example, the functions implemented by the above units can be implemented by one processing unit. In other embodiments of this application, the entity recognition device based on logical function division may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.
[0109] According to another embodiment of this application, the following can be achieved by running on a general-purpose computing device, such as a computer, which includes processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM), a device capable of performing operations such as... Figure 2 , Figure 3 as well as Figure 5 The computer program (including program code) for each step involved in the corresponding method shown, to construct such... Figure 6 The entity recognition device shown herein, and the entity recognition method for implementing the embodiments of this application, are described. The computer program may be recorded on, for example, a computer-readable storage medium, loaded onto the aforementioned computing device via the computer-readable storage medium, and run therein.
[0110] In this embodiment, encoded semantic features and sequence dependency features corresponding to each character in the target text can be extracted. The encoded semantic features and sequence dependency features corresponding to each character are then fused to obtain fused features for each character. Based on these fused features, entities contained in the target text can be predicted to obtain the target entity. The feature fusion of encoded semantic features and sequence dependency features enables cross-layer feature fusion. Encoded semantic features corresponding to each character are introduced and interacted with on top of the sequence dependency features. This allows for the prediction of target entities based on the fused features, considering not only the sequence dependency features but also the encoded semantic features. In other words, the sequence relationships between characters and the deep semantic features of each character in the target text can be considered simultaneously, improving the accuracy of entity recognition.
[0111] Based on the aforementioned embodiments of the entity recognition method and the entity recognition device, this application also provides an entity recognition device. See also... Figure 7 This is a schematic diagram of the structure of an entity recognition device provided in an embodiment of this application. Figure 7 The entity recognition device shown may include at least a processor 701, an input interface 702, an output interface 703, and a computer storage medium 704. The processor 701, input interface 702, output interface 703, and computer storage medium 704 may be connected via a bus or other means.
[0112] The computer storage medium 704 can be stored in the memory of the entity recognition device. The computer storage medium 704 is used to store computer programs, which include program instructions. The processor 701 is used to execute the program instructions stored in the computer storage medium 704. The processor 701 (or CPU (Central Processing Unit)) is the computing and control core of the entity recognition device. It is suitable for implementing one or more instructions, specifically for loading and executing one or more instructions to realize the above-mentioned entity recognition method flow or corresponding functions.
[0113] This application embodiment also provides a computer storage medium (Memory), which is a memory device in an entity recognition device used to store programs and data. It is understood that the computer storage medium here can include the built-in storage medium in the terminal, or it can include an extended storage medium supported by the terminal. The computer storage medium provides storage space, which stores the terminal's operating system. Furthermore, the storage space also stores one or more instructions suitable for loading and execution by the processor 701. These instructions can be one or more computer programs (including program code). It should be noted that the computer storage medium here can be a high-speed random access memory (RAM), or it can be non-volatile memory, such as at least one disk storage device; optionally, it can also be at least one computer storage medium located remotely from the aforementioned processor.
[0114] In one embodiment, the processor 701 may load and execute one or more instructions stored in the computer storage medium to implement the aforementioned related... Figure 2 , Figure 3 as well as Figure 5 In the embodiment of the entity recognition method, one or more instructions in the computer storage medium are loaded and executed by the processor 701 in the following steps:
[0115] Semantic feature encoding is performed on the target text to obtain the encoded semantic features corresponding to each character in the target text;
[0116] Sequence dependency feature extraction is performed on the encoded semantic features corresponding to each character to obtain the sequence dependency features corresponding to each character.
[0117] The encoded semantic features corresponding to each character are respectively fused with the corresponding sequence dependency features to obtain the fused features corresponding to each character;
[0118] Based on the fusion features corresponding to each character, the entities contained in the target text are predicted to obtain the target entities.
[0119] In one embodiment, when the processor 701 performs feature fusion processing on the encoded semantic features corresponding to each character and the corresponding sequence dependency features to obtain the fused features corresponding to each character, the following operations are specifically performed:
[0120] Obtain a fusion parameter matrix; the fusion parameter matrix includes at least one fusion parameter, which is used to indicate the fusion relationship between the encoded semantic features corresponding to each character and the corresponding sequence dependency features;
[0121] For any one of the characters, tensor fusion processing is performed on the encoded semantic features and sequence dependency features corresponding to the character according to the fusion parameter matrix to obtain the fusion feature corresponding to the character.
[0122] In one embodiment, the encoded semantic features corresponding to any character and the sequence dependency features corresponding to any character are multidimensional feature vectors;
[0123] When the processor 701 performs tensor fusion processing on the encoded semantic features and sequence dependency features corresponding to any character based on the fusion parameter matrix to obtain the fused features corresponding to any character, it specifically performs the following operations:
[0124] The fusion feature corresponding to any character is obtained by multiplying the encoded semantic feature, the fusion parameter matrix, and the sequence dependency feature corresponding to any character by tensor multiplication.
[0125] In one embodiment, when the processor 701 performs feature fusion processing on the encoded semantic features corresponding to each character and the corresponding sequence dependency features to obtain the fused features corresponding to each character, the following operations are specifically performed:
[0126] For any one of the characters, the encoded semantic feature corresponding to the character and the sequence dependency feature corresponding to the character are concatenated to obtain the fused feature corresponding to the character.
[0127] In one embodiment, when the processor 701 performs prediction processing on the entities contained in the target text based on the fusion features corresponding to each character, and obtains the target entities, it specifically performs the following operations:
[0128] For any one of the characters, a probability prediction process is performed on the fusion feature corresponding to the character to obtain the label prediction probability of the character being predicted as each of the multiple entity label labels; the multiple entity label labels include entity labels and non-entity labels.
[0129] Based on the predicted probabilities of multiple labels corresponding to each character, the predicted label corresponding to each character is determined from the multiple entity annotation labels; wherein, one character corresponds to one predicted label;
[0130] The character in the target text whose predicted label is an entity label is selected as the target entity.
[0131] In one embodiment, the target text comprises N characters, and the number of the plurality of entity annotation tags is K, where N and K are positive integers;
[0132] When the processor 701 determines the predicted label corresponding to each character from the multiple entity annotation labels based on the predicted probability of each character according to the multiple labels corresponding to each character, it specifically performs the following operations:
[0133] Multiple candidate tag sequences corresponding to the target text are constructed based on K entity annotation labels; each candidate tag sequence includes N candidate tags, and each candidate tag is selected from the K entity annotation labels;
[0134] Based on the predicted probabilities of the K tags corresponding to each character, the multiple candidate tag sequences are evaluated to obtain the evaluation score of each candidate tag sequence.
[0135] Each candidate label in the candidate label sequence indicated by the maximum evaluation score is determined as the predicted label corresponding to the corresponding character.
[0136] In one embodiment, when the processor 701 evaluates the plurality of candidate label sequences based on the predicted probabilities of the K labels corresponding to each character and obtains the evaluation score of each candidate label sequence, it specifically performs the following operations:
[0137] For the nth candidate label in any candidate label sequence, obtain the label transition probability of the nth candidate label; the label transition probability is used to indicate the probability of transitioning from the (n-1)th candidate label in any candidate label sequence to the nth candidate label, where n is a positive integer less than or equal to N;
[0138] Based on the tag prediction probability of the nth character in the target text being predicted as the nth candidate tag, and the tag transition probability, the evaluation score of the nth character is determined.
[0139] The evaluation score of any candidate tag sequence is determined based on the evaluation score of each character.
[0140] In one embodiment, the target entity is predicted by calling a trained entity recognition model;
[0141] The processor 701 is also used for:
[0142] Obtain the sample text and the reference label corresponding to each sample character in the sample text; the reference label corresponding to any sample character is selected from multiple entity annotation labels;
[0143] The sample text is semantically encoded using an entity recognition model to obtain the encoded semantic features corresponding to each sample character in the sample text.
[0144] Sequence dependency feature extraction is performed on the encoded semantic features corresponding to each sample character to obtain the sequence dependency features corresponding to each sample character.
[0145] The encoded semantic features and corresponding sequence dependency features corresponding to each sample character are respectively subjected to feature fusion processing to obtain the fused features corresponding to each sample character;
[0146] For any sample character among the sample characters, perform probability prediction processing on the fusion feature corresponding to the sample character to obtain the label prediction probability of the sample character being predicted as each entity label among the multiple entity labels.
[0147] The entity recognition model is trained based on the difference between the reference label and the corresponding label prediction probability for each sample character to obtain the trained entity recognition model.
[0148] This application provides a computer program product, which includes a computer program stored in a computer storage medium. The processor of an entity recognition device reads the computer program from the computer storage medium and executes the computer program, causing the entity recognition device to perform the aforementioned actions. Figure 2 , Figure 3 as well as Figure 5 The method embodiment shown. The computer-readable storage medium may be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0149] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. An entity recognition method, characterized in that, include: Semantic feature encoding is performed on the target text to obtain the encoded semantic features corresponding to each character in the target text; Sequence dependency feature extraction is performed on the encoded semantic features corresponding to each character to obtain the sequence dependency features corresponding to each character. Obtain a fusion parameter matrix; the fusion parameter matrix includes at least one fusion parameter, which is used to indicate the fusion relationship between the encoded semantic features corresponding to each character and the corresponding sequence dependency features; For any one of the characters, tensor fusion processing is performed on the encoded semantic features and the sequence dependency features corresponding to the character according to the fusion parameter matrix to obtain the fusion features corresponding to the character. Based on the fusion features corresponding to each character, the entities contained in the target text are predicted to obtain the target entities.
2. The method as described in claim 1, characterized in that, The encoded semantic features and the sequence dependency features corresponding to any character are multi-dimensional feature vectors. The step of performing tensor fusion processing on the encoded semantic features and sequence dependency features corresponding to any character based on the fusion parameter matrix to obtain the fused features corresponding to any character includes: The fusion feature corresponding to any character is obtained by multiplying the encoded semantic feature, the fusion parameter matrix, and the sequence dependency feature corresponding to any character by tensor multiplication.
3. The method as described in claim 1, characterized in that, The step of predicting entities contained in the target text based on the fusion features corresponding to each character to obtain target entities includes: For any one of the characters, a probability prediction process is performed on the fusion feature corresponding to the character to obtain the label prediction probability of the character being predicted as each of the multiple entity label labels; the multiple entity label labels include entity labels and non-entity labels. Based on the predicted probabilities of multiple labels corresponding to each character, the predicted label corresponding to each character is determined from the multiple entity annotation labels; wherein, one character corresponds to one predicted label; The character in the target text whose predicted label is an entity label is selected as the target entity.
4. The method as described in claim 3, characterized in that, The target text comprises N characters, and the number of the plurality of entity annotation tags is K, where N and K are positive integers; The step of predicting probabilities based on multiple labels corresponding to each character and determining the predicted label corresponding to each character from the multiple entity annotation labels includes: Multiple candidate tag sequences corresponding to the target text are constructed based on K entity annotation labels; each candidate tag sequence includes N candidate tags, and each candidate tag is selected from the K entity annotation labels; Based on the predicted probabilities of the K tags corresponding to each character, the multiple candidate tag sequences are evaluated to obtain the evaluation score of each candidate tag sequence. Each candidate label in the candidate label sequence indicated by the maximum evaluation score is determined as the predicted label corresponding to the corresponding character.
5. The method as described in claim 4, characterized in that, The step of predicting probabilities based on the K tags corresponding to each character and evaluating the multiple candidate tag sequences to obtain an evaluation score for each candidate tag sequence includes: For the nth candidate label in any candidate label sequence, obtain the label transition probability of the nth candidate label; the label transition probability is used to indicate the probability of transitioning from the (n-1)th candidate label in any candidate label sequence to the nth candidate label, where n is a positive integer less than or equal to N; Based on the tag prediction probability of the nth character in the target text being predicted as the nth candidate tag, and the tag transition probability, the evaluation score of the nth character is determined. The evaluation score of any candidate tag sequence is determined based on the evaluation score of each character.
6. The method as described in claim 1, characterized in that, The target entity is predicted by calling a trained entity recognition model; The method further includes: Obtain the sample text and the reference label corresponding to each sample character in the sample text; the reference label corresponding to any sample character is selected from multiple entity annotation labels; The sample text is processed by semantic feature encoding using an entity recognition model to obtain the encoded semantic features corresponding to each sample character in the sample text. Sequence dependency feature extraction is performed on the encoded semantic features corresponding to each sample character to obtain the sequence dependency features corresponding to each sample character. The encoded semantic features and corresponding sequence dependency features corresponding to each sample character are respectively subjected to feature fusion processing to obtain the fused features corresponding to each sample character; For any sample character among the sample characters, perform probability prediction processing on the fusion feature corresponding to the sample character to obtain the label prediction probability of the sample character being predicted as each entity label among the multiple entity labels. The entity recognition model is trained based on the difference between the reference label and the corresponding label prediction probability for each sample character to obtain the trained entity recognition model.
7. An entity recognition device, characterized in that, include: The feature encoding unit is used to perform semantic feature encoding processing on the target text to obtain the encoded semantic features corresponding to each character in the target text. The feature extraction unit is used to perform sequence dependency feature extraction processing on the encoded semantic features corresponding to each character to obtain the sequence dependency features corresponding to each character. A feature fusion unit is used to obtain a fusion parameter matrix; the fusion parameter matrix includes at least one fusion parameter, which is used to indicate the fusion relationship between the encoded semantic features and the corresponding sequence dependency features of each character; for any character among the characters, tensor fusion processing is performed on the encoded semantic features and the sequence dependency features of the any character according to the fusion parameter matrix to obtain the fusion feature of the any character; The entity prediction unit is used to predict the entities contained in the target text based on the fusion features corresponding to each character, so as to obtain the target entities.
8. An entity recognition device, characterized in that, The entity recognition device includes an input interface and an output interface, and also includes: A processor, adapted to implement one or more instructions; and, A computer storage medium storing one or more instructions adapted to be loaded by the processor and executed as described in any one of claims 1-6.
9. A computer storage medium, characterized in that, The computer storage medium stores computer program instructions, which, when executed by a processor, are used to perform the entity recognition method as described in any one of claims 1-6.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, is used to load and execute the entity recognition method as described in any one of claims 1-6.
Citation Information
Patent Citations
Chinese named entity recognition method and device fusing multi-granularity information and medium
CN114781380A