Intention recognition method and system based on a generative model, and storage medium
By performing semantic matching and text concatenation processing in the intent recognition method, and combining the multi-layer attention mechanism and feedforward neural network of the generative model, the parameters of the generative model are optimized, which solves the problem of low intent recognition accuracy and achieves higher intent recognition accuracy and system response precision.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGXI GUIYUNTONG TECH CO LTD
- Filing Date
- 2024-10-29
- Publication Date
- 2026-05-29
Smart Images

Figure CN119443113B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of speech recognition technology, and in particular to an intent recognition method, system, and storage medium based on a generative model. Background Technology
[0002] Intent recognition is a natural language processing technology aimed at understanding the true needs or purposes expressed by users when interacting with computer systems, applications, or smart devices. Specifically, it involves computer devices identifying the user's intent category from input information (such as text, voice commands, etc.), enabling the system to provide more accurate responses or services that meet user expectations. With the increasing richness of business scenarios and the gradual popularization of big data, user needs often exhibit diversity and continuity, making the accuracy of user intent recognition increasingly important.
[0003] In existing intent recognition processes, intent is typically classified directly from the text to be recognized, resulting in low accuracy of intent recognition. Summary of the Invention
[0004] The purpose of this invention is to provide an intent recognition method, system, and storage medium based on a generative model, so as to solve the problem of low intent recognition accuracy in the prior art.
[0005] This invention is implemented as follows: an intent recognition method based on a generative model, the method comprising:
[0006] The text to be identified is obtained, and the text to be identified is semantically matched with the corpus sample library to obtain the semantic similarity.
[0007] Based on the semantic similarity, similar samples in the corpus sample library are determined, and the similar samples and the text to be identified are concatenated to obtain the concatenated text;
[0008] The concatenated text is input into the pre-trained generative model for intent classification to obtain intent classification results, and the target sample in the concatenated text is determined based on the intent classification results.
[0009] The intent category of the text to be identified is determined based on the intent encoding of the target sample.
[0010] Preferably, before inputting the concatenated text into the pre-trained generative model for intent classification, the method further includes:
[0011] The training samples are used to generate text based on the generative model to obtain generated text, and word embedding processing is performed on the generated text to obtain word vectors;
[0012] The word vectors are processed using a multi-layer attention mechanism to obtain attention features, and the attention features are then processed using a feedforward neural network to obtain feedforward computation features.
[0013] The feedforward computation features are processed by a fully connected layer to obtain the predicted intent features, and the predicted intent features are then classified to obtain the intent prediction classification.
[0014] The model loss is determined based on the intent prediction classification and the predicted intent features, and the parameters of the generative model are updated based on the model loss until the generative model converges, thus obtaining the pre-trained generative model.
[0015] Preferably, the generated text is subjected to word embedding processing to obtain word vectors, and then the process further includes:
[0016] Global feature extraction is performed on the word vectors to obtain global text features, and fully connected processing is performed on the global text features to obtain the predicted intent features;
[0017] The predicted intent features are classified and predicted to obtain the predicted intent classification, and the model loss is determined based on the predicted intent classification.
[0018] The parameters of the generative model are updated based on the model loss until the generative model converges, thus obtaining the pre-trained generative model.
[0019] Preferably, global feature extraction is performed on the word vectors to obtain global text features, including:
[0020] Obtain the update gate weight matrix and the reset gate weight matrix, and perform gate operations on the word vectors according to the update gate weight matrix and the reset gate weight matrix to obtain the first time step degree and the second time step degree;
[0021] Obtain the hidden weight matrix, and calculate the hidden state relationship based on the hidden weight matrix, the first time step degree, and the second time step degree;
[0022] The word vectors are feature-mapped according to the hidden state relationships to obtain the global text features.
[0023] Preferably, determining the target sample in the concatenated text based on the intent classification result includes:
[0024] The text to be recognized is input into the pre-trained generative model for intent classification to obtain a first intent label, and the sample labels of the similar samples are obtained to obtain a second intent label;
[0025] Obtain the intent label from the intent classification result to get the third intent label, and map the first intent label, the second intent label and the third intent label according to the preset mapping relationship to get the first label mapping, the second label mapping and the third label mapping;
[0026] Calculate the similarity between the first label mapping and the third label mapping to obtain a first similarity, and calculate the similarity between the second label mapping and the third label mapping to obtain a second similarity;
[0027] For the same concatenated text, the first similarity and the second similarity are weighted and calculated to obtain the total similarity, and the concatenated text corresponding to the maximum total similarity is determined as the preferred text;
[0028] The similar samples in the preferred text are identified as the target samples.
[0029] Preferably, determining the model loss based on the intent prediction classification and the predicted intent features includes:
[0030] Calculate the loss between the standard intent classification and the predicted intent classification to obtain a first loss, and calculate the loss between the standard intent features and the predicted intent features to obtain a second loss;
[0031] The model loss is obtained by weighting the first loss and the second loss.
[0032] Preferably, the text to be identified is semantically matched with a corpus of sample texts to obtain semantic similarity, including:
[0033] The text features of the text to be identified and the corpus samples in the corpus sample library are obtained to obtain the first text feature and the second text feature;
[0034] The first text feature and the second text feature are transformed into vectors to obtain a first text vector and a second text vector, and the similarity between the first text vector and the second text vector is calculated to obtain the semantic similarity.
[0035] Another objective of this invention is to provide an intent recognition system based on a generative model, the system comprising:
[0036] The semantic matching module is used to acquire the text to be identified and perform semantic matching between the text to be identified and the corpus sample library to obtain semantic similarity.
[0037] The text concatenation module is used to determine similar samples in the corpus sample library based on the semantic similarity, and concatenate the similar samples and the text to be identified to obtain concatenated text;
[0038] The intent classification module is used to input the concatenated text into the pre-trained generative model for intent classification, obtain intent classification results, and determine the target samples in the concatenated text based on the intent classification results.
[0039] An intent recognition module is used to determine the intent category of the text to be recognized based on the intent encoding of the target sample.
[0040] Preferably, the intent classification module is further used for:
[0041] The training samples are used to generate text based on the generative model to obtain generated text, and word embedding processing is performed on the generated text to obtain word vectors;
[0042] The word vectors are processed using a multi-layer attention mechanism to obtain attention features, and the attention features are then processed using a feedforward neural network to obtain feedforward computation features.
[0043] The feedforward computation features are processed by a fully connected layer to obtain the predicted intent features, and the predicted intent features are then classified to obtain the intent prediction classification.
[0044] The model loss is determined based on the intent prediction classification and the predicted intent features, and the parameters of the generative model are updated based on the model loss until the generative model converges, thus obtaining the pre-trained generative model.
[0045] In this embodiment of the invention, semantic matching between the text to be identified and a corpus sample library can effectively calculate the semantic similarity between the text to be identified and the corpus samples. Based on the semantic similarity, similar samples in the corpus sample library can be effectively identified. By concatenating similar samples with the text to be identified, texts with similar semantics to the text to be identified can be effectively combined to obtain concatenated text. By inputting the concatenated text into a pre-trained generative model for intent classification, the intent classification result of the concatenated text can be effectively obtained. Based on the intent classification result, the target sample in the concatenated text can be effectively identified. Based on the intent encoding of the target sample, the intent category of the text to be identified can be effectively determined. In this embodiment, by inputting multiple semantically similar texts with intent encoding into the pre-trained generative model, the generative model can better identify the semantic information of the text to be identified, thereby improving the accuracy of intent recognition. Attached Figure Description
[0046] Figure 1 This is a flowchart of the intention recognition method based on a generative model provided in the first embodiment of the present invention;
[0047] Figure 2This is a schematic diagram of the structure of the generative model-based intent recognition system provided in the second embodiment of the present invention;
[0048] Figure 3 This is a schematic diagram of the structure of the terminal device provided in the third embodiment of the present invention. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0050] To illustrate the technical solution described in this invention, specific embodiments are described below.
[0051] Example 1
[0052] Please see Figure 1 This is a flowchart of the generative model-based intent recognition method provided in the first embodiment of the present invention. This generative model-based intent recognition method can be applied to any device or system, and includes the following steps:
[0053] Step S10: Obtain the text to be identified and perform semantic matching between the text to be identified and the corpus sample library to obtain semantic similarity;
[0054] Given a corpus sample database:
[0055] D={(d0, l0), (d1, l1),..., (d n-1 , l n-1 )}
[0056] d0 represents the o-th corpus sample in D, and l0 represents the intent encoding of the o-th corpus sample in D. In this step, the semantic similarity between the text to be identified and the corpus sample is calculated by semantically matching the text to be identified with the corpus sample library.
[0057] Optionally, the text to be identified is semantically matched with a corpus of sample texts to obtain semantic similarity, including:
[0058] The text features of the text to be identified and the corpus samples in the corpus sample library are obtained to obtain the first text feature and the second text feature; wherein, the text features include word frequency, word embedding, syntactic features and text statistical features, etc.
[0059] The first text feature and the second text feature are vectorized to obtain a first text vector and a second text vector, and the similarity between the first text vector and the second text vector is calculated to obtain the semantic similarity; wherein, by performing vectorization on the first text feature and the second text feature, the text features can be effectively vectorized to obtain the first text vector and the second text vector.
[0060] Specifically, in this step, for each corpus sample in D, the corresponding vector representation is obtained, as follows:
[0061]
[0062] Where E is the second text vector, e i For the i-th corpus sample d i The corresponding representation vector, M gen It is a generative model, and embedding is the embedding layer in the generative model.
[0063] Calculate the semantic similarity between the text to be identified, t, and the corpus samples:
[0064]
[0065]
[0066] Where, sim i e is the semantic similarity between the text t to be identified and the i-th corpus sample. t It is the second text vector corresponding to the text t to be identified.
[0067] Step S20: Determine similar samples in the corpus sample library based on the semantic similarity, and concatenate the similar samples and the text to be identified to obtain the concatenated text;
[0068] Among them, corpus samples with semantic similarity greater than the similarity threshold are identified as similar samples. The similarity threshold can be set according to the requirements. By concatenating similar samples with the text to be identified, multiple texts with intent encoding that are semantically similar to the text to be identified can be effectively combined to obtain concatenated text.
[0069] Specifically, in this step, the k samples with the highest semantic similarity to the text t to be identified are selected from D to obtain similar samples, and C = {(d0, l0)...(d... k-1 , l k-1 )} represents the set of the k most similar samples selected from D. Following a preset format, the similar samples in C and the text to be identified t are concatenated into a character sequence. Specifically, the concatenated text I can be represented as:
[0070] Example 1: d0\tl0\n, Example 2: d1\tl1\n…\n, Example k: d k-1 \tl k-1 \nt.
[0071] Step S30: Input the spliced text into the pre-trained generation model for intent classification, obtain the intent classification result, and determine the target sample in the spliced text based on the intent classification result;
[0072] By inputting concatenated text into the pre-trained generative model for intent classification, multiple texts with intent encoding that are semantically similar to the text to be identified can be input into the pre-trained generative model together. This enables the generative model to better identify the semantic information of the text to be identified and improves the accuracy of intent recognition.
[0073] Optionally, before inputting the concatenated text into the pre-trained generative model for intent classification, the method further includes:
[0074] The training samples are used to generate text based on the generative model to obtain generated text, and word embedding processing is performed on the generated text to obtain word vectors; wherein, by performing word embedding processing on the generated text, word vectors in the generated text can be effectively extracted.
[0075] The word vectors are processed using a multi-layer attention mechanism to obtain attention features, and then processed using a feedforward neural network to obtain feedforward computation features. By processing the word vectors using a multi-layer attention mechanism, the semantic relevance between word vectors can be effectively obtained. Through feedforward computation, features can be extracted from different spaces, effectively improving the representation effect of the output vector.
[0076] The feedforward computation features are fully connected to obtain predicted intent features, and the predicted intent features are then classified to obtain an intent prediction category. The fully connected processing of the feedforward computation features effectively combines them to obtain predicted intent features. The predicted intent features are then classified to obtain an intent prediction category that represents the classification result of the concatenated text.
[0077] The model loss is determined based on the intent prediction classification and the predicted intent features, and the parameters of the generative model are updated based on the model loss until the generative model converges, thus obtaining the pre-trained generative model. By determining the model loss, the parameter updates of the generative model are effectively guaranteed, the accuracy of the generative model is improved, and the pre-trained generative model can effectively perform intent recognition.
[0078] Further, the generated text is subjected to word embedding processing to obtain word vectors, and then the process further includes:
[0079] Global feature extraction is performed on the word vectors to obtain global text features, and fully connected processing is performed on the global text features to obtain the predicted intent features; wherein, by performing global feature extraction on the word vectors, the global text features of the generated text can be effectively obtained;
[0080] The predicted intent features are classified and predicted to obtain the predicted intent classification, and the model loss is determined based on the predicted intent classification.
[0081] The parameters of the generative model are updated based on the model loss until the generative model converges, thus obtaining the pre-trained generative model.
[0082] Furthermore, global feature extraction is performed on the word vectors to obtain global text features, including:
[0083] Obtain the update gate weight matrix and the reset gate weight matrix, and perform gate operations on the word vectors according to the update gate weight matrix and the reset gate weight matrix to obtain the degree of influence between the current time step and the previous time step; wherein, the update gate weight matrix and the reset gate weight matrix can be set according to the requirements, and the degree of influence between the current time step and the previous time step can be effectively obtained by performing gate operations on the word vectors through the update gate weight matrix and the reset gate weight matrix.
[0084] A hidden weight matrix is obtained, and a hidden state relationship is calculated based on the hidden weight matrix, the first time step degree, and the second time step degree. The word vectors are then feature-mapped based on the hidden state relationship to obtain the global text features. The hidden weight matrix can be set according to requirements. By calculating the hidden state relationship, the word vectors can be effectively feature-mapped to obtain global text features that retain the hidden relationship, thereby improving the accuracy of the global text features.
[0085] Preferably, determining the target sample in the concatenated text based on the intent classification result includes:
[0086] The text to be recognized is input into the pre-trained generative model for intent classification to obtain a first intent label, and the sample labels of the similar samples are obtained to obtain a second intent label; wherein, by inputting the text to be recognized into the pre-trained generative model for intent classification, the intent of the text to be recognized can be effectively classified to obtain the first intent label.
[0087] The intent label in the intent classification result is obtained to obtain the third intent label. The first intent label, the second intent label, and the third intent label are mapped according to the preset mapping relationship to obtain the first label mapping, the second label mapping, and the third label mapping. In this way, by mapping the first intent label, the second intent label, and the third intent label, the first intent label, the second intent label, and the third intent label can be effectively mapped to the representation in the specified area to obtain the first label mapping, the second label mapping, and the third label mapping.
[0088] Calculate the similarity between the first label mapping and the third label mapping to obtain a first similarity, and calculate the similarity between the second label mapping and the third label mapping to obtain a second similarity;
[0089] For the same concatenated text, the first similarity and the second similarity are weighted to obtain the total similarity. The concatenated text corresponding to the maximum total similarity is determined as the preferred text, and the similar samples in the preferred text are determined as the target samples. Wherein, when the total similarity is larger, the semantics between the text to be identified and the similar text in the corresponding concatenated text are closer. Therefore, the concatenated text corresponding to the maximum total similarity is determined as the preferred text, and the similar samples in the preferred text are the target samples that are closest to the text to be identified.
[0090] In this embodiment, determining the model loss based on the intent prediction classification and the predicted intent features includes:
[0091] Calculate the loss between the standard intent classification and the predicted intent classification to obtain a first loss, and calculate the loss between the standard intent features and the predicted intent features to obtain a second loss;
[0092] The first loss and the second loss are weighted to obtain the model loss; wherein, during the weighting operation, the weighting coefficients of the first loss and the second loss can be set according to requirements, and by weighting the first loss and the second loss, the accuracy of the model loss is effectively improved.
[0093] Step S40: Determine the intent category of the text to be identified based on the intent encoding of the target sample;
[0094] In this step, the intent code is matched with an intent lookup table to obtain the intent category. The intent lookup table stores the correspondence between different intent codes and their corresponding intent categories. The formulas that can be used to obtain the intent code corresponding to the text t to be recognized in this step include:
[0095] l t =M gen (I)
[0096] Among them, l t And the intent category of the text t to be identified, l t ∈C.
[0097] In this embodiment, semantic matching between the text to be identified and the corpus sample library can effectively calculate the semantic similarity between the text to be identified and the corpus samples. Based on the semantic similarity, similar samples in the corpus sample library can be effectively identified. By concatenating similar samples and the text to be identified, texts with similar semantics to the text to be identified can be effectively combined to obtain concatenated text. By inputting the concatenated text into the pre-trained generative model for intent classification, the intent classification result of the concatenated text can be effectively obtained. Based on the intent classification result, the target sample in the concatenated text can be effectively identified. Based on the intent encoding of the target sample, the intent category of the text to be identified can be effectively determined. In this embodiment, by inputting multiple semantically similar texts with intent encoding into the pre-trained generative model, the generative model can better identify the semantic information of the text to be identified, thus improving the accuracy of intent recognition.
[0098] Example 2
[0099] Please see Figure 2 This is a schematic diagram of the structure of the generative model-based intent recognition system 100 provided in the second embodiment of the present invention, including:
[0100] The semantic matching module 10 is used to acquire the text to be identified and perform semantic matching between the text to be identified and the corpus sample library to obtain semantic similarity.
[0101] Optionally, the semantic matching module 10 is further configured to: obtain the text features of the text to be identified and the corpus samples in the corpus sample library to obtain the first text features and the second text features;
[0102] The first text feature and the second text feature are transformed into vectors to obtain a first text vector and a second text vector, and the similarity between the first text vector and the second text vector is calculated to obtain the semantic similarity.
[0103] The text splicing module 11 is used to determine similar samples in the corpus sample library based on the semantic similarity, and splice the similar samples and the text to be identified to obtain spliced text.
[0104] The intent classification module 12 is used to input the concatenated text into the pre-trained generative model for intent classification, obtain intent classification results, and determine the target samples in the concatenated text based on the intent classification results.
[0105] Optionally, the intent classification module 12 is also used for:
[0106] The training samples are used to generate text based on the generative model to obtain generated text, and word embedding processing is performed on the generated text to obtain word vectors;
[0107] The word vectors are processed using a multi-layer attention mechanism to obtain attention features, and the attention features are then processed using a feedforward neural network to obtain feedforward computation features.
[0108] The feedforward computation features are processed by a fully connected layer to obtain the predicted intent features, and the predicted intent features are then classified to obtain the intent prediction classification.
[0109] The model loss is determined based on the intent prediction classification and the predicted intent features, and the parameters of the generative model are updated based on the model loss until the generative model converges, thus obtaining the pre-trained generative model.
[0110] Furthermore, the intent classification module 12 is also used to: extract global features from the word vectors to obtain text global features, and perform fully connected processing on the text global features to obtain the predicted intent features;
[0111] The predicted intent features are classified and predicted to obtain the predicted intent classification, and the model loss is determined based on the predicted intent classification.
[0112] The parameters of the generative model are updated based on the model loss until the generative model converges, thus obtaining the pre-trained generative model.
[0113] Furthermore, the intent classification module 12 is also used to: obtain the update gate weight matrix and the reset gate weight matrix, and perform gate operation on the word vector according to the update gate weight matrix and the reset gate weight matrix to obtain the first time step degree and the second time step degree;
[0114] Obtain the hidden weight matrix, and calculate the hidden state relationship based on the hidden weight matrix, the first time step degree, and the second time step degree;
[0115] The word vectors are feature-mapped according to the hidden state relationships to obtain the global text features.
[0116] Preferably, the intent classification module 12 is further configured to: input the text to be recognized into the pre-trained generative model to perform intent classification, obtain a first intent label, and obtain the sample labels of the similar samples to obtain a second intent label;
[0117] Obtain the intent label from the intent classification result to get the third intent label, and map the first intent label, the second intent label and the third intent label according to the preset mapping relationship to get the first label mapping, the second label mapping and the third label mapping;
[0118] Calculate the similarity between the first label mapping and the third label mapping to obtain a first similarity, and calculate the similarity between the second label mapping and the third label mapping to obtain a second similarity;
[0119] For the same concatenated text, the first similarity and the second similarity are weighted and calculated to obtain the total similarity, and the concatenated text corresponding to the maximum total similarity is determined as the preferred text;
[0120] The similar samples in the preferred text are identified as the target samples.
[0121] In this embodiment, the intent classification module 12 is further configured to: calculate the loss between the standard intent classification and the predicted intent classification to obtain a first loss, and calculate the loss between the standard intent features and the predicted intent features to obtain a second loss;
[0122] The model loss is obtained by weighting the first loss and the second loss.
[0123] The intent recognition module 13 is used to determine the intent category of the text to be recognized based on the intent encoding of the target sample.
[0124] In this embodiment, semantic matching between the text to be identified and the corpus sample library can effectively calculate the semantic similarity between the text to be identified and the corpus samples. Based on the semantic similarity, similar samples in the corpus sample library can be effectively identified. By concatenating similar samples and the text to be identified, texts with similar semantics to the text to be identified can be effectively combined to obtain concatenated text. By inputting the concatenated text into the pre-trained generative model for intent classification, the intent classification result of the concatenated text can be effectively obtained. Based on the intent classification result, the target sample in the concatenated text can be effectively identified. Based on the intent encoding of the target sample, the intent category of the text to be identified can be effectively determined. In this embodiment, by inputting multiple semantically similar texts with intent encoding into the pre-trained generative model, the generative model can better identify the semantic information of the text to be identified, thus improving the accuracy of intent recognition.
[0125] Example 3
[0126] Figure 3 This is a structural block diagram of a terminal device 2 provided in the third embodiment of this application. For example... Figure 3As shown, the terminal device 2 in this embodiment includes a processor 20, a memory 21, and a computer program 22 stored in the memory 21 and executable on the processor 20, such as a program for an intent recognition method based on a generative model. When the processor 20 executes the computer program 22, it implements the steps in the various embodiments of the intent recognition method based on the generative model described above.
[0127] For example, the computer program 22 may be divided into one or more modules, which are stored in the memory 21 and executed by the processor 20 to complete this application. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program 22 in the terminal device 2. The terminal device may include, but is not limited to, the processor 20 and the memory 21.
[0128] The processor 20 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0129] The memory 21 can be an internal storage unit of the terminal device 2, such as a hard drive or memory of the terminal device 2. The memory 21 can also be an external storage device of the terminal device 2, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the terminal device 2. Furthermore, the memory 21 can include both internal and external storage units of the terminal device 2. The memory 21 is used to store the computer program and other programs and data required by the terminal device. The memory 21 can also be used to temporarily store data that has been output or will be output.
[0130] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0131] If an integrated module is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. This computer-readable storage medium can be non-volatile or volatile. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable storage medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the contents of a computer-readable storage medium may be appropriately added to or subtracted from the contents as required by the legislation and patent practice in a jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, a computer-readable storage medium may not include electrical carrier signals and telecommunication signals.
[0132] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. An intent recognition method based on a generative model, characterized in that, The method includes: The text to be identified is obtained, and the text to be identified is semantically matched with the corpus sample library to obtain the semantic similarity. Based on the semantic similarity, similar samples in the corpus sample library are determined, and the similar samples and the text to be identified are concatenated to obtain the concatenated text; The concatenated text is input into a pre-trained generative model for intent classification to obtain intent classification results. Target samples in the concatenated text are then determined based on these intent classification results. Determining target samples in the concatenated text based on the intent classification results includes: inputting the text to be identified into the pre-trained generative model for intent classification to obtain a first intent label; obtaining sample labels of similar samples to obtain a second intent label; obtaining intent labels from the intent classification results to obtain a third intent label; mapping the first intent label, the second intent label, and the third intent label according to a preset mapping relationship to obtain a first label mapping, a second label mapping, and a third label mapping; calculating the similarity between the first label mapping and the third label mapping to obtain a first similarity; and calculating the similarity between the second label mapping and the third label mapping to obtain a second similarity. For the same concatenated text, the first similarity and the second similarity are weighted to obtain a total similarity, and the concatenated text corresponding to the maximum total similarity is determined as the preferred text; the similar samples in the preferred text are determined as the target samples; The intent category of the text to be identified is determined based on the intent encoding of the target sample.
2. The intention recognition method based on a generative model as described in claim 1, characterized in that, Before inputting the concatenated text into the pre-trained generative model for intent classification, the process also includes: The training samples are used to generate text based on the generative model to obtain generated text, and word embedding processing is performed on the generated text to obtain word vectors; The word vectors are processed using a multi-layer attention mechanism to obtain attention features, and the attention features are then processed using a feedforward neural network to obtain feedforward computation features. The feedforward computation features are processed by a fully connected layer to obtain the predicted intent features, and the predicted intent features are then classified to obtain the intent prediction classification. The model loss is determined based on the intent prediction classification and the predicted intent features, and the parameters of the generative model are updated based on the model loss until the generative model converges, thus obtaining the pre-trained generative model.
3. The intention recognition method based on a generative model as described in claim 2, characterized in that, The generated text is subjected to word embedding processing to obtain word vectors, and then the process further includes: Global feature extraction is performed on the word vectors to obtain global text features, and fully connected processing is performed on the global text features to obtain the predicted intent features; The predicted intent features are classified and predicted to obtain the predicted intent classification, and the model loss is determined based on the predicted intent classification. The parameters of the generative model are updated based on the model loss until the generative model converges, thus obtaining the pre-trained generative model.
4. The intention recognition method based on a generative model as described in claim 3, characterized in that, Global feature extraction is performed on the word vectors to obtain global text features, including: Obtain the update gate weight matrix and the reset gate weight matrix, and perform gate operations on the word vectors according to the update gate weight matrix and the reset gate weight matrix to obtain the first time step degree and the second time step degree; Obtain the hidden weight matrix, and calculate the hidden state relationship based on the hidden weight matrix, the first time step degree, and the second time step degree; The word vectors are feature-mapped according to the hidden state relationships to obtain the global text features.
5. The intention recognition method based on a generative model as described in claim 2, characterized in that, The model loss is determined based on the intent prediction classification and the predicted intent features, including: Calculate the loss between the standard intent classification and the predicted intent classification to obtain a first loss, and calculate the loss between the standard intent features and the predicted intent features to obtain a second loss; The model loss is obtained by weighting the first loss and the second loss.
6. The intention recognition method based on a generative model as described in claim 1, characterized in that, The text to be identified is semantically matched with a corpus of sample texts to obtain semantic similarity, including: The text features of the text to be identified and the corpus samples in the corpus sample library are obtained to obtain the first text feature and the second text feature; The first text feature and the second text feature are transformed into vectors to obtain a first text vector and a second text vector, and the similarity between the first text vector and the second text vector is calculated to obtain the semantic similarity.
7. An intent recognition system based on a generative model, characterized in that, The system includes: The semantic matching module is used to acquire the text to be identified and perform semantic matching between the text to be identified and the corpus sample library to obtain semantic similarity. The text concatenation module is used to determine similar samples in the corpus sample library based on the semantic similarity, and concatenate the similar samples and the text to be identified to obtain concatenated text; An intent classification module is used to input the concatenated text into a pre-trained generative model for intent classification, obtain intent classification results, and determine target samples in the concatenated text based on the intent classification results. Determining target samples in the concatenated text based on the intent classification results includes: inputting the text to be identified into the pre-trained generative model for intent classification to obtain a first intent label, and obtaining sample labels of similar samples to obtain a second intent label; obtaining intent labels from the intent classification results to obtain a third intent label, and mapping the first intent label, the second intent label, and the third intent label according to a preset mapping relationship to obtain a first label mapping, a second label mapping, and a third label mapping; calculating the similarity between the first label mapping and the third label mapping to obtain a first similarity, and calculating the similarity between the second label mapping and the third label mapping to obtain a second similarity; for the same concatenated text, performing a weighted operation on the first similarity and the second similarity to obtain a total similarity, and determining the concatenated text corresponding to the maximum total similarity as the preferred text; and determining the similar samples in the preferred text as the target samples. An intent recognition module is used to determine the intent category of the text to be recognized based on the intent encoding of the target sample.
8. The intention recognition system based on a generative model as described in claim 7, characterized in that, The intent classification module is also used for: The training samples are used to generate text based on the generative model to obtain generated text, and word embedding processing is performed on the generated text to obtain word vectors; The word vectors are processed using a multi-layer attention mechanism to obtain attention features, and the attention features are then processed using a feedforward neural network to obtain feedforward computation features. The feedforward computation features are processed by a fully connected layer to obtain the predicted intent features, and the predicted intent features are then classified to obtain the intent prediction classification. The model loss is determined based on the intent prediction classification and the predicted intent features, and the parameters of the generative model are updated based on the model loss until the generative model converges, thus obtaining the pre-trained generative model.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 6.