Entity and intent recognition method, device, equipment, storage medium and product
By generating a latent vector sequence using a vocabulary containing feature vectors of both non-rare and rare words, the problem of inaccurate rare word recognition in existing models is solved, achieving more accurate entity and intent recognition.
Patent Information
- Application Number
- CN202211167620.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-23
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2042-09-23
AI Technical Summary
Existing recognition models struggle to cover all entity words, leading to inaccurate entity and intent recognition results, particularly with a high error rate for rare words.
The system employs a first vocabulary containing non-rare words and a second vocabulary containing rare words and their corresponding entity categories as feature vector representations. By acquiring the feature vectors of words and characters, a latent vector sequence is generated for entity and intent recognition.
It improves the accuracy of entity and intent recognition, enabling more comprehensive recognition of words in text, especially rare words, thus enhancing the accuracy of the recognition results.
Smart Images

Figure CN117009470B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, device, storage medium, and product for identifying entities and intentions. Background Technology
[0002] In intelligent question-answering systems, entity recognition and intent recognition are crucial for accurate question answers. These are typically implemented using recognition models. However, because it's difficult for recognition models to cover all entity words, and given the broad range of entity words, these models are generally trained on common ones. This leads to recognition errors when the text contains entity words not trained on by the model, resulting in inaccurate entity and intent recognition results. Summary of the Invention
[0003] This application provides a method, apparatus, device, storage medium, and product for identifying entities and intentions, which can improve the accuracy of entity and intention recognition. The technical solution is as follows:
[0004] On the one hand, a method for identifying entities and intentions is provided, the method comprising:
[0005] Based on a first vocabulary and a second vocabulary, multiple words in the text are identified. The first vocabulary includes multiple non-rare words, and the second vocabulary includes multiple rare words and the entity categories to which the multiple rare words belong.
[0006] Obtain the feature vectors of the plurality of words, wherein the feature vectors of rare words among the plurality of words are represented based on the feature vectors of the entity categories to which the rare words belong;
[0007] Obtain the feature vectors of multiple characters in the text;
[0008] Based on the feature vectors of the multiple words and the feature vectors of the multiple characters, a latent vector sequence of the text is obtained. The latent vector sequence includes the latent vector sequence of characters and the latent vector sequence of words. The latent vector sequence of characters includes the latent vectors of the multiple characters, and the latent vector sequence of words includes the latent vectors of the multiple words.
[0009] Based on the latent vector sequence of the characters in the latent vector sequence, entity recognition is performed on the text to obtain entity recognition results;
[0010] Based on the latent vector sequence, intent recognition is performed on the text to obtain intent recognition results.
[0011] On the other hand, an entity and intent identification device is provided, the device comprising:
[0012] A word determination module is used to determine multiple words in a text based on a first vocabulary and a second vocabulary. The first vocabulary includes multiple non-rare words, and the second vocabulary includes multiple rare words and the entity categories to which the multiple rare words belong.
[0013] The feature vector acquisition module is used to acquire the feature vectors of the plurality of words, wherein the feature vectors of rare words among the plurality of words are based on the feature vector representation of the entity category to which the rare words belong;
[0014] The feature vector acquisition module is also used to acquire feature vectors of multiple characters in the text;
[0015] The latent vector sequence determination module is used to obtain the latent vector sequence of the text based on the feature vectors of the multiple words and the feature vectors of the multiple characters. The latent vector sequence includes the latent vector sequence of characters and the latent vector sequence of words. The latent vector sequence of characters includes the latent vectors of the multiple characters, and the latent vector sequence of words includes the latent vectors of the multiple words.
[0016] An entity recognition module is used to perform entity recognition on the text based on the latent vector sequence of the characters in the latent vector sequence, and obtain entity recognition results;
[0017] The intent recognition module is used to perform intent recognition on the text based on the latent vector sequence to obtain the intent recognition result.
[0018] In some embodiments, the entity recognition result and the intent recognition result are obtained based on a target recognition model, which includes an input module, an encoding module, an entity recognition module, and an intent recognition module.
[0019] The feature vector acquisition module is used to input the text into the input module of the target recognition model, and obtain the feature vectors of the multiple characters and the feature vectors of the multiple words through the input module;
[0020] The latent vector sequence determination module is used to input the feature vectors of the multiple characters and the feature vectors of the multiple words into the encoding module, and to extract attention features from the feature vectors of the multiple characters and the feature vectors of the multiple words through the encoding module to obtain the latent vector sequence;
[0021] The entity recognition module is used to input the latent vector sequence of the character into the entity recognition module, and obtain the entity recognition result through the entity recognition module;
[0022] The intent recognition module is used to input the latent vector sequence into the intent recognition module and obtain the intent recognition result through the intent recognition module.
[0023] In some embodiments, the feature vector acquisition module is configured to:
[0024] The feature vectors of the multiple characters and the feature vectors of the multiple words are input into the encoding module;
[0025] The encoding module performs a linear transformation on the first feature matrix to obtain the second feature matrix, where each row vector in the first feature matrix is a feature vector of a character or a feature vector of a word.
[0026] Based on multiple row vectors in the first feature matrix, a weight matrix is obtained, where each element in the weight matrix represents the degree of correlation between two row vectors in the first feature matrix.
[0027] The weight matrix is activated, and the latent vector sequence is obtained based on the activated weight matrix and the second feature matrix.
[0028] In some embodiments, the weight matrix includes multiple elements, and the feature vector acquisition module is configured to:
[0029] Obtain a first position and a second position, where the first position is the position of the word or phrase indicated by the i-th row vector in the first feature matrix in the text, and the second position is the position of the word or phrase indicated by the j-th row vector in the second feature matrix in the text, where i and j are integers greater than 0;
[0030] Determine the position vector based on the position difference between the first position and the second position;
[0031] The i-th row vector, the j-th row vector, and the position vector are fused to obtain the element in the i-th row and j-th column of the weight matrix.
[0032] In some embodiments, the entity recognition result is a target label sequence of the text, the target label sequence including category labels of the plurality of characters, and the category label of each character is used to represent the entity category of the target word in which the character is located and the position of the character in the target word;
[0033] The entity recognition module is used to input the latent vector sequence of the character into the entity recognition module;
[0034] Through the entity recognition module, for any one of the plurality of characters, based on the latent vector of the character and the preset category label of the character with a preset position difference from the character, the degree parameter of the character being labeled as multiple preset category labels is determined. The degree parameter of each preset category label is used to indicate the appropriateness of the character being labeled as the preset category label.
[0035] Based on the degree parameters of the multiple words being labeled as the multiple preset category labels and multiple candidate label sequences, the probabilities of the multiple candidate label sequences are determined respectively, and the multiple candidate label sequences are obtained based on the combination of the multiple preset category labels;
[0036] The candidate label sequence with the highest probability among the multiple candidate label sequences is output as the target label sequence.
[0037] In some embodiments, the intent recognition result includes probabilities of multiple intent categories, and the intent recognition module is configured to:
[0038] The hidden vector sequence is input into the intent recognition module;
[0039] The intent recognition module determines multiple target preset category labels from a variety of preset category labels. Each preset category label indicates the entity category of the target word in which the labeled character is located and the position of the character in the target word. The target preset category label indicates that the labeled character is located at the beginning of the target word.
[0040] For each of the multiple target preset category labels, based on the latent vectors of the multiple characters, determine the probability that each character is labeled as the target preset category label;
[0041] Based on the probability that each of the multiple characters is labeled as the target preset category label, the probability that the target preset category label is labeled in the text is determined;
[0042] A first probability vector is determined based on the probability that the various target preset category labels are labeled in the text;
[0043] Attention features are extracted from the latent vector sequence to obtain the attention vector;
[0044] The first probability vector and the attention vector are fused to obtain a second probability vector, which includes probabilities of multiple intent categories.
[0045] In some embodiments, the intent recognition module is configured to, for each of the plurality of characters, determine the probability that the character is labeled as the target preset category label based on the latent vector of the character and the target model parameters, wherein the target model parameters are model parameters obtained from the entity recognition module for determining the probability that the character is labeled as any preset category label.
[0046] In some embodiments, the intent recognition module is configured to:
[0047] A linear transformation is performed on the first latent vector matrix to obtain a second latent vector matrix, where each row vector in the first latent vector matrix is a latent vector in the latent vector sequence.
[0048] Based on multiple row vectors in the first latent vector matrix, a weight vector is obtained, where each element in the weight vector represents the importance of a row vector in the first latent vector matrix.
[0049] The weight vector is activated, and the attention vector is obtained based on the activated weight vector and the second latent vector matrix.
[0050] In some embodiments, the apparatus further includes a training module for:
[0051] The training samples are input into the target recognition model, and the predicted entity recognition result is obtained through the entity recognition module. Based on the predicted entity recognition result and the real entity recognition result, a first loss value is determined. The first loss value represents the difference between the predicted entity recognition result and the real entity recognition result.
[0052] The intent recognition module obtains a predicted intent recognition result. Based on the predicted intent recognition result and the actual intent recognition result, a second loss value is determined. The second loss value represents the difference between the predicted intent recognition result and the actual intent recognition result.
[0053] The first loss value and the second loss value are weighted and summed to obtain the third loss value;
[0054] The model parameters of the target recognition model are adjusted based on the third loss value.
[0055] On the other hand, a computer device is provided, the computer device including a processor and a memory, the memory being used to store at least one computer program, the at least one computer program being loaded and executed by the processor to implement the entity and intent identification method in the embodiments of this application.
[0056] On the other hand, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, the at least one computer program being loaded and executed by a processor to implement the entity and intent identification method as described in the embodiments of this application.
[0057] On the other hand, a computer program product is provided, the computer program product including computer program code stored in a computer-readable storage medium, a processor of a computer device reading the computer program code from the computer-readable storage medium, the processor executing the computer program code, causing the computer device to perform the entity and intent identification method described in any of the above implementations.
[0058] This application provides a method for entity and intent recognition. Because this method identifies multiple words in a text based on a first vocabulary list including non-rare words and a second vocabulary list including rare words, it can also identify rare words in the text, making the identified words more comprehensive. Furthermore, it represents the feature vector of a rare word based on the feature vector of the entity category to which the rare word belongs, thereby obtaining relevant information about the rare word. This leads to more accurate recognition results when performing entity and intent recognition, thus improving the accuracy of entity and intent recognition. Attached Figure Description
[0059] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying 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.
[0060] Figure 1 This is a schematic diagram of an implementation environment provided in an embodiment of this application;
[0061] Figure 2 This is a flowchart illustrating an entity and intent identification method provided in an embodiment of this application;
[0062] Figure 3 This is a flowchart of another entity and intent identification method provided in the embodiments of this application;
[0063] Figure 4 This is a schematic diagram of a target recognition model provided in an embodiment of this application;
[0064] Figure 5 This is a schematic diagram of an interface for an application scenario provided in an embodiment of this application;
[0065] Figure 6 This is a block diagram of an entity and intent identification device provided in an embodiment of this application;
[0066] Figure 7 This is a block diagram of a terminal provided in an embodiment of this application;
[0067] Figure 8This is a block diagram of a server provided in an embodiment of this application. Detailed Implementation
[0068] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0069] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items with essentially the same function. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor are there any restrictions on quantity or execution order.
[0070] In this application, the term "at least one" means one or more, and "multiple" means two or more.
[0071] It should be noted that all information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this application have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the texts involved in this application were all obtained with full authorization.
[0072] The following is an explanation of the terms used in this application.
[0073] 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.
[0074] 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, speech processing, natural language processing, and machine learning / deep learning.
[0075] 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 relationship with linguistic research. NLP techniques typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs.
[0076] Machine learning (ML) is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence; its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learn-by-doing.
[0077] The following describes the implementation environment involved in this application:
[0078] The entity and intent identification method provided in this application can be executed by a computer device. In some embodiments, the computer device is at least one of a terminal and a server. The following is a schematic diagram illustrating the implementation environment of the entity and intent identification method provided in this application. See also... Figure 1 The implementation environment includes terminal 101 and server 102. Terminal 101 and server 102 can be connected directly or indirectly via wired or wireless communication, which is not limited herein.
[0079] In some embodiments, a target application is installed on the terminal 101. This target application can be an application for intelligent question answering. After the terminal 101 obtains the input text containing the question, it sends it to the server 102. The server 102 is the backend server of the target application. The server 102 is used to perform entity and intent recognition on the text, and then obtain the pre-configured corresponding answer based on the entity recognition result and intent recognition result, and send it to the terminal 101 for display.
[0080] In some embodiments, after the terminal 101 obtains the input text containing the question, the terminal 101 performs entity and intent recognition on the text, and then sends the entity recognition result and intent recognition result to the server 102. The server 102 obtains the pre-configured corresponding answer based on the entity recognition result and intent recognition result, and sends it to the terminal 101 for display.
[0081] In some embodiments, after the terminal 101 obtains the input text containing the question, the terminal 101 performs entity and intent recognition on the text, and then obtains the pre-configured corresponding answer based on the entity recognition result and intent recognition result, and then displays it.
[0082] The method provided in this application embodiment can be applied to the search field, where location search, weather search, etc. can be performed, that is, the method provided in this application embodiment provides search services in the search field.
[0083] In some embodiments, terminal 101 may be a smartphone, tablet, laptop, desktop computer, smart voice interaction device, smart home appliance, vehicle terminal, aircraft, etc., but is not limited thereto. In some embodiments, server 102 may be an independent server, a server cluster or distributed system composed of multiple servers, or a cloud server that provides 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, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Server 102 is used to provide background services for the target application installed on terminal 101. In some embodiments, server 102 mainly undertakes computing work, and terminal 101 undertakes secondary computing work; or, server 102 undertakes secondary computing services, and terminal 101 undertakes primary computing work; or, server 102 and terminal 101 collaborate on computing using a distributed computing architecture.
[0084] Figure 2 This is a flowchart of an entity and intent identification method provided according to an embodiment of this application. See also... Figure 2 In this embodiment of the application, the method is described using a computer device as an example. The method includes the following steps:
[0085] 201. A computer device determines multiple words in a text based on a first vocabulary and a second vocabulary, wherein the first vocabulary includes multiple non-rare words and the second vocabulary includes multiple rare words and the entity categories to which the multiple rare words belong.
[0086] In this embodiment of the application, the text is the text of the entity and intent to be identified. The text can be a word, a sentence or a paragraph, and the text can be the text containing a question, so as to obtain the answer to the question contained in the text based on the entity recognition result and intent recognition result of the text.
[0087] In this embodiment of the application, non-rare words are words whose usage frequency is greater than a preset usage frequency, and rare words are words whose usage frequency is not greater than a preset usage frequency. For example, the first vocabulary includes non-rare words such as "today," "a little," and "eating." The second vocabulary includes rare words such as "photophobia (symptom)," "phallic speech (symptom)," and "conjugated teeth (disease)," as well as entity categories of rare words.
[0088] In the embodiments of this application, the multiple rare words are rare words in at least one field; for example, the multiple rare words are all rare words in the medical field, or the multiple rare words are rare words in multiple fields such as medical, agricultural, and educational fields.
[0089] 202. The computer device acquires the feature vectors of multiple words, and the feature vectors of rare words among the multiple words are represented by the feature vectors of the entity categories to which the rare words belong.
[0090] In this embodiment, the feature vector of the entity category to which the rare word belongs is used to represent the entity category to which the rare word belongs, and it can effectively characterize the rare word. The feature vector of the non-rare word among multiple words is determined based on the feature vector of the non-rare word, and the feature vector of the non-rare word is used to represent the non-rare word.
[0091] 203. Computer devices acquire feature vectors of multiple characters in a text.
[0092] In the embodiments of this application, the feature vector of each character is used to represent the character.
[0093] 204. The computer device obtains a latent vector sequence of text based on the feature vectors of multiple words and the feature vectors of multiple characters. The latent vector sequence includes the latent vector sequence of characters and the latent vector sequence of words. The latent vector sequence of characters includes the latent vectors of multiple characters, and the latent vector sequence of words includes the latent vectors of multiple words.
[0094] In this embodiment, the latent vectors of multiple characters are arranged sequentially to form a latent vector sequence for characters, and the latent vectors of multiple words are arranged sequentially to form a latent vector sequence for words. The latent vector of a character is used to represent the character, and the latent vector of a word is used to represent the word.
[0095] 205. Computer equipment performs entity recognition on text based on the latent vector sequence of characters in the latent vector sequence, and obtains entity recognition results.
[0096] In this embodiment of the application, the entity recognition result is used to indicate which entity categories each word in the text belongs to.
[0097] 206. Computer devices perform intent recognition on text based on latent vector sequences to obtain intent recognition results.
[0098] In this embodiment of the application, the intent recognition result is used to indicate which intent categories the text belongs to.
[0099] This application provides a method for entity and intent recognition. Because this method identifies multiple words in a text based on a first vocabulary list including non-rare words and a second vocabulary list including rare words, it can also identify rare words in the text, making the identified words more comprehensive. Furthermore, it represents the feature vector of a rare word based on the feature vector of the entity category to which the rare word belongs, thereby obtaining relevant information about the rare word. This leads to more accurate recognition results when performing entity and intent recognition, thus improving the accuracy of entity and intent recognition.
[0100] The above Figure 2 The basic flow of the entity and intent identification method provided in the embodiments of this application is as follows: Figure 3 The methods for identifying entities and intentions are further elaborated. Figure 3 This is a flowchart of an entity and intent identification method provided according to an embodiment of this application. In this embodiment, using... Figure 4 Taking the target recognition model shown as an example, we can obtain entity recognition results and intent recognition results. The target recognition model includes an input module 401, an encoding module 402, an entity recognition module 403, and an intent recognition module 404.
[0101] First see Figure 3 In this embodiment, the method is described using an example executed by a computer device. The method includes the following steps:
[0102] 301. The computer device inputs text into the input module of the target recognition model, and through this input module, obtains feature vectors of multiple characters and feature vectors of multiple words.
[0103] In this embodiment of the application, after the computer device inputs text into the target recognition model, it needs to first determine multiple words in the text. Accordingly, the process by which the computer device inputs text into the input module of the target recognition model and obtains feature vectors of multiple characters and multiple words through the input module includes the following steps: the computer device inputs text into the input module of the target recognition model, and through the input module, based on a first vocabulary and a second vocabulary, determines multiple words in the text, and obtains feature vectors of the multiple words and feature vectors of the multiple characters in the text.
[0104] In this embodiment, because a first vocabulary list and a second vocabulary list are set, any word in either the first or second vocabulary list can be identified as long as it appears in the input text, ensuring the comprehensiveness of the words identified in the text. For example, in the input text "Today I'm a little afraid of light," the words "today," "a little," and "afraid of light" are words in the first and second vocabulary lists, respectively, and therefore they are identified as words in the text.
[0105] In some embodiments, the computer device sets up a word vector table in the input module to determine the feature vectors of multiple words based on the word vector table. Accordingly, the process by which the computer device obtains the feature vectors of multiple words through the input module includes: the computer device querying the feature vectors of multiple words from the word vector table through the input module, the word vector table including the feature vectors of multiple non-rare words and the feature vectors of the entity categories to which multiple rare words belong.
[0106] For each entity category, rare words within that category share a single feature vector. For example, for the entity category "symptom," rare words belonging to that symptom category share a single feature vector; such as "photophobia" and "phantom speech," these rare words are represented using the feature vector for the symptom category. Similarly, for the entity category "disease," rare words belonging to that disease category share a single feature vector; such as "glass opacity" or "glass canine dislocation," these rare words are represented using the feature vector for the disease category.
[0107] In some embodiments, rare words may not be categorized into a particular entity category. Optionally, these uncategorized rare words can be uniformly represented by a common feature vector, which indicates that the rare word cannot be categorized into an entity category. In this embodiment, by setting a word vector table, the efficiency of obtaining feature vectors for multiple words is improved. Furthermore, by representing the feature vectors of rare words based on the feature vectors of their respective entity categories, relevant information about rare words in the text can also be obtained.
[0108] In this embodiment, the feature vectors in the word vector table are organized into a matrix form, making them part of the target recognition model and participating in model training, so as to determine the feature vectors of multiple words through the input module.
[0109] In this embodiment, the determination of whether a word is a rare word is based on its usage frequency. Optionally, the determination of whether a word is a rare word is based on the number of times it appears in the training sample set, which represents its usage frequency. For example, if its occurrence frequency is greater than a preset fixed threshold, it is determined to be a non-rare word; if its occurrence frequency is not greater than the preset fixed threshold, it is determined to be a rare word. The training sample set is used to train the target recognition model, and it includes multiple training samples, each of which is a text. In this embodiment, rare and non-rare words are determined based on the training sample set, thereby making the determined rare and non-rare words more closely matched with the target recognition model.
[0110] In this embodiment, the first lexicon includes multiple non-rare words, the second lexicon includes multiple rare words and their entity categories, and the word vector table includes feature vectors of non-rare words and feature vectors of the entity categories to which rare words belong. By using the word vector table to obtain word feature vectors, the target recognition model can effectively utilize both the lexicon and the word vector table. Even if the text contains entity words that rarely or never appear in the training data, as long as the word can be found in the second lexicon, the target recognition model can obtain the corresponding information from the word vector table, thus achieving more accurate recognition results when performing entity and intent recognition. Furthermore, since rare words of the same entity category share a single feature vector, new rare words can be dynamically added to the second lexicon after model training. These new rare words can be represented using the already trained feature vectors of their respective entity categories without retraining the entire model, thereby improving the flexibility and convenience of updating the model.
[0111] In some embodiments, the computer device sets up a character vector table in the input module and determines the feature vectors of multiple characters based on the character vector table. Accordingly, the process by which the computer device obtains the feature vectors of multiple characters in text includes the following steps: the computer device converts the text into a sequence of characters, queries the character vector table for the feature vector of each character in the sequence, and thus obtains the feature vectors of multiple characters, wherein the character vector table includes the feature vectors of multiple characters.
[0112] In this embodiment, the feature vectors in both the character vector table and the word vector table are pre-trained feature vectors, and any feature vector can be a vector obtained through embedding. By setting up character vector tables and word vector tables, the efficiency of obtaining feature vectors is improved, thereby enhancing recognition efficiency.
[0113] 302. The computer device inputs the feature vectors of multiple characters and multiple words into the encoding module. The encoding module performs attention feature extraction on the feature vectors of multiple characters and multiple words to obtain a hidden vector sequence.
[0114] In this embodiment of the application, the computer device inputs the feature vectors of multiple characters and the feature vectors of multiple words into the encoding module, and performs attention feature extraction on the feature vectors of multiple characters and the feature vectors of multiple words through the encoding module to obtain the latent vector sequence, including the following steps A1-A3.
[0115] A1: The computer device inputs the feature vectors of multiple characters and the feature vectors of multiple words into the encoding module; through the encoding module, the first feature matrix is linearly transformed to obtain the second feature matrix, where each row vector in the first feature matrix is a feature vector of a character or a feature vector of a word.
[0116] In this embodiment of the application, the first feature matrix is represented as X. n1 represents the number of rows in the first characteristic matrix, d1 represents the number of columns in the first characteristic matrix, and R represents a real number.
[0117] In some embodiments, the computer device performs a linear transformation on the first feature matrix through an encoding module, which is achieved by the following formula (1).
[0118] V1 = XW v (1);
[0119] Where V1 represents the second characteristic matrix, X represents the first characteristic matrix, and W... v This represents the model parameters for the linear transformation.
[0120] In this embodiment, the feature vectors of multiple characters and multiple words are used as inputs to the encoding module, which effectively addresses the situation that a sentence in Chinese may have multiple word combinations, thereby obtaining a more comprehensive and accurate latent vector sequence.
[0121] A2: The computer device obtains a weight matrix based on multiple row vectors in the first feature matrix through the encoding module. Each element in the weight matrix represents the degree of correlation between two row vectors in the first feature matrix.
[0122] In the embodiments of the present application, each element in the weight matrix is obtained not only based on the row vector in the first feature matrix, but also based on the positions of characters and words in the text. Correspondingly, the process of determining the element located at the i-th row and the j-th column in the weight matrix includes the following steps: the computer device acquires a first position and a second position, where the first position is the position of the character or word indicated by the i-th row vector in the first feature matrix in the text, and the second position is the position of the character or word indicated by the j-th row vector in the second feature matrix in the text, and i and j are integers greater than 0; a position vector is determined based on the position difference between the first position and the second position; the computer device fuses the i-th row vector, the j-th row vector, and the position vector to obtain the element located at the i-th row and the j-th column in the weight matrix. In the embodiments of the present application, since the elements in the weight matrix are also determined based on the positions of characters and words in the text, the information represented by the elements is richer and more comprehensive.
[0123] In the embodiments of the present application, the first position and the second position each include the starting position of the character or word indicated by the vector in the text and the ending position of the character or word indicated by the vector in the text. For example, in the text "Today is a bit photophobic", the starting position of "photophobia" is 5, and the ending position is 6. Correspondingly, the position difference between the first position and the second position includes the position difference of the starting positions and the position difference of the ending positions.
[0124] In the embodiment of the present application, the computer device extracts the positions of each character and word in the text through the input module, and then inputs them into the encoding module. The encoding module acquires the first position and the second position from the positions of the multiple characters and the multiple words. For example, continue to refer to Figure 1 , the input module extracts the starting position and the ending position of each sub-character and word in the text "Today is a bit photophobic", and inputs them into the encoding module together with the feature vectors of the multiple characters and the feature vectors of the multiple words. In this way, by extracting the positions of characters or words through the input module, preprocessing of characters or words is realized, thereby improving the data processing efficiency in the encoding module.
[0125] In some embodiments, the computer device determines the position vector through the encoding module based on the position difference between the first position and the second position, which is implemented by the following formula (2).
[0126]
[0127] where R ij represents the position vector obtained based on the i-th row vector and the j-th row vector in the first feature matrix, L i represents the starting position in the first position, L j represents the starting position in the second position, R i represents the ending position in the first position, R j represents the ending position in the second position, Wr These represent the model parameters that determine the position vector. The symbol represents vector concatenation, PE means converting a position difference into a vector, and ReLU means a non-linear function used to obtain the position vector.
[0128] In some embodiments, PE converts a position difference into a vector using the following formula (3).
[0129]
[0130] Where x represents the position difference, d2 represents the dimension of the transformed vector, and PE 2k PE represents the 2kth element in the transformed vector. 2k+1 This represents the (2k+1)th element in the transformed vector.
[0131] In some embodiments, the computer device described above fuses the i-th row vector, the j-th row vector, and the position vector through an encoding module to obtain the element located in the i-th row and j-th column of the weight matrix, which is achieved by the following formula (4):
[0132]
[0133] Among them, A ij X represents the element located in the i-th row and j-th column of the weight matrix. i Let X represent the i-th row vector. j Let R represent the j-th row vector. ij T represents the position vector, and W represents the transpose of the vector or matrix. v W q W k,R W k,E u and v represent the model parameters that determine the elements in the weight matrix.
[0134] In this embodiment, each element in the weight matrix represents the degree of correlation between two row vectors in the first feature matrix, which can be the magnitude of the influence of one vector on another. For example, for element A... ij Then, we can represent the influence of the j-th row vector on the i-th row vector.
[0135] A3: The computer device activates the weight matrix through the encoding module, and obtains the latent vector sequence based on the activated weight matrix and the second feature matrix.
[0136] In some embodiments, the computer device activates the weight matrix through an encoding module, and obtains a latent vector sequence based on the activated weight matrix and the second feature matrix, which is achieved by the following formula (5).
[0137] H = softmax(A)V1 (5);
[0138] Where H represents the matrix formed by the sequence of latent vectors, each latent vector in the sequence of latent vectors is a row vector in the matrix, softmax represents the activation function, A represents the weight matrix, and V1 represents the second feature matrix.
[0139] Steps A1-A3 above are illustrated using a single-head attention mechanism to obtain the latent vector sequence as an example. In other embodiments, the encoding module obtains the latent vector sequence based on a multi-head attention mechanism. The encoding module includes an attention mechanism submodule, which contains multi-head attention units. Accordingly, the computer device inputs the feature vectors of multiple characters and multiple words into the attention mechanism submodule of the encoding module. Through the multi-head attention units in the attention mechanism submodule, the latent vector sequence output by each attention unit is obtained. Then, based on the latent vector sequences output by the multi-head attention units, the latent vector sequence of the text is obtained. The attention mechanism submodule is used to concatenate the latent vector sequences output by the multi-head attention units to obtain the latent vector sequence of the text.
[0140] For example, the latent vector sequence of text is represented as H. n2 represents the number of rows in the latent vector sequence of the text, d3 represents the number of columns in the latent vector sequence of the text, and the latent vector sequence output by each attention unit is represented as H′. m*d4 = d3, the number of rows of the latent vector sequence output by each attention unit is equal to the number of rows of the latent vector sequence of the text, d4 represents the number of columns of the latent vector sequence output by each attention unit, m represents the number of multi-head attention units, and H is the final output of the attention mechanism submodule.
[0141] In this embodiment of the application, a multi-head attention mechanism is used to chain together the independent attention outputs of multiple heads. That is, the multi-head attention unit allows attention operations with different focuses to be performed on different parts of the first feature matrix, thereby improving the accuracy of the determined latent vector sequence.
[0142] In some embodiments, the encoding module employs a Transformer Encoder (Chinese encoder) model for attention feature extraction, such as the structure of the Flat-Lattice Transformer (a Chinese entity recognition model). Accordingly, each word list and vector table in this embodiment corresponds to a Chinese character or word, thus optimizing the recognition of rare words in Chinese. Furthermore, recognition is based on the Transformer Encoder model, a small neural network model with few parameters, offering advantages such as low memory footprint and fast recognition speed.
[0143] In this embodiment, attention features are extracted from the feature vectors of characters and words in the text to obtain a latent vector sequence, which enables the latent vector sequence to more accurately represent the characters and words in the text.
[0144] 303. The computer device inputs the latent vector sequence of the character into the entity recognition module, and obtains the entity recognition result through the entity recognition module.
[0145] In this embodiment, the entity recognition result is a target label sequence of text. This target label sequence includes category labels for multiple characters, where each character's category label represents the entity category of the target word and the character's position within the target word. Accordingly, the computer device inputs the latent vector sequence of the characters into the entity recognition module, and the process of obtaining the entity recognition result through this module includes the following steps B1-B3.
[0146] B1: The computer device inputs the latent vector sequence of the characters into the entity recognition module. Through the entity recognition module, for any one of the multiple characters, based on the latent vector of the character and the preset category label of the character with a preset position difference from the character, the degree parameter of the character being labeled as a variety of preset category labels is determined. The degree parameter of each preset category label is used to indicate the appropriateness of the character being labeled as that preset category label.
[0147] In this embodiment, the entity recognition module uses a Conditional Random Fields (CRF) model to label the text. Accordingly, the category labels are BIO (beginning, inside, outside) labels, including Bt, It, and O labels. A character labeled Bt indicates that the target word belongs to entity category t, and the character is at the beginning of the target word. A character labeled It indicates that the target word belongs to entity category t, and the character is not at the beginning of the target word. A character labeled O indicates that the character does not belong to any entity category. For example, see [link to example]. Figure 1 The entity recognition module labels each character in the text "Today I'm a little afraid of light" with category labels B-time, I-time, O, O, B-symptom, and I-symptom.
[0148] In this embodiment of the application, the latent vector sequence of the word is represented as follows: Each represents a latent vector of a character, n c The number of characters. The target label sequence is represented as follows: Each of these is a preset category label representing a single character.
[0149] In this embodiment, the character with a preset position difference from the character can be at least one of the following: a character that precedes the character and has a position difference of one, a character that has a position difference of two, or a character that has a position difference of three. In this embodiment, the example of a character with a preset position difference from the character being a character that precedes the character and has a position difference of one is used for illustration.
[0150] Accordingly, the computer device, through the entity recognition module, determines the degree parameter of whether a character is labeled with multiple preset category labels based on the latent vector of the character and the preset category label of the character with a preset position difference from the character, through the following formula (6).
[0151] f(y,y′,h)=exp(U y,y′ +W y h+b y (6);
[0152] Where h represents the latent vector of a character, y′ represents the category label of the first character, y represents the predefined category label of the second character, and U y,y′ W represents the transformation parameter from the preset category label y to the preset category label y′. y and b yLet f(y,y′,h) represent the weight vector and bias of the corresponding category label y. f(y,y′,h) indicates the appropriateness of labeling the current character with the preset category label y, given that the latent vector of the current character is h and the preset category label of the previous character is y′. Specifically, if any character is the first character in the text, the preset category label of its preceding character is a fixed, easily calculated starting category label y0.
[0153] B2: The computer device uses an entity recognition module to determine the probability of multiple candidate label sequences based on the degree parameters of multiple characters being labeled with multiple preset category labels and multiple candidate label sequences. The multiple candidate label sequences are obtained based on the combination of multiple preset category labels.
[0154] In some embodiments, the probability of a candidate label sequence represents the likelihood that it is a true label sequence of text. The probability of each candidate label sequence is obtained by multiplying the degree parameters of multiple characters being labeled as preset category labels in that candidate label sequence. Accordingly, the process of determining the probability of each candidate label sequence includes the following steps: the computer device, through an entity recognition module, multiplies the degree parameters of multiple characters being labeled as preset category labels in the candidate label sequence, and uses the product value as the probability of that candidate label sequence, thus improving the rationality and convenience of determining the probability of candidate label sequences.
[0155] In some embodiments, for each candidate label sequence, the probability of the candidate label sequence is determined based on the following formula (7).
[0156]
[0157] Wherein, p(y|H c f(y) represents the probability of the candidate label sequence y. i ,y i-1 ,h i ) represents the degree to which the i-th character in the text is labeled with a certain preset category label.
[0158] In this embodiment, the multiple candidate label sequences can be predetermined, and the number of preset category labels in the multiple candidate label sequences can correspond to different text lengths. Accordingly, the computer device can select a candidate label sequence from the multiple candidate label sequences that corresponds to the number of characters in the text to be recognized, and perform entity recognition based on the selected candidate label sequence. This reduces the range of candidate label sequences and thus improves the efficiency of entity recognition.
[0159] B3: The computer device uses an entity recognition module to output the candidate label sequence with the highest probability from multiple candidate label sequences as the target label sequence.
[0160] It should be noted that since words in text are generally composed of multiple characters, the preset category labels of these characters are usually matched. Therefore, multiple preset category labels generally appear in pairs, forming category label pairs. For example, for the word "today," the preset category labels for the two characters are "B-time" and "I-time," which appear as a pair. Some category label pairs are easy to find, while others are not. Therefore, in this embodiment, the degree parameter for determining whether a character is labeled with multiple preset category labels is based on the preset category labels of the characters preceding it. This fully considers the matching between the preset category labels of the two characters, thereby improving the accuracy of the labeling and ultimately enhancing the accuracy of the determined target label sequence.
[0161] 304. The computer device inputs the latent vector sequence into the intent recognition module, and obtains the intent recognition result through the intent recognition module.
[0162] In this embodiment, the intent recognition result includes the probabilities of multiple intent categories, where the probability of each intent category representing the likelihood that the intent category is the true intent category of the text. Accordingly, the process by which the computer device inputs the latent vector sequence into the intent recognition module and obtains the intent recognition result through the intent recognition module includes the following steps C1-C6.
[0163] C1: The computer device inputs the latent vector sequence into the intent recognition module; through the intent recognition module, multiple target preset category labels are determined from the multiple preset category labels. Any preset category label indicates the entity category of the target word in which the labeled character is located and the position of the character in the target word. The target preset category label indicates that the labeled character is located at the beginning of the target word.
[0164] In this embodiment of the application, the target preset category label refers to the Bt label. The character labeled with the Bt label indicates that the target word to which the character belongs belongs to the entity category t, and the character is located at the beginning of the target word.
[0165] C2: For each of the multiple target preset category labels, the computer device, through the intent recognition module, determines the probability that each character is labeled as the target preset category label based on the latent vectors of multiple characters.
[0166] In this embodiment, the process by which the intent recognition module determines the probability that each of the multiple characters will be labeled with a target preset category label based on the latent vectors of multiple characters includes the following steps: For each of the multiple characters, the intent recognition module determines the probability that the character will be labeled with a target preset category label based on the latent vector of that character and the target model parameters. The target model parameters are model parameters obtained from the entity recognition module used to determine the probability that a character will be labeled with any preset category label. In this embodiment, since the target model parameters are obtained directly from the entity recognition module, the need to train the target model parameters in the intent recognition module is avoided, thereby improving the training efficiency of the model.
[0167] In this embodiment of the application, since determining the probability of a character being labeled as a target preset category label based on the conditional random field model is quite complex and may affect the recognition time, the probability of a character being labeled as a target preset category label is determined only based on the latent vector of the character and the target model parameters, thereby improving the recognition efficiency.
[0168] In this embodiment, since the target model parameters are obtained from the entity recognition module, and these target model parameters are used to determine the probability that a character is labeled as any preset category label, the computer device, through the intent recognition module, determines the probability that each character is labeled as a target preset category label based on the latent vector of the character and the target model parameters, which can be achieved through the following (8).
[0169]
[0170] in, h represents the probability that a word is labeled as a target preset category label. i W represents the latent vector of the i-th character. y and b y This represents the target model parameters, and W in formula (6) y and b i same.
[0171] C3: The computer device, through the intent recognition module, determines the probability that the target's preset category label is labeled in the text based on the probability that multiple words are respectively labeled as the target's preset category label.
[0172] In this embodiment of the application, the computer device determines the probability that the target preset category label is labeled in the text based on the probability that multiple words are respectively labeled as the target preset category label by the intent recognition module, and implements it based on the following formula (9).
[0173] P(t) = 1 - π i (1-p i (9);
[0174] Where P(t) represents the probability that the target preset category label is labeled in the text, p i This indicates the probability that a word will be labeled as a target preset category label.
[0175] C4: The computer device determines the first probability vector based on the probability that multiple target preset category labels are labeled in the text through the intent recognition module.
[0176] In this embodiment of the application, each element in the first probability vector represents the probability that a target preset category label is labeled in the text.
[0177] In this embodiment of the application, the computer device uses an intent recognition module to compose the probability of each target's preset category label being marked in the text into a vector form, thus obtaining a first probability vector.
[0178] C5: The computer device extracts attention features from the latent vector sequence through the intent recognition module to obtain the attention vector.
[0179] In this embodiment, the intent recognition module obtains the attention vector based on an attention mechanism. Accordingly, the computer device extracts attention features from the latent vector sequence through the intent recognition module to obtain the attention vector, including the following steps: the computer device performs a linear transformation on the first latent vector matrix through the intent recognition module to obtain a second latent vector matrix, where each row vector in the first latent vector matrix is a latent vector in the latent vector sequence; the computer device obtains a weight vector based on multiple row vectors in the first latent vector matrix through the intent recognition module, where each element in the weight vector represents the importance of a row vector in the first latent vector matrix; the computer device performs activation processing on the weight vector through the intent recognition module, and obtains the attention vector based on the activated weight vector and the second latent vector matrix.
[0180] The intent recognition module includes an attention mechanism submodule. The computer device inputs the latent vector sequence into the attention mechanism submodule, and the attention vector is obtained through the attention mechanism submodule.
[0181] In some embodiments, the computer device performs a linear transformation on the first latent vector matrix through the intent recognition module to obtain the second latent vector matrix, which is achieved by the following formula (10).
[0182] V2 = HW ID,v (10);
[0183] Where V2 represents the second implicit vector matrix, H represents the first implicit vector matrix, and W... ID,v This represents the model parameters for the linear transformation.
[0184] In some embodiments, each element in the weight vector is obtained by the following formula (11).
[0185]
[0186] Among them, a i H represents the i-th element in the weight matrix. i W represents the i-th row vector in the first implicit vector matrix. ID,q W ID,k W ID,v u ID Represents the trainable model parameters, which can be a matrix or a vector.
[0187] In some embodiments, the computer device activates the weight vector through the intent recognition module, and obtains the attention vector based on the activated weight vector and the second latent vector matrix, which is achieved by the following formula (12).
[0188] h = softmax(a)V2 (12);
[0189] Where h represents the attention vector, a represents the weight vector, softmax represents the activation function, and V2 represents the second hidden vector matrix.
[0190] In the embodiments of this application, the above steps are described using a single-layer structure for the attention mechanism submodule as an example. In other embodiments, the attention mechanism submodule is a multi-layer structure. For each layer, the output of the previous layer is used as the input of that layer to obtain the attention vector of that layer, until the attention vector is output through the last layer. For example, z in formula (11) is the vector output by the previous layer. For the first layer in the multi-layer structure, z is a randomly initialized vector.
[0191] In some embodiments, the intent recognition module obtains the attention vector based on a multi-head attention mechanism. Accordingly, the computer device inputs the latent vector sequence into the attention mechanism submodule of the intent recognition module. Through the multi-head attention units within the attention mechanism submodule, the attention vector output by each attention unit is obtained. Based on the attention vectors output by the multi-head attention units, the attention vector of the text is obtained. Specifically, the attention mechanism submodule is used to concatenate the attention vectors output by the multi-head attention units to obtain the attention vector of the text.
[0192] In this embodiment of the application, a multi-head attention mechanism is used to chain together the independent attention outputs of multiple heads. That is, the multi-head attention unit allows attention operations with different focuses to be performed on different parts of the latent vector sequence, thereby improving the accuracy of the determined attention vector.
[0193] C6: The computer device fuses the first probability vector and the attention vector through the intent recognition module to obtain a second probability vector, which includes the probabilities of multiple intent categories.
[0194] In some embodiments, the computer device fuses the first probability vector and the attention vector through the intent recognition module to obtain the second probability vector, which is achieved by the following formula (13).
[0195]
[0196] Where, p ID Let W represent the second probability vector, sigmoid represent the activation function, W and b represent the trainable model parameters, and h represent the second probability vector. e h represents the attention vector. p Denotes the first probability vector. The symbol represents vector concatenation.
[0197] In this embodiment, since the second probability vector is obtained based on the first probability vector and the attention vector, and the first probability vector is based on the probability that multiple characters in the text are labeled as target preset category labels, the result of entity recognition is also considered when performing intent recognition, thereby improving the accuracy of intent recognition.
[0198] In some embodiments, the intent recognition module includes a classification head submodule, which fuses the first probability vector and the attention vector to obtain a second probability vector. See also... Figure 4 The intent recognition module includes an attention mechanism submodule and a classification head submodule. The classification head submodule obtains a second probability vector based on a first probability vector and the attention vector output by the attention mechanism submodule. Optionally, the computer device can also output the intent category corresponding to the highest probability in the second probability vector to obtain the intent category to which the text most likely belongs. In the embodiments of this application, the classification head submodule can use a single-layer fully connected layer or a multilayer perceptron structure.
[0199] It should be noted that the execution order of steps 303-304 in this embodiment can vary. The step numbers are for ease of description and do not restrict the execution order. Step 303 can be executed before step 304, after step 304, or simultaneously with step 304. In this embodiment, the simultaneous execution of steps 303 and 304 is used as an example, which allows entity recognition and intent recognition to be performed simultaneously, improving recognition efficiency. Furthermore, by jointly performing entity recognition and intent recognition based on this target recognition model, only steps 301-302 need to be executed once to obtain the information required for entity recognition and intent recognition respectively, saving the cumbersome process of each module having to execute steps 301-302 separately. Moreover, the intent recognition module also utilizes some of the results of entity recognition, thereby achieving better intent recognition results.
[0200] In this embodiment, the target recognition model is trained based on multiple training samples in the training sample set. The training process of the target recognition model includes the following steps: The computer device inputs the training samples into the target recognition model, obtains the predicted entity recognition result through the entity recognition module, and determines a first loss value based on the predicted entity recognition result and the real entity recognition result. The first loss value represents the difference between the predicted entity recognition result and the real entity recognition result. The computer device obtains the predicted intent recognition result through the intent recognition module, and determines a second loss value based on the predicted intent recognition result and the real intent recognition result. The second loss value represents the difference between the predicted intent recognition result and the real intent recognition result. The computer device performs a weighted summation of the first loss value and the second loss value to obtain a third loss value. The computer device adjusts the model parameters of the target recognition model based on the third loss value.
[0201] In some embodiments, the Negative Log-Likelihood is used as the model training loss function for the entity recognition module, that is, the first loss value is obtained through this function. See formula (14) below.
[0202] L ER =-∑ x logp(y x |H c,x (14);
[0203] Among them, L ER Let x represent the first loss value, and y represent a training sample. x H represents the true label sequence of training sample x. c,x This represents the hidden vector sequence of words in the training sample x.
[0204] In some embodiments, Binary Cross Entropy is used as the model training loss function for the intent recognition module, that is, the second loss value is obtained through this function. See formula (15) below.
[0205] L ID =∑ x ∑ y y x logp ID (x,y)+(1-y x log(1-p) ID (x,y)) (15);
[0206] Among them, L ID This represents the second loss value, where x represents a training sample and y represents an intent category. x This is used to indicate whether a training sample x belongs to the intent category y. If it does, then y... x =1, otherwise y x =0, p ID (x,y) represents the element in the second probability vector of training sample x corresponding to the intention category y.
[0207] It should be noted that the above embodiment takes the example of a text belonging to multiple intent categories to obtain the second probability vector and the second loss value. However, when a text can only belong to one intent category, the sigmoid function in formula (13) for determining the second probability vector is changed to the softmax function, and the loss function of the intent recognition module is changed to the Cross Entropy function, thereby improving the flexibility of intent recognition and model training.
[0208] In this embodiment of the application, the computer device performs a weighted summation of the first loss value and the second loss value to obtain the third loss value, which is achieved by the following formula (16).
[0209] L=λL ER +(1-λ)L ID (16);
[0210] Where L represents the third loss function, L ER L represents the first loss value. ID Let λ represent the second loss value, λ represent the weight of the first loss value, and 1-λ represent the weight of the second loss value. Here, λ∈[0,1] is a hyperparameter used to adjust the importance of the entity recognition module and the intent recognition module during model training.
[0211] It should be noted that the above training process is an iterative training process, and training stops when the iteration stopping conditions are met. These stopping conditions include: the number of iterations reaches a preset number, the third loss value converges, and the third loss value reaches a preset loss value.
[0212] In the embodiments of this application, during the training process of the target recognition model, gradient descent methods such as Stochastic Gradient Descent and Adam (adaptive moment estimation) can be used to update the model parameters.
[0213] In some embodiments, since the entity recognition capability is poor in the early stage of model training, in order to enable the intent recognition module to better learn how to utilize the model parameters of the entity recognition module, the entity recognition module is first trained with a second loss value, and then joint training is performed based on the two loss values. That is, the target recognition model is trained to perform entity recognition and intent recognition simultaneously, thereby improving the training effect of the target recognition model.
[0214] The method provided in this application can quickly identify entities and intents, and can also improve the recognition accuracy when rare words appear in the text by utilizing a second vocabulary that can be expanded in real time.
[0215] In this embodiment, to demonstrate the effectiveness of the method provided in entity recognition and intent recognition, an experiment was conducted using entity recognition and intent recognition data from a hospital customer service question-and-answer scenario. This data includes 55 intent categories and 20 entity categories, containing approximately 60,000 manually labeled questions. Each question can have one or more correct intent categories. These questions were divided into training, development, and test sets in an 8:1:1 ratio. The method provided in this embodiment was compared with methods that only perform intent recognition and methods that only perform entity recognition. The results are shown in Table 1 below. As can be seen from the table, the method provided in this embodiment significantly improves intent recognition performance compared to intent recognition alone, and also outperforms entity recognition performance compared to entity recognition alone. The F1 score is a statistical metric used to measure the accuracy of a binary classification model, taking into account both precision and recall.
[0216] Table 1
[0217]
[0218] In some embodiments, the effect of the method provided by the present application embodiments can also be seen based on the two texts in Table 2. The "no second vocabulary" method in Table 2 refers to the method obtained by removing the portion related to the second vocabulary from the method provided by the present application embodiments, while the "with second vocabulary" method refers to the method provided by the present application embodiments. In the two texts in Table 2, "photophobia" and "conjugated teeth" are both rare words. Methods without utilizing the second vocabulary made incorrect entity recognition and intent recognition due to the lack of information on these rare words, while the method provided by the present application embodiments can make correct recognitions.
[0219] Table 2
[0220]
[0221]
[0222] The method provided in this application can be applied to medical question-and-answer systems. For a question input into the system, the method provided in this application can identify its corresponding entity category and intent. The identification result corresponds to the answer to the question and plays an important role in downstream AI algorithms. The method provided in this application can serve as a key technology in intelligent triage and intelligent hospital management question-and-answer assistants. For example, for the input question "Where is the pediatrics department?", the method provided in this application can identify that the most likely intent of the question is "asking for directions," with one key entity being "pediatrics" (entity category: "department"). This allows the system to determine that the purpose of the question is to know the location of the "pediatrics" department within the hospital, and thus provide the correct response based on the pre-configured corresponding answers in the system. See also... Figure 5 , Figure 5 This is a schematic diagram of an application scenario provided in an embodiment of this application.
[0223] This application provides a method for entity and intent recognition. Because this method identifies multiple words in a text based on a first vocabulary list including non-rare words and a second vocabulary list including rare words, it can also identify rare words in the text, making the identified words more comprehensive. Furthermore, it represents the feature vector of a rare word based on the feature vector of the entity category to which the rare word belongs, thereby obtaining relevant information about the rare word. This leads to more accurate recognition results when performing entity and intent recognition, thus improving the accuracy of entity and intent recognition.
[0224] Figure 6 This is a block diagram of an entity and intent identification device according to an embodiment of this application. The device is used to perform the steps of the above-described entity and intent identification method, see [link to relevant documentation]. Figure 6 The device includes:
[0225] The word determination module 601 is used to determine multiple words in a text based on a first vocabulary and a second vocabulary. The first vocabulary includes multiple non-rare words, and the second vocabulary includes multiple rare words and the entity categories to which the rare words belong.
[0226] The feature vector acquisition module 602 is used to acquire feature vectors of multiple words, wherein the feature vectors of rare words among the multiple words are based on the feature vector representation of the entity category to which the rare words belong;
[0227] The feature vector acquisition module 602 is also used to acquire feature vectors of multiple characters in the text;
[0228] The latent vector sequence determination module 603 is used to obtain the latent vector sequence of the text based on the feature vectors of multiple words and the feature vectors of multiple characters. The latent vector sequence includes the latent vector sequence of characters and the latent vector sequence of words. The latent vector sequence of characters includes the latent vectors of multiple characters, and the latent vector sequence of words includes the latent vectors of multiple words.
[0229] The entity recognition module 604 is used to perform entity recognition on text based on the latent vector sequence of characters in the latent vector sequence, and obtain entity recognition results;
[0230] The intent recognition module 605 is used to perform intent recognition on text based on the latent vector sequence and obtain the intent recognition result.
[0231] In some embodiments, the entity recognition result and the intent recognition result are obtained based on a target recognition model, which includes an input module, an encoding module, an entity recognition module, and an intent recognition module.
[0232] The feature vector acquisition module 602 is used to input text into the input module of the target recognition model, and obtain the feature vectors of multiple characters and multiple words through the input module;
[0233] The latent vector sequence determination module 603 is used to input the feature vectors of multiple characters and the feature vectors of multiple words into the encoding module, and to extract attention features from the feature vectors of multiple characters and the feature vectors of multiple words through the encoding module to obtain the latent vector sequence.
[0234] The entity recognition module 604 is used to input the latent vector sequence of the character into the entity recognition module and obtain the entity recognition result through the entity recognition module;
[0235] The intent recognition module 605 is used to input the latent vector sequence into the intent recognition module and obtain the intent recognition result through the intent recognition module.
[0236] In some embodiments, the feature vector acquisition module 602 is used for:
[0237] Input the feature vectors of multiple characters and multiple words into the encoding module;
[0238] The first feature matrix is linearly transformed by the encoding module to obtain the second feature matrix. Each row vector in the first feature matrix is a feature vector of a character or a feature vector of a word.
[0239] Based on multiple row vectors in the first feature matrix, a weight matrix is obtained. Each element in the weight matrix represents the degree of correlation between two row vectors in the first feature matrix.
[0240] The weight matrix is activated, and the latent vector sequence is obtained based on the activated weight matrix and the second feature matrix.
[0241] In some embodiments, the weight matrix includes multiple elements, and the feature vector acquisition module 602 is used for:
[0242] Obtain the first position and the second position. The first position is the position of the word or phrase indicated by the i-th row vector in the first feature matrix in the text, and the second position is the position of the word or phrase indicated by the j-th row vector in the second feature matrix in the text. i and j are integers greater than 0.
[0243] The position vector is determined based on the position difference between the first and second positions;
[0244] The i-th row vector, the j-th row vector, and the position vector are fused to obtain the element in the i-th row and j-th column of the weight matrix.
[0245] In some embodiments, the entity recognition result is a target label sequence of text, which includes category labels of multiple characters. The category label of each character is used to indicate the entity category of the target word in which the character is located and the position of the character in the target word.
[0246] Entity recognition module 604 is used to input the latent vector sequence of the character into the entity recognition module;
[0247] Through the entity recognition module, for any one of multiple characters, based on the latent vector of the character and the preset category label of the character with a preset position difference from the character, the degree parameter of the character being labeled as multiple preset category labels is determined. The degree parameter of each preset category label is used to indicate the appropriateness of the character being labeled as that preset category label.
[0248] Based on the degree parameter that multiple words are labeled with multiple preset category labels and multiple candidate label sequences, the probability of multiple candidate label sequences is determined, and multiple candidate label sequences are obtained based on the combination of multiple preset category labels;
[0249] Output the candidate label sequence with the highest probability among multiple candidate label sequences as the target label sequence.
[0250] In some embodiments, the intent recognition result includes probabilities of multiple intent categories, and the intent recognition module 605 is used to:
[0251] Input the latent vector sequence into the intent recognition module;
[0252] The intent recognition module determines multiple target preset category labels from a variety of preset category labels. Each preset category label indicates the entity category of the target word in which the labeled character is located and the position of the character in the target word. The target preset category label indicates that the labeled character is located at the beginning of the target word.
[0253] For each of the multiple target preset category labels, the probability of each character being labeled as a target preset category label is determined based on the latent vectors of multiple characters.
[0254] Based on the probability that multiple characters are labeled as target preset category labels, determine the probability that the target preset category label is labeled in the text;
[0255] The first probability vector is determined based on the probability of multiple target preset category labels being labeled in the text;
[0256] Attention features are extracted from the latent vector sequence to obtain the attention vector;
[0257] The first probability vector and the attention vector are fused to obtain the second probability vector, which includes the probabilities of multiple intent categories.
[0258] In some embodiments, the intent recognition module 605 is used to determine, for each of a plurality of characters, the probability that the character is labeled as a target preset category label based on the latent vector of the character and the target model parameters, wherein the target model parameters are model parameters obtained from the entity recognition module for determining the probability that the character is labeled as any preset category label.
[0259] In some embodiments, the intent recognition module 605 is configured to:
[0260] A linear transformation is performed on the first latent vector matrix to obtain the second latent vector matrix, where each row vector in the first latent vector matrix is a latent vector in the sequence of latent vectors.
[0261] Based on multiple row vectors in the first latent vector matrix, a weight vector is obtained, where each element in the weight vector represents the importance of a row vector in the first latent vector matrix.
[0262] The weight vector is activated, and the attention vector is obtained based on the activated weight vector and the second latent vector matrix.
[0263] In some embodiments, the apparatus further includes a training module for:
[0264] The training samples are input into the target recognition model, and the predicted entity recognition result is obtained through the entity recognition module. Based on the predicted entity recognition result and the real entity recognition result, the first loss value is determined. The first loss value represents the difference between the predicted entity recognition result and the real entity recognition result.
[0265] The intent recognition module obtains the predicted intent recognition result. Based on the predicted intent recognition result and the true intent recognition result, a second loss value is determined. The second loss value represents the difference between the predicted intent recognition result and the true intent recognition result.
[0266] The third loss value is obtained by weighted summation of the first and second loss values;
[0267] The model parameters of the target recognition model are adjusted based on the third loss value.
[0268] This application provides an entity and intent recognition device. Since multiple words in the text are identified based on a first vocabulary list including non-rare words and a second vocabulary list including rare words, rare words can also be identified, resulting in a more comprehensive range of identified words. Furthermore, by representing the feature vector of the rare word based on the feature vector of the entity category to which the rare word belongs, relevant information about the rare word can be obtained. Therefore, when performing entity and intent recognition, more accurate recognition results can be obtained, thereby improving the accuracy of entity and intent recognition.
[0269] Figure 7 A structural block diagram of a terminal 700 provided in an exemplary embodiment of this application is shown. The terminal 700 may be a portable mobile terminal, such as a smartphone, tablet computer, MP3 player (Moving Picture Experts Group Audio Layer III), MP4 player (Moving Picture Experts Group Audio Layer IV), laptop computer, or desktop computer. The terminal 700 may also be referred to as a user device, portable terminal, laptop terminal, desktop terminal, or other names.
[0270] Typically, terminal 700 includes a processor 701 and a memory 702.
[0271] Processor 701 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 701 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 701 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 701 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 701 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0272] The memory 702 may include one or more computer-readable storage media, which may be non-transitory. The memory 702 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 702 are used to store at least one program code, which is executed by the processor 701 to implement the entity and intent identification method provided in the method embodiments of this application.
[0273] In some embodiments, the terminal 700 may also optionally include a peripheral device interface 703 and at least one peripheral device. The processor 701, memory 702, and peripheral device interface 703 can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface 703 via a bus, signal line, or circuit board. Specifically, the peripheral device includes at least one of the following: a radio frequency circuit 704, a display screen 705, a camera assembly 706, an audio circuit 707, and a power supply 708.
[0274] Peripheral device interface 703 can be used to connect at least one I / O (Input / Output) related peripheral device to processor 701 and memory 702. In some embodiments, processor 701, memory 702 and peripheral device interface 703 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 701, memory 702 and peripheral device interface 703 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0275] The radio frequency (RF) circuit 704 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 704 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 704 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals back into electrical signals. Optionally, the RF circuit 704 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The RF circuit 704 can communicate with other terminals through at least one wireless communication protocol. This wireless communication protocol includes, but is not limited to: the World Wide Web, metropolitan area networks, intranets, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 704 may also include circuitry related to NFC (Near Field Communication), which is not limited in this application.
[0276] Display screen 705 is used to display a UI (User Interface). This UI may include graphics, text, icons, videos, and any combination thereof. When display screen 705 is a touch display screen, it also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to processor 701 for processing. In this case, display screen 705 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there may be one display screen 705, disposed on the front panel of terminal 700; in other embodiments, there may be at least two display screens 705, disposed on different surfaces of terminal 700 or in a folded design; in other embodiments, display screen 705 may be a flexible display screen, disposed on a curved or folded surface of terminal 700. Furthermore, display screen 705 may be configured as a non-rectangular irregular shape, i.e., a non-rectangular screen. Display screen 705 may be made of materials such as LCD (Liquid Crystal Display) or OLED (Organic Light-Emitting Diode).
[0277] The camera assembly 706 is used to acquire images or videos. Optionally, the camera assembly 706 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is located on the front panel of the terminal, and the rear-facing camera is located on the back of the terminal. In some embodiments, there are at least two rear-facing cameras, which are any one of a main camera, a depth-sensing camera, a wide-angle camera, and a telephoto camera, to achieve background blurring by fusion of the main camera and the depth-sensing camera, panoramic shooting by fusion of the main camera and the wide-angle camera, VR (Virtual Reality) shooting, or other fusion shooting functions. In some embodiments, the camera assembly 706 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm-light flash and a cool-light flash, which can be used for light compensation at different color temperatures.
[0278] The audio circuit 707 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, converting the sound waves into electrical signals that are input to the processor 701 for processing, or input to the radio frequency circuit 704 for voice communication. For stereo sound acquisition or noise reduction purposes, multiple microphones may be used, each located at a different part of the terminal 700. The microphone may also be an array microphone or an omnidirectional microphone. The speaker is used to convert the electrical signals from the processor 701 or the radio frequency circuit 704 into sound waves. The speaker may be a conventional diaphragm speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into audible sound waves but also into inaudible sound waves for purposes such as distance measurement. In some embodiments, the audio circuit 707 may also include a headphone jack.
[0279] Power supply 708 is used to power the various components in terminal 700. Power supply 708 can be AC power, DC power, a disposable battery, or a rechargeable battery. When power supply 708 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged via a wired line, while a wireless rechargeable battery is a battery that is charged via a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0280] In some embodiments, the terminal 700 further includes one or more sensors 709. The one or more sensors 709 include, but are not limited to: an accelerometer 710, a gyroscope 711, a pressure sensor 712, an optical sensor 713, and a proximity sensor 714.
[0281] Accelerometer 710 can detect the magnitude of acceleration along the three coordinate axes of a coordinate system established by terminal 700. For example, accelerometer 710 can be used to detect the components of gravitational acceleration along the three coordinate axes. Processor 701 can control display screen 705 to display the user interface in either a landscape or portrait view based on the gravitational acceleration signal acquired by accelerometer 710. Accelerometer 710 can also be used for games or for acquiring user motion data.
[0282] The gyroscope sensor 711 can detect the orientation and rotation angle of the terminal 700. The gyroscope sensor 711, in conjunction with the accelerometer sensor 710, can collect 3D motion data from the user on the terminal 700. Based on the data collected by the gyroscope sensor 711, the processor 701 can perform the following functions: motion sensing (e.g., changing the UI based on the user's tilt), image stabilization during shooting, game control, and inertial navigation.
[0283] The pressure sensor 712 can be disposed on the side bezel of the terminal 700 and / or the lower layer of the display screen 705. When the pressure sensor 712 is disposed on the side bezel of the terminal 700, it can detect the user's grip signal on the terminal 700, and the processor 701 can perform left / right hand recognition or quick operation based on the grip signal collected by the pressure sensor 712. When the pressure sensor 712 is disposed on the lower layer of the display screen 705, the processor 701 can control the operable controls on the UI interface based on the user's pressure operation on the display screen 705. The operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.
[0284] An optical sensor 713 is used to collect ambient light intensity. In one embodiment, the processor 701 can control the display brightness of the display screen 705 based on the ambient light intensity collected by the optical sensor 713. Specifically, when the ambient light intensity is high, the display brightness of the display screen 705 is increased; when the ambient light intensity is low, the display brightness of the display screen 705 is decreased. In another embodiment, the processor 701 can also dynamically adjust the shooting parameters of the camera assembly 706 based on the ambient light intensity collected by the optical sensor 713.
[0285] The proximity sensor 714, also known as a distance sensor, is typically located on the front panel of the terminal 700. The proximity sensor 714 is used to detect the distance between the user and the front of the terminal 700. In one embodiment, when the proximity sensor 714 detects that the distance between the user and the front of the terminal 700 is gradually decreasing, the processor 701 controls the display screen 705 to switch from a screen-on state to a screen-off state; when the proximity sensor 714 detects that the distance between the user and the front of the terminal 700 is gradually increasing, the processor 701 controls the display screen 705 to switch from a screen-off state to a screen-on state.
[0286] Those skilled in the art will understand that Figure 7 The structure shown does not constitute a limitation on terminal 700, and may include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0287] Figure 8This is a schematic diagram of a server structure according to an embodiment of this application. The server 800 can vary significantly due to different configurations or performance. It may include one or more Central Processing Units (CPUs) 801 and one or more memories 802. The memories 802 are used to store executable program code, and the processors 801 are configured to execute the executable program code to implement the entity and intent recognition methods provided in the various method embodiments described above. Of course, the server may also have wired or wireless network interfaces, a keyboard, and input / output interfaces for input and output. The server may also include other components for implementing device functions, which will not be elaborated here.
[0288] This application also provides a computer-readable storage medium storing at least one piece of program code, which is loaded and executed by a processor to implement the entity and intent identification method of any of the above implementations.
[0289] This application also provides a computer program product, which includes computer program code stored in a computer-readable storage medium. The processor of the terminal reads the computer program code from the computer-readable storage medium and executes the computer program code, causing the terminal to execute the entity and intent identification method of any of the above implementations.
[0290] In some embodiments, the computer program product involved in the present application can be deployed and executed on a terminal, or executed on multiple terminals located in one location, or executed on multiple terminals distributed in multiple locations and interconnected through a communication network. Multiple terminals distributed in multiple locations and interconnected through a communication network can form a blockchain system.
[0291] The above are merely optional embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for identifying entities and intentions, characterized in that, The method includes: Based on a first vocabulary and a second vocabulary, multiple words in the text are identified. The first vocabulary includes multiple non-rare words, and the second vocabulary includes multiple rare words and the entity categories to which the multiple rare words belong. Obtain the feature vectors of the plurality of words, wherein the feature vectors of rare words among the plurality of words are represented based on the feature vectors of the entity categories to which the rare words belong; Obtain the feature vectors of multiple characters in the text; Based on the feature vectors of the multiple words and the feature vectors of the multiple characters, a latent vector sequence of the text is obtained. The latent vector sequence includes the latent vector sequence of characters and the latent vector sequence of words. The latent vector sequence of characters includes the latent vectors of the multiple characters, and the latent vector sequence of words includes the latent vectors of the multiple words. Based on the latent vector sequence of the characters in the latent vector sequence, entity recognition is performed on the text to obtain entity recognition results; Based on the latent vector sequence, intent recognition is performed on the text to obtain intent recognition results; The intent recognition result is obtained based on the intent recognition module in the target recognition model. The intent recognition result includes the probabilities of multiple intent categories. The process of performing intent recognition on the text based on the latent vector sequence to obtain the intent recognition result includes: The latent vector sequence is input into the intent recognition module. The intent recognition module determines multiple target preset category labels from multiple preset category labels. Any preset category label indicates the entity category of the target word in which the labeled character is located and the position of the character in the target word. The target preset category label indicates that the labeled character is located at the beginning of the target word. For each of the multiple target preset category labels, based on the latent vectors of the multiple characters, determine the probability that each character is labeled as the target preset category label; Based on the probability that the multiple characters are respectively labeled as the target preset category label, the probability that the target preset category label is labeled in the text is determined, and based on the probability that the multiple target preset category labels are labeled in the text, a first probability vector is determined; Attention features are extracted from the latent vector sequence to obtain the attention vector; The first probability vector and the attention vector are fused to obtain a second probability vector, which includes probabilities of multiple intent categories.
2. The method according to claim 1, characterized in that, The entity recognition result is obtained based on the target recognition model, which further includes an input module, an encoding module, and an entity recognition module. The process of obtaining the feature vectors of the multiple characters and the feature vectors of the multiple words includes: The text is input into the input module of the target recognition model, and the feature vectors of the multiple characters and the feature vectors of the multiple words are obtained through the input module. The process of obtaining the latent vector sequence of the text based on the feature vectors of the multiple words and the feature vectors of the multiple characters includes: The feature vectors of the multiple characters and the feature vectors of the multiple words are input into the encoding module. The encoding module performs attention feature extraction on the feature vectors of the multiple characters and the feature vectors of the multiple words to obtain the latent vector sequence. The entity recognition process, based on the latent vector sequence of characters in the latent vector sequence, performs entity recognition on the text to obtain entity recognition results, including: The latent vector sequence of the character is input into the entity recognition module, and the entity recognition result is obtained through the entity recognition module.
3. The method according to claim 2, characterized in that, The step of inputting the feature vectors of the multiple characters and the feature vectors of the multiple words into the encoding module, and extracting attention features from the feature vectors of the multiple characters and the multiple words through the encoding module to obtain the latent vector sequence includes: The feature vectors of the multiple characters and the feature vectors of the multiple words are input into the encoding module; The encoding module performs a linear transformation on the first feature matrix to obtain the second feature matrix, where each row vector in the first feature matrix is a feature vector of a character or a feature vector of a word. Based on multiple row vectors in the first feature matrix, a weight matrix is obtained, where each element in the weight matrix represents the degree of correlation between two row vectors in the first feature matrix. The weight matrix is activated, and the latent vector sequence is obtained based on the activated weight matrix and the second feature matrix.
4. The method according to claim 3, characterized in that, The weight matrix comprises multiple elements, wherein the element located at the th weight matrix is the weight matrix. i line, number j The process of determining the elements of a column includes: Obtain the first position and the second position, where the first position is the position in the first feature matrix. i The position of the character or word indicated by the row vector in the text, the second position being the position of the second feature matrix. j The position of the character or word indicated by each row vector in the text, the i and j It is an integer greater than 0; Determine the position vector based on the position difference between the first position and the second position; For the first i The row vector, the first j The row vector and the position vector are fused to obtain the position vector located in the weight matrix. i line, number j The elements of the column.
5. The method according to claim 2, characterized in that, The entity recognition result is the target label sequence of the text, and the target label sequence includes the category labels of the plurality of characters. The category label of each character is used to represent the entity category of the target word in which the character is located and the position of the character in the target word. The step of inputting the latent vector sequence of the character into the entity recognition module and obtaining the entity recognition result through the entity recognition module includes: The latent vector sequence of the character is input into the entity recognition module; Through the entity recognition module, for any one of the plurality of characters, based on the latent vector of the character and the preset category label of the character with a preset position difference from the character, the degree parameter of the character being labeled as multiple preset category labels is determined. The degree parameter of each preset category label is used to indicate the appropriateness of the character being labeled as the preset category label. Based on the degree parameters of the multiple words being labeled as the multiple preset category labels and the multiple candidate label sequences, the probabilities of the multiple candidate label sequences are determined respectively, and the multiple candidate label sequences are obtained based on the combination of the multiple preset category labels; The candidate label sequence with the highest probability among the multiple candidate label sequences is output as the target label sequence.
6. The method according to claim 2, characterized in that, The determination of the probability that each of the multiple characters is labeled as the target preset category label based on the latent vectors of the multiple characters includes: For each of the plurality of characters, based on the latent vector of the character and the target model parameters, the probability of the character being labeled as the target preset category label is determined, wherein the target model parameters are model parameters obtained from the entity recognition module for determining the probability of the character being labeled as any preset category label.
7. The method according to claim 2, characterized in that, The step of extracting attention features from the latent vector sequence to obtain the attention vector includes: A linear transformation is performed on the first latent vector matrix to obtain a second latent vector matrix, where each row vector in the first latent vector matrix is a latent vector in the latent vector sequence. Based on multiple row vectors in the first latent vector matrix, a weight vector is obtained, where each element in the weight vector represents the importance of a row vector in the first latent vector matrix. The weight vector is activated, and the attention vector is obtained based on the activated weight vector and the second hidden vector matrix.
8. The method according to claim 2, characterized in that, The training process of the target recognition model includes: The training samples are input into the target recognition model, and the entity recognition module obtains the predicted entity recognition result. Based on the predicted entity recognition result and the real entity recognition result, a first loss value is determined. The first loss value represents the difference between the predicted entity recognition result and the real entity recognition result. The intent recognition module obtains a predicted intent recognition result. Based on the predicted intent recognition result and the actual intent recognition result, a second loss value is determined. The second loss value represents the difference between the predicted intent recognition result and the actual intent recognition result. The first loss value and the second loss value are weighted and summed to obtain the third loss value; The model parameters of the target recognition model are adjusted based on the third loss value.
9. A device for identifying entities and intentions, characterized in that, The device includes: A word determination module is used to determine multiple words in a text based on a first vocabulary and a second vocabulary. The first vocabulary includes multiple non-rare words, and the second vocabulary includes multiple rare words and the entity categories to which the multiple rare words belong. The feature vector acquisition module is used to acquire the feature vectors of the plurality of words, wherein the feature vectors of rare words among the plurality of words are based on the feature vector representation of the entity category to which the rare words belong; The feature vector acquisition module is also used to acquire feature vectors of multiple characters in the text; The latent vector sequence determination module is used to obtain the latent vector sequence of the text based on the feature vectors of the multiple words and the feature vectors of the multiple characters. The latent vector sequence includes the latent vector sequence of characters and the latent vector sequence of words. The latent vector sequence of characters includes the latent vectors of the multiple characters, and the latent vector sequence of words includes the latent vectors of the multiple words. An entity recognition module is used to perform entity recognition on the text based on the latent vector sequence of the characters in the latent vector sequence, and obtain entity recognition results; An intent recognition module is used to perform intent recognition on the text based on the latent vector sequence to obtain an intent recognition result; The intent recognition result is obtained based on the intent recognition module in the target recognition model. The intent recognition result includes the probabilities of multiple intent categories. The intent recognition module in the device is used for: The latent vector sequence is input into the intent recognition module in the target recognition model. Through the intent recognition module in the target recognition model, multiple target preset category labels are determined from multiple preset category labels. Any preset category label indicates the entity category of the target word in which the labeled character is located and the position of the character in the target word. The target preset category label indicates that the labeled character is located at the beginning of the target word. For each of the multiple target preset category labels, based on the latent vectors of the multiple characters, determine the probability that each character is labeled as the target preset category label; Based on the probability that the multiple characters are respectively labeled as the target preset category label, the probability that the target preset category label is labeled in the text is determined, and based on the probability that the multiple target preset category labels are labeled in the text, a first probability vector is determined; Attention features are extracted from the latent vector sequence to obtain the attention vector; The first probability vector and the attention vector are fused to obtain a second probability vector, which includes probabilities of multiple intent categories.
10. A computer device, characterized in that, The computer device includes a processor and a memory, the memory being used to store at least one computer program, the at least one computer program being loaded by the processor and executed as the entity and intent identification method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store at least one computer program for performing the entity and intent identification method as described in any one of claims 1 to 8.
12. A computer program product, characterized in that, The computer program product includes computer program code stored in a computer-readable storage medium, a processor of a computer device reads the computer program code from the computer-readable storage medium, and the processor executes the computer program code to cause the computer device to perform the entity and intent identification method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Intelligent medication question-answering method based on medicine knowledge graph and equipment thereof
CN112182252A
Unregistered word replacement method based on entity type matching
CN112633012A
Medical entity identification method and system fusing Chinese medical field features
CN114927177A
