Intention recognition method and device, electronic device and storage medium
Through the hierarchical clustering algorithm, the problem of new intention recognition in the task-based intelligent dialogue system is solved, and the accurate identification and clustering of new intention text is achieved, which improves customer service effect.
Patent Information
- Application Number
- CN202211378256.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-04
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2042-11-04
AI Technical Summary
In a task-based intelligent dialogue system, it is difficult for the existing technology to accurately identify new intention text, resulting in the dialogue management module being unable to effectively respond to new intentions in business updates, affecting customer service effects.
The hierarchical clustering algorithm is used to train and cluster unknown intent texts. Through iterative training of known intent text and temporary labels, the hierarchical clustering algorithm is used to cluster text representation vectors, and temporary labels of unknown intent text are marked according to the clustering results, and new intent text in trusted clusters are output.
It improves the accuracy and clustering effect of new intent texts, ensures timely updates to the intent library, and improves the customer service capabilities of the intelligent dialogue system.
Smart Images

Figure CN116150354B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of text processing, and specifically to an intent recognition method and device, an electronic device, and a storage medium. Background Art
[0002] With the rapid development of artificial intelligence (AI) technology, intelligent dialogue systems are widely used in various business fields. Generally speaking, intelligent dialogue systems can be divided into two types: open-domain intelligent chat dialogue systems; and task-based intelligent dialogue systems for specific tasks. These systems are currently widely used in intelligent customer service, such as online intelligent customer service and intelligent voice customer service.
[0003] In task-based intelligent dialogue systems, a dialogue management module typically controls the normal flow of conversation content and determines the system's capabilities. However, as business evolves, new intent texts gradually emerge in task-based intelligent dialogue systems, making it difficult for the dialogue management module to recognize these new intent texts. Therefore, handling these new intent texts has become a challenge for task-based intelligent dialogue systems.
[0004] In order to ensure accurate identification of customer intent in task-based intelligent dialogues, it is first necessary to identify new business-related intent texts from a large amount of unknown intent texts, and provide a reference for intent library maintainers to add new intents, so as to train the dialogue management module based on the updated intent library and ensure the effective operation of the intelligent dialogue system. Summary of the Invention
[0005] In view of this, the embodiments of the present application provide an intent recognition method and device, an electronic device and a storage medium, which are conducive to accurately identifying new intents appearing in unknown intent texts.
[0006] In a first aspect, an embodiment of the present application provides an intent recognition method, comprising: inputting a first text and a second text after the N-1th round of annotation into a first model after the N-1th round of training to perform an N-th round of training on the first model, wherein the first text includes a known intent text with a fixed label in a sample set, and the second text after the N-1th round of annotation includes an unknown intent text with a temporary label in the sample set, wherein at least part of the unknown intent text in the sample set has a temporary label after the first round of annotation, and N≥2; inputting the known intent text, the unknown intent text with the temporary label, and the unknown intent text without the temporary label in the sample set into the Nth round of training. After the first model is trained, a representation vector of each text in the sample set is obtained; hierarchical clustering is performed on all the texts in the sample set according to the representation vector of each text to obtain multiple clusters, and the clusters in which the number of texts is greater than or equal to a preset threshold are determined to be credible clusters; based on the ratio of fixed labels corresponding to known intent texts and temporary labels corresponding to unknown intent texts in each credible cluster, temporary labels are annotated on the unknown intent texts in the credible clusters to obtain the second text after the Nth round of annotation; iterate the above steps, and when multiple clusters meet the preset convergence conditions, output the second text and the temporary label corresponding to the second text.
[0007] In a second aspect, an embodiment of the present application provides an intent recognition device, comprising: a training module for inputting a first text and a second text after the N-1th round of annotation into a first model after the N-1th round of training to perform an N-th round of training on the first model, wherein the first text includes a known intent text with a fixed label in a sample set, and the second text after the N-1th round of annotation includes an unknown intent text with a temporary label in the sample set, wherein at least part of the unknown intent text in the sample set has a temporary label after the first round of annotation, and N≥2; a computing module for inputting the known intent text, the unknown intent text with a temporary label, and the unknown intent text without a temporary label in the sample set into the N-1th round of training. The first model after rounds of training obtains the representation vector of each text in the sample set; the clustering module is used to hierarchically cluster all the texts in the sample set according to the representation vector of each text, obtain multiple clusters, and determine the clusters in which the number of texts is greater than or equal to a preset threshold as credible clusters; the labeling module is used to label the unknown intent texts in the credible clusters with temporary labels based on the ratio of fixed labels corresponding to known intent texts and temporary labels corresponding to unknown intent texts in each credible cluster, and obtain the second text after the Nth round of labeling; the output module is used to output the second text and the temporary labels corresponding to the second text when multiple clusters meet the preset convergence conditions.
[0008] In a third aspect, an embodiment of the present application provides an electronic device comprising: a processor; and a memory for storing processor-executable instructions, wherein the processor is used to execute the intent recognition method provided in the first aspect above.
[0009] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program is used to execute the intention recognition method provided in the first aspect above.
[0010] The embodiment of the present application provides an intent recognition method and device, an electronic device and a storage medium, which iteratively trains a first model based on known intent texts and updated unknown intent texts with temporary labels, hierarchically clusters all texts based on the representation vectors of the texts output by the trained first model using a hierarchical clustering algorithm, labels the unknown intent texts according to the clustering results, and outputs the unknown intent texts with temporary labels when the clustering results meet the convergence conditions. The first model is trained with known intent texts with fixed intent labels and unknown intent texts with temporary labels, so that the first model continuously learns more texts with unknown intent, so that the representation vectors of each text output by the trained first model can more accurately represent the intent of each text, and by hierarchically clustering the text representation vectors of each text output by the first model, a clustering result with a better clustering effect can be obtained. In this way, the temporary labels of the unknown intent texts of the credible cluster clusters can be added or updated according to the clustering results, and finally, the new intent texts in the unknown intent texts are accurately identified, wherein the new intent texts are texts identified from the unknown intent texts and labeled with temporary labels different from the fixed labels. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1a Shown is a flowchart of an intention recognition method provided by an exemplary embodiment of the present application.
[0012] Figure 1b Shown is a schematic diagram of the network structure of a first model provided by an exemplary embodiment of the present application.
[0013] Figure 2a Shown is a schematic diagram of partitioning a hierarchical tree (partial structure) based on a target bifurcation distance provided by an exemplary embodiment of the present application.
[0014] Figure 2b Shown is a schematic diagram of a marking intention label provided by an exemplary embodiment of the present application.
[0015] Figure 2c Shown is a schematic diagram of a labeling intention provided by another exemplary embodiment of the present application.
[0016] Figure 2dShown is a schematic diagram of the network structure of the second model provided by an exemplary embodiment of the present application.
[0017] Figure 3 Shown is a flowchart of an intention recognition method provided by another exemplary embodiment of the present application.
[0018] Figure 4 Shown is a schematic diagram of partitioning a hierarchical tree (partial structure) based on a target bifurcation distance provided by another exemplary embodiment of the present application.
[0019] Figure 5 Shown is a flowchart of the trusted clustering intent label confirmation provided by an exemplary embodiment of the present application.
[0020] Figure 6 Shown is a schematic structural diagram of an intention recognition device provided by an exemplary embodiment of the present application.
[0021] Figure 7 Shown is a block diagram of an electronic device for executing an intent recognition method provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0022] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0023] Related technologies
[0024] After the task-based dialogue system is deployed, new intents gradually emerge in intelligent dialogue scenarios as the business develops and changes. For example, in the insurance Q&A scenario, a user learns about a newly released insurance product A through offline promotional channels, and then consults the online intelligent customer service system for detailed information about insurance product A. However, since the intent text related to insurance product A has not yet been added to the intent library, the intelligent robot cannot recognize questions about insurance product A, and is therefore unable to answer users' questions accurately and promptly. To ensure the effective conduct of intelligent dialogue, it is first necessary to identify or discover new intent texts from unknown intent texts. Managers label the new intent texts with intent tags by browsing their contents, and then add the labeled new intent texts to the intent library and train the intent recognition model as known intent texts. The trained intent recognition model can thus improve its ability to recognize unknown intent texts and improve customer service effectiveness.
[0025] Among related methods for discovering new intents, the k-means clustering algorithm can be used to cluster text with unknown intents, generating multiple groups of text with similar intents. However, due to the continuous nature of the semantic space, it does not satisfy the k-means algorithm's spherical space assumption. Furthermore, the k-means clustering algorithm requires specifying the number of clusters, a value that significantly impacts the clustering performance. Consequently, these issues can lead to poor clustering and discovery of new intents. Alternatively, a method for discovering new intents can be used to pre-train the BERT deep learning model based on business data. The pre-trained BERT model is then used to generate embedding vectors for user conversation texts. Machine learning algorithms are then used to reduce the dimensionality of these embedding vectors to low-dimensional vectors. Specifically, principal component analysis (PCA) is used to reduce the dimensionality of the sentence embeddings to vectors with representative feature information. A machine learning algorithm (DBSCAN) clustering algorithm is then applied to the reduced embedding vectors, and the algorithm's hyperparameters are adjusted to obtain clustered text information. However, this method uses BERT for pre-training, and the vector representation obtained by this method is relatively dense. PCA dimensionality reduction followed by DBSCAN clustering does not make the semantic space more sparse and separable, which affects the effectiveness of discovering new intents. Therefore, the present application provides an intent recognition method that can identify new intent texts from a large number of unknown intent texts and cluster new intent texts with similar intents into a group. This method has a good effect in identifying new intents.
[0026] Exemplary Methods
[0027] Figure 1a Shown is a flowchart of an intention recognition method provided by an exemplary embodiment of the present application. Figure 1a The method may be executed by a computing device, such as a server. Figure 1a As shown, the intention recognition method includes the following contents.
[0028] 110: Input the first text and the second text after the N-1th round of annotation into the first model after the N-1th round of training to perform the Nth round of training on the first model, wherein the first text includes the known intent text with fixed labels in the sample set, and the second text after the N-1th round of annotation includes the unknown intent text with temporary labels in the sample set, wherein at least part of the unknown intent text in the sample set has temporary labels after the first round of annotation, and N≥2.
[0029] Known intent text is text in the sample set that has a known intent label. This known intent label can be a label that the administrator annotates based on the text content to express the text's intent. For example, a known intent text might read "How much does this dress cost?", which would be labeled with the known intent label "Price Inquiry". Unknown intent text is text to be identified in the sample set that does not have a known intent label. After the first round of labeling, some of the labeled unknown intent text will have temporary labels.
[0030] The first text is a known intent text in the sample set, and its known intent label is a fixed label, that is, the known intent label of each text in the first text is fixed. All unknown intent texts in the initial sample set do not have labels. The second text refers to the unknown intent text with a temporary label in the sample set after the first round of labeling. The temporary label of the second text may change after each round of labeling. For example, for an unknown intent text in the sample set, the temporary label marked as "new intent 1" in the first round may be marked as "price consultation" in the second round. In addition, the temporary label may include a known intent label (such as "price consultation") and a new intent label (for example, "new intent 1"), wherein the known intent label is the known intent label in the first text, and the new intent label is a newly added label different from the known intent label. It should be noted that for the sake of convenience, the known intent label and the new intent label are both referred to as intent labels in the embodiment of the present application, that is, both fixed labels and temporary labels can be referred to as intent labels.
[0031] Figure 1b The diagram shows a network structure diagram of the first model provided by an exemplary embodiment of the present application. Figure 1b As shown, the network structure of the first model includes an encoding network and a classification network, wherein the classification network includes a pooling layer and a classification layer. After encoding, the text is input into the encoding network of the first model to obtain a representation vector, and the sentence vector in the representation vector (the representation vector corresponding to the [CLS] symbol) is input into the classification network to obtain a classification feature vector. The representation vector of each text output by the encoding network is specifically a word vector sequence. The word vector sequence refers to the sorted word vectors, and the order of the word vectors corresponds to the order of the words in the text.
[0032] Specifically, a [CLS] symbol is inserted before each text, and the output vector corresponding to the [CLS] symbol is used as the semantic representation of each text for text classification. In this embodiment of the application, the vector corresponding to the [CLS] symbol is called a sentence vector, such as Figure 1b The first position shown represents a vector.
[0033] In the first round of training for the first model, the first model is trained through a classification task based on the first text in the sample set, and the weights of the first model network are updated after the training is completed. The first text is a plurality of texts with known intents.
[0034] In the Nth round of training of the first model, the first model is trained through a classification task based on the first text in the sample set and the second text obtained in the N-1th round. After the training is completed, the network weight of the first model is updated, where N≥2.
[0035] 120: Input the known intent texts, the unknown intent texts with temporary labels, and the unknown intent texts without temporary labels in the sample set into the first model after the Nth round of training to obtain a representation vector for each text in the sample set.
[0036] Specifically, in step 110, the first model is trained for the Nth round to obtain a first model with updated model parameters, and all texts in the sample set are input into the first model with updated weights obtained by the Nth round of training to output a representation vector (representation vector sequence) for each text.
[0037] 130: Perform hierarchical clustering on all the texts in the sample set according to the representation vector of each text to obtain multiple clusters, and determine the clusters in which the number of texts is greater than or equal to a preset threshold as credible clusters.
[0038] Hierarchical clustering is a clustering algorithm that creates a hierarchical nested cluster tree by calculating the similarity between data points of different categories.
[0039] Based on the sentence vector representing each text obtained in step 120, the cosine distance between the sentence vectors of each text is used as the distance function, and a hierarchical clustering algorithm is used to obtain a hierarchical tree (cluster tree) including each text. The hierarchical tree is divided into multiple clusters based on the hierarchical tree partitioning algorithm, and each cluster includes at least one text. The number of texts in each cluster is calculated, and clusters in which the number of texts is greater than or equal to a preset threshold are determined as credible clusters, and clusters that do not meet the requirement are determined as uncredible clusters.
[0040] The hierarchical clustering algorithm does not need to subjectively set the number of clusters, thus avoiding the problem of poor clustering effect caused by unreasonable setting of the number of clusters.
[0041] 140: Based on the ratio of fixed labels corresponding to known intent texts and temporary labels corresponding to unknown intent texts in each credible cluster, the unknown intent texts in the credible cluster are labeled with temporary labels to obtain the second text after the Nth round of labeling.
[0042] For at least one trusted cluster, each trusted cluster is labeled with an intent label, and then the intent label of the trusted cluster is used to label all unknown intent texts in the trusted cluster. The unknown intent text here refers to unknown intent text with temporary labels and text without temporary labels. After labeling, the unknown intent texts in the trusted cluster all have the same intent label.
[0043] Specifically, each trusted cluster is labeled with an intent label based on the proportion of each intent label in the trusted cluster. In one embodiment, when an intent label that meets a preset condition exists in the trusted cluster, the unknown intent text in the trusted cluster is labeled with the intent label; if an intent label that meets the preset condition does not exist, the unknown intent text in the trusted cluster is labeled with a new intent label. In addition, the labeled unknown intent text is the second text.
[0044] Exemplarily, for one of the credible clusters, the credible cluster includes multiple known intent texts marked with intent label A, multiple unknown intent texts marked with intent label B, and multiple unknown intent texts without intent labels. The proportions of texts marked with intent label A and intent label B are calculated respectively. If the proportion of texts marked with intent label A meets the preset conditions, the unknown intent texts in the credible cluster are marked with intent label A. After marking, the original multiple unknown intent texts marked with intent label B in the cluster are updated to unknown intent texts marked with intent label A, and the original multiple unknown intent texts without intent labels are updated to unknown intent texts marked with intent label A; if the proportions of texts marked with intent label A and intent label B do not meet the preset conditions, the unknown intent texts in the credible cluster are marked with the newly added intent label.
[0045] 150: Iterate the above steps, and when multiple clusters meet the preset convergence condition, output the second text and the temporary label corresponding to the second text.
[0046] Iterate step 110 to step 140 until multiple clusters meet the preset convergence conditions, and output the second text and the temporary label corresponding to the second text, where the second text is the unknown intent text with the temporary label, where the temporary label of the unknown intent text includes the known intent label and the new intent label, and the second text marked with the new intent label is the new intent text identified from the unknown intent text.
[0047] New intent text can be output as clusters, and the distance relationship between each cluster will be retained in the output, making it easier for administrators to merge clusters with similar intents.
[0048] Specifically, clustering performance metrics can be used to evaluate whether the clustering results meet the convergence conditions. Clustering performance metrics can be compactness, seperation, Davies-bouldin Index (DBI), or Silhouette Coefficient.
[0049] During the iterative process from step 110 to step 140, the results of each round of annotation of the unknown intent text are saved. The output results include: the weight of the first model, each trusted cluster and its label, and the hierarchical tree structure between each trusted cluster. These results are output for the administrator to reference and view the clustering results.
[0050] The embodiment of the present application provides an intent recognition method, which iteratively trains a first model based on known intent texts and updated unknown intent texts with temporary labels, hierarchically clusters all texts based on the representation vectors of the texts output by the trained first model using a hierarchical clustering algorithm, labels the unknown intent texts according to the clustering results, and outputs the unknown intent texts with temporary labels when the clustering results meet the convergence conditions. The first model is trained with known intent texts with fixed intent labels and unknown intent texts with temporary labels, so that the first model continuously learns more texts with unknown intent, so that the representation vectors of each text output by the trained first model can more accurately represent the intent of each text, and by hierarchically clustering the text representation vectors of each text output by the first model, a clustering result with better clustering effect can be obtained. In this way, the temporary labels of the unknown intent texts of the credible cluster clusters can be added or updated according to the clustering results, and finally, the new intent texts in the unknown intent texts are accurately identified, wherein the new intent texts are texts identified from the unknown intent texts and labeled with temporary labels different from the fixed labels.
[0051] In one embodiment, the preset convergence condition is that the silhouette coefficient of the credible clustering cluster obtained according to the first model after the Mth round of training is greater than or equal to the silhouette coefficient of the credible clustering cluster obtained according to the first model after the M-1th round of training, and the silhouette coefficient of the credible clustering cluster obtained according to the first model after the M+1th round of training is less than the silhouette coefficient of the credible clustering cluster obtained according to the first model after the Mth round of training, where M≥2.
[0052] Specifically, based on the representation vector of each text output by the first model after the current round of training, all texts are clustered to obtain multiple clusters, and at least one credible cluster is determined among the multiple clusters. The preset convergence condition can be to calculate the total silhouette coefficient for all credible clusters. When the total silhouette coefficient meets certain conditions, the clustering result is considered to be good, the iterative training is stopped, and the clustering cluster result obtained when the convergence condition is met is output.
[0053] Optionally, the preset convergence condition can be a preset threshold or a trend in the total silhouette coefficient. For example, if the total silhouette coefficient increases from round 1 to round M and then suddenly decreases or remains unchanged in round M+1, then the total silhouette coefficient of the credible clusters in round M is considered to be the highest, the clustering effect is the best, and the preset convergence condition is met. By using the total silhouette coefficient of the credible clusters in each round as the convergence condition, the clustering results of the text can be effectively supervised.
[0054] The calculation formula of the total silhouette coefficient SC is as follows:
[0055]
[0056] Among them, a(I i ) indicates I i with I i The average distance to other samples in the cluster, b(I i ) means I i The minimum distance to the average distance of samples in other clusters.
[0057] In one embodiment, all texts in a sample set are hierarchically clustered based on a representation vector of each text to obtain a plurality of clusters, including: generating a hierarchical tree based on a sentence vector in a representation vector of each text in the sample set; traversing the plurality of candidate bifurcation distances in the hierarchical tree in ascending order, obtaining a plurality of candidate clusters based on each candidate bifurcation distance, and stopping traversing the plurality of candidate bifurcation distances until one of the current plurality of candidate clusters meets a preset rule, wherein each candidate bifurcation distance in the plurality of candidate bifurcation distances represents an average value of distances between a plurality of texts that bifurcate corresponding to the candidate bifurcation distance; determining the current candidate bifurcation distance as a target bifurcation distance, and dividing the hierarchical tree based on the target bifurcation distance to obtain a plurality of clusters.
[0058] The cosine distance between the first position representation vectors is used as the distance function, and the hierarchical tree (clustering tree) of each text is obtained by the hierarchical clustering algorithm.
[0059] The sentence vectors in the representation vector of each text are selected, and the cosine distance between each sentence vector is used as the distance function. A hierarchical clustering algorithm is used to obtain a hierarchical tree. Based on the hierarchical tree, multiple candidate bifurcation distances can be obtained.
[0060] Figure 2a FIG. 1 is a schematic diagram showing a hierarchical tree (partial structure) partitioned based on target bifurcation distance provided by an exemplary embodiment of the present application. Figure 2a As shown in the figure, a part of the hierarchical tree structure is used as an example to specifically illustrate the process of obtaining clusters. The vertical axis in the hierarchical tree represents the distance between texts. Based on the hierarchical tree, multiple candidate bifurcation distances D1, D2, and D3 can be obtained. The multiple candidate bifurcation distances are arranged in ascending order as D1, D2, and D3, where D1 is the distance between text 3 and text 4 at its corresponding bifurcation point a, D2 is the distance between text 1 and text 2 at its bifurcation point b, and D3 is the average distance between each two texts in text 1, text 2, text 3, and text 4 at its corresponding bifurcation point c. The distance between texts represents the similarity between texts. Multiple texts at each bifurcation point belong to a cluster. For example, bifurcation point a means that text 3 and text 4 belong to a cluster, bifurcation point b means that text 1 and text 2 belong to a cluster, and bifurcation point c means that text 1, text 2, text 3, and text 4 belong to a cluster. By traversing multiple candidate bifurcation distances in ascending order, and dividing the hierarchical tree based on each candidate bifurcation distance, at least one candidate cluster can be obtained.
[0061] For example, the cluster tree is divided by candidate bifurcation distance D1, and a horizontal straight line with a ordinate less than or equal to D1 is used as the dividing line to divide the hierarchical tree. Since there is a bifurcation point a, text 3 and text 4 are clustered into one cluster. Then, based on candidate bifurcation distance D1, three candidate clusters are obtained, namely candidate cluster 1 (text 1), candidate cluster 2 (text 2), and candidate cluster 3 (text 3, text 4). For another example, the cluster tree is divided by candidate bifurcation distance D3, and a horizontal straight line with a ordinate less than or equal to D3 and a ordinate greater than D2 is used as the dividing line. Since there is a bifurcation point c, bifurcation point c clusters text 1, text 2, text 3, and text 4 into one cluster, thereby obtaining one candidate cluster (text 1, text 2, text 3, text 4).
[0062] By dividing the hierarchical tree based on different candidate bifurcation distances, different candidate clusters can be obtained. When there is no cluster that meets the preset rules among the multiple candidate clusters obtained by the current candidate bifurcation distance, the next candidate bifurcation distance is selected in sequence for division. When a cluster that meets the preset rules is found among the multiple candidate clusters, the current candidate bifurcation distance is determined to be the target bifurcation distance, and the determination operation of the candidate bifurcation distance is terminated. The hierarchical tree is divided according to the target bifurcation distance to obtain multiple clusters. The target bifurcation distance is the smallest bifurcation distance among the multiple candidate bifurcation distances that meet the preset rules.
[0063] Optionally, the preset rule may be set based on the ratio of intent labels in the candidate clusters.
[0064] In this embodiment, a target bifurcation distance that satisfies preset rules is determined by traversing multiple candidate bifurcation distances in a hierarchical tree. This target bifurcation distance is then used to partition the hierarchical tree into at least one cluster. This method does not require a specific number of clusters, avoiding the problem of poor clustering results caused by an inappropriate number of clusters. This method can better address the problem of identifying new intents and improve the effectiveness of new intent recognition.
[0065] In one embodiment, the current multiple candidate clusters include a first candidate cluster, the sample set includes a first number of first intent texts, the first intent texts are texts marked with a first intent label, and the preset rule is: the ratio of the number of first intent texts in the first candidate cluster to the number of all texts in the first candidate cluster is greater than or equal to a first threshold, and the ratio of the number of first intent texts in the first candidate cluster to the first number is greater than or equal to a second threshold.
[0066] Specifically, a judgment is made based on preset rules for each candidate cluster among the multiple candidate clusters. For the current first candidate cluster, the proportion of texts of each intent label in the first candidate cluster is calculated, and the ratio of the number of first intent texts marked with the first intent label to the number of all texts in the cluster is taken as the first ratio, and the ratio of the number of first intent texts in the first candidate cluster to the number of first intent texts in all candidate clusters is taken as the second ratio. When the first ratio and the second ratio are both greater than or equal to the preset threshold, the first candidate cluster satisfies the preset rules. Optionally, when the first ratio or the second ratio is greater than or equal to the preset threshold, the first candidate cluster satisfies the preset rules. Exemplarily, the first threshold and the second threshold can be set to 90%. It should be noted that the embodiment of the present application does not specifically limit the setting of the first threshold and the second threshold.
[0067] In one embodiment, the trusted clustering cluster includes a first trusted clustering cluster, the first trusted clustering cluster includes a second intent text marked with a second intent label, and the unknown intent text in the trusted clustering cluster is marked with a temporary label, including: when the number of second intent texts in the first trusted clustering cluster meets a preset condition, the unknown intent text in the first trusted clustering cluster is marked with the second intent label; when there is no text that meets the preset condition in the first trusted clustering cluster, the unknown intent text in the first trusted clustering cluster is marked with a newly added temporary label.
[0068] Specifically, step 140 further includes: marking each credible cluster with an intent label. Specifically, the preset condition may include a first preset condition and a second preset condition.
[0069] Determine the first preset condition, calculate the ratio of the number of texts with intent labels in the first credible cluster to the number of all texts in the first credible cluster as a third ratio, and calculate the ratio of the number of texts with each intent label in the first credible cluster to the number of all texts in the first credible cluster as a fourth ratio. When the third ratio is greater than or equal to the third threshold, and there are intent labels with a fourth ratio greater than or equal to the fourth threshold, label the intent label with the largest proportion that meets the requirements as the intent label of the first credible cluster, and use the intent label with the largest proportion to label the unknown intent texts in the credible cluster.
[0070] Furthermore, when there is no intent label that meets the first preset condition in the first credible cluster, the second preset condition is judged, and a certain number of texts in the center of the first credible cluster are selected. If the selected certain number of texts include texts marked with intent labels, the intent labels are voted on, and the intent label with the most votes is selected as the intent label of the credible cluster.
[0071] Furthermore, when there is no intent label that meets the first preset condition and the second preset condition, the first credible cluster is initialized, that is, a new intent label is added, and the new intent label is used to label the unknown intent text in the first credible cluster.
[0072] Figure 2b Shown is a schematic diagram of a marking intention label provided by an exemplary embodiment of the present application. Figure 2c FIG. 1 is a schematic diagram of a label indicating an intention provided by another exemplary embodiment of the present application. Figure 2b As shown, when the text labeled with "Known Intent 1" meets the preset conditions, "Known Intent 1" is used to confirm the label of the unknown intent text in the trusted cluster.
[0073] like Figure 2cAs shown, in the Nth round, the trusted clusters are labeled. If there is no text with an intent label in the trusted cluster or no intent label that meets the preset conditions, "New Intent 1" is determined as the label of the cluster, and all unknown intent texts in the cluster are labeled with the label "New Intent 1". In the N+1th round, the trusted clusters are labeled. If there is a text with an intent label (text with the intent label "New Intent 1") in one of the trusted clusters, "New Intent 1" is determined as the intent label of the trusted cluster based on the voting results. If there is no text with an intent label in one of the trusted clusters, "New Intent 2" is determined as the intent label of the trusted cluster.
[0074] In one embodiment, the network structure of the first model includes a first encoding network and a first classification network. The N-th round of training of the first model in step 110 includes: using the first encoding network to process the first text and the second text after the N-1th round of annotation to obtain a representation vector of each text; using the first classification network to process the sentence vector in the representation vector of each text to obtain a first classification feature vector of each text; determining a loss function based on the first classification feature vector and the fixed label of the first text and the temporary label of the second text; and performing the N-th round of training on the first model based on the loss function to obtain the first model after the N-th round of training.
[0075] Specifically, the network structure of the first model includes an encoding network layer and a classification network layer. The first model is trained through a classification task using text with intent labels, where the text with intent labels includes the first text and the second text obtained after the previous round of annotation. The intent labels include the fixed label of the first text and the temporary label of the second text. First, the intent labels are encoded; then the text with intent labels is input into the first model, and the representation vector of each text is obtained based on the encoding network. The sentence vector of each text is input into the classification network to obtain the classification feature vector of each text; finally, the cross-entropy loss is calculated based on the classification feature vector and the intent label, and the cross-entropy loss is minimized using the optimizer to update the parameters (weights) of the first model, completing one round of training.
[0076] In one embodiment, Figure 1a The method of the embodiment further includes: inputting the first text into the first model for a first round of training to obtain a first model after the first round of training.
[0077] In one embodiment, the first text is a text in a single business field. Before the first text is input into the first model for the first round of training, Figure 1aThe method of the embodiment also includes: using third texts from multiple business fields to train the second model to obtain a trained second model, wherein the second model includes a second encoding network and the third text is a known intent text with a fixed label; and using the parameters of the second encoding network of the trained second model as the initial values of the parameters of the first encoding network of the first model.
[0078] Third text from multiple business domains refers to a dataset of texts with known intent across multiple business domains, characterized by multiple texts sharing the same known intent label. Third text can be a large number of texts with known intent across multiple business domains (all domains), for example, 500,000.
[0079] Optionally, the second model can be composed of an encoding network and a classification network. The parameters of the encoding network in the trained second model are used to initialize the parameters of the encoding network in the first model, and the initial parameters of the encoding network layer of the first model are obtained. According to an embodiment of the present application, the training process of the second model is based on a large number of known intent texts in various business fields, which improves the generalization of the second model and can obtain a sparsely represented semantic space, which is conducive to the accurate recognition of text intent. In addition, initializing the parameters of the encoding network of the first model based on the trained encoding network of the second model can improve the accuracy of the first model in the first round of training, which is conducive to improving the convergence speed of the first model and the accuracy of discovering new intent texts.
[0080] In one embodiment, the network structure of the second model includes a second encoding network, a language model network, a second classification network and a text representation network, and the second model is trained using third texts from multiple business fields, including: using the encoding network to process the third text to obtain a representation vector for each text in the third text; using the language model network to process the representation vector of each text in the third text to obtain a language model feature vector; using the second classification network to process the sentence vector in the representation vector of each text in the third text to obtain a second classification feature vector; using the text representation network to process the sentence vector in the representation vector of each text in the third text to obtain a text representation vector; wherein, a first loss is calculated based on the language model feature vector, a second loss is calculated based on the second classification feature vector, and a third loss is calculated based on the third text representation vector, and the second model is trained based on the first loss, the second loss and the third loss.
[0081] Figure 2d FIG2 is a schematic diagram of the network structure of the second model provided by an exemplary embodiment of the present application. The training process of the second model includes the following steps.
[0082] The known intent texts from various business fields are encoded and input into the encoding network, which outputs a representation vector (representation vector sequence) for each text. The representation vector is then input into the language model network to obtain a language model feature vector (language model feature vector). The sentence vector of each text is then input into the classification network to obtain a classification feature vector. The sentence vector of each text is then input into the text representation network to obtain a text representation vector. The language model network is used to train the second model to focus on the information of each word in the text, making the second model more suitable for online conversation scenarios. The intent classification network is used to train the second model to recognize the concept of the text intent. The text representation network is used to train the second model to recognize the representation vector of the intent, so that the representation vectors of the same intent are close, while the representation vectors of different intents are far apart.
[0083] The word segmenter is used to segment and encode the same text twice. During segmentation, the words are randomly masked and the masked positions and original words are annotated. The two encodings are used as reference samples and positive samples respectively, and the encodings of different texts are used as negative samples.
[0084] All codes are input into the second model to obtain text representation vector, language model feature vector, and classification feature vector.
[0085] The vector of the language model feature vector at the mask position is extracted as the mask feature vector, and the cross entropy loss between the mask feature vector and the original word at the mask position is calculated as the first loss.
[0086] The cross entropy loss between the classification feature vector and the intent label of the known intent text is calculated as the second loss.
[0087] Calculate the inner product between the text representation vectors of the reference sample and the positive sample as the positive sample score, and simultaneously calculate the inner product between the text representation vectors of the reference sample and the negative sample as the negative sample score. Concatenate the positive sample score and the negative sample score to obtain a first score vector, and divide the first score vector by the first hyperparameter to obtain a second score vector. Calculate the cross entropy loss between the second score vector and the position of each positive sample as the third loss;
[0088] The fourth loss is obtained by weighted addition of the first loss, the second loss, and the third loss, and the fourth loss is minimized using the Adam optimizer with weight decay.
[0089] According to the method provided in this embodiment, four cross-entropy losses are calculated based on the four network layers of the second model to train the second model so that the second model can better adapt to online conversation scenarios and recognize the intention of the text. The parameters of the trained encoding network are used as the initial parameters of the encoding network of the first model, thereby improving the accuracy of the first model in the first round of training.
[0090] In order to clearly and completely describe the technical solution of the embodiment of the present application, the implementation process of the method provided in the embodiment of the present application in the dialogue scenario of the insurance industry is further described in detail below with reference to the accompanying drawings.
[0091] Figure 3 Shown is a flowchart of an intention recognition method provided by another exemplary embodiment of the present application.
[0092] Figure 3 The method may be executed by a computing device, such as a server. Figure 3 The method shown is Figure 1a In order to avoid repetition, the same parts of the examples in the embodiments will not be described again. Figure 3 As shown, the method includes the following contents.
[0093] 310: Train a second model using intent recognition datasets from multiple business domains.
[0094] like Figure 2d As shown, the network structure of the second model includes an encoding network, a language model network, an intent classification network, and a text representation network.
[0095] The encoding network can choose the open source pre-trained language model chinese-roberta-wwm-ext; the pooling layer in the language model network consists of a dropout layer with a dropout probability of 0.2 and a double-layer 768x768 MLP network. The hidden layer activation function between the MLP layers is the Tanh function. The hidden layer size of the word classification layer in the language model network is 768 dimensions, and the softmax dimension is 21128; the classification pooling layer in the intent classification network selects a double-layer 768x768 MLP network, the hidden layer activation function is the Tanh function, and the classification softmax layer selects a 768x5712 MLP network; the representation pooling layer in the text representation network is composed of a 768X768 dense layer.
[0096] The input features of the second model are encoded through the network to obtain the representation vector corresponding to each word in the text; the representation vector is input into the language model network to obtain a 2D language model feature vector; the sentence vector is input into the text representation network, and its output is normalized by the two-norm to obtain a 768-dimensional text representation vector; the sentence vector is input into the intent classification network to obtain a 5712-dimensional classification feature vector.
[0097] Specifically, for training the second model, we selected 500,000 intent-labeled, client-side anonymized texts from historical conversations as training text. We then processed the training texts by replacing """ and """ with """, replacing "'" and "'" with "'", replacing characters between non-whitespace characters with ",", and filtering text with fewer than five characters.
[0098] The processed training text is segmented by the word segmenter. After the segmentation is completed, 10% of the words in the segmentation results are randomly selected for masking, which is divided into three cases:
[0099] a) With a 75% probability, replace with a masked word;
[0100] b) With a 15% probability, replace with a random word;
[0101] c) 10% probability, no action is taken.
[0102] The selected original word is used as the predicted label, and the words in other positions are masked with -100.
[0103] Furthermore, the second model is trained using the encoded training text. The specific training method is as follows.
[0104] a) Repeat the input of each batch twice in the first dimension and expand it to the second dimension;
[0105] b) Input the 0 position of the second dimension as the reference sample, the 1 position as the positive sample, and the other positions in the first dimension as negative samples;
[0106] c) inputting the processed input text into a second model to obtain a language model feature vector, a text representation vector, and a classification feature vector;
[0107] d) Extract the non-100 positions from the predicted labels, extract the vectors of the language model feature vectors corresponding to these positions, and calculate the cross entropy losses in pairs with the predicted labels. The average of the cross entropy losses is selected as the first loss.
[0108] e) Calculate the cross entropy loss between the classification feature vector and the intent label of the training text as the second loss;
[0109] f) Calculate the inner product between the text representation features of the reference sample and each positive sample in the batch to obtain the positive sample score, and the inner product between the text representation features of the reference sample and each negative sample as the negative sample score. Concatenate the scores of each positive sample and the negative sample in the batch to obtain a first score vector, and divide the first score vector by 0.06 to obtain a second score vector. Calculate the cross entropy loss between the second score vector and the rank of each positive sample position as the third loss;
[0110] g) the fourth loss is obtained by adding the first loss, the second loss multiplied by 0.3, and the third loss multiplied by 0.5;
[0111] h) Use the Adam optimizer with weight decay to minimize the fourth loss. For example, the learning rate of the Adam optimizer is 3e -5 , the weight decay coefficient is 1e -2 .
[0112] 320: Initialize parameters of the encoding network of the first model based on the encoding network of the second model.
[0113] The network structure of the first model consists of an encoding network and a classification network. The encoding network of the first model is consistent with the encoding network of the second model, and the initial weights are the weights of the encoding network layer of the second model after training. The classification network of the first model consists of a dropout layer with a dropout rate of 0.3 and a 768x768 dense layer, and the classification softmax layer consists of a 768x2000 dense layer.
[0114] 330: Train a first model through a classification task based on the text with intent labels.
[0115] During the first model training, data from the insurance Q&A scenario was selected. This data included both known intent texts annotated with known intent labels and unknown intent texts. The known intent texts were selected from the intent training set, totaling 10,000 texts across 103 categories. The unknown intent texts included 50,000 online user questions predicted by the intent recognition model and 100,000 online user questions missed by the system's object-oriented model.
[0116] All the above texts are processed, including replacing special characters, replacing space characters, and filtering texts with fewer characters.
[0117] The training process of the first model includes the following specific contents.
[0118] Before the first model training begins, the intent labels are encoded from 0 to 102.
[0119] During the first round of training for the first model, text with intent labels is encoded by the tokenizer and fed into the model in batches. A 2000-dimensional categorical feature vector is calculated, and the cross-entropy loss is calculated based on the categorical feature vector and the known intent labels. The Adam optimizer is then used to minimize the cross-entropy loss, and the weights of the first model are updated based on the gradient.
[0120] In the above way, the text with intent labels is input into the first model in batches for one round of training. In this embodiment, a total of 2343 steps are trained with a learning rate of 1e -5 .
[0121] It should be noted that the texts with intent labels in the first round are 10,000 texts selected from the intent training set texts, and the texts with intent labels in the Nth round include 10,000 texts selected from the intent training set texts and unknown intent texts marked with temporary intent labels, N≥2.
[0122] 340: Input the known intent text and the unknown intent text into the trained first model and calculate the representation vector sequence of each text.
[0123] Specifically, the unknown intent text includes text with a temporary intent label and text without a temporary intent label.
[0124] 350: Perform hierarchical clustering on the sentence vectors in the representation vector sequence obtained in step 340 to obtain a hierarchical tree.
[0125] 360: Traverse multiple candidate bifurcation distances of the hierarchical tree, determine a target bifurcation distance, and divide the hierarchical tree based on the target bifurcation distance to obtain at least one cluster, and determine at least one credible cluster in the at least one cluster.
[0126] Figure 4 FIG. 1 is a schematic diagram showing a method of dividing a hierarchical tree (partial structure) based on target bifurcation distance provided by another exemplary embodiment of the present application. Figure 4 The figure shows, from left to right, the Nth, N+1th, N+2th, and N+3th rounds of the first model training, where N ≥ 1. The dotted line represents the target bifurcation distance determined in the current round. As the first model is iteratively trained, from round N to round N+2, the target bifurcation distance increases, and the total silhouette coefficient of the credible clusters also increases. If the total silhouette coefficient decreases in round N+3, the total silhouette coefficient of round N+2 is considered the best. The first model of round N+2 is determined as the trained model, and the clustering and labeling results of round N+2 are used as the final intent recognition results.
[0127] It should be stated that Figure 4 The hierarchical tree shown is a partial structure. The texts in the clusters are only for illustrative purposes and do not mean that the clusters only include these texts.
[0128] 370: Label at least one credible cluster with an intent label.
[0129] Specifically, when the preset conditions are met, the intent label in the cluster is used to confirm the label of the trusted cluster, and the unknown intent text in the trusted cluster is marked; when the preset conditions are not met, the new intent label is used to confirm the label of the trusted cluster, and the unknown intent text in the trusted cluster is marked.
[0130] 380: Iterate steps 330 to 370 until the total silhouette coefficient of the credible clusters obtained in step 360 meets the convergence condition, and output the text marked with the new intent label in the unknown intent text as the recognized new intent text.
[0131] Figure 5 Shown is a flowchart of the trusted clustering intent label confirmation provided by an exemplary embodiment of the present application.
[0132] like Figure 5 As shown in FIG, the process of cluster label confirmation includes the following steps.
[0133] S371: Select one of the credible clusters.
[0134] S372: Determine whether there is an intention tag in the trusted cluster that meets the first preset condition.
[0135] If satisfied, execute step S373; if not satisfied, execute step S374.
[0136] Specifically, within the trusted cluster, the first pre-set condition is that the proportion of text with intent labels is greater than or equal to 50%, and the proportion of text with at least one intent label is greater than or equal to 30%. If there are intent labels that meet the first pre-set condition, the intent label with the largest proportion is determined as the intent label of the trusted cluster, and the unknown intent text in the trusted cluster is labeled using this intent label.
[0137] S373: Confirm the label of the credible cluster using the intention label that meets the first preset condition.
[0138] S374: Select K texts at the center of the credible cluster.
[0139] Specifically, the value of K can be set according to the business scenario, and the embodiments of the present application do not limit this.
[0140] S375: Determine whether there is an intent label in the K texts.
[0141] If it exists, execute step S376; if it does not exist, execute step S379.
[0142] S376: Vote for the intent labels present in the K texts.
[0143] S377: Determine the voting results.
[0144] If the vote is successful, execute step S378; if the vote is not successful, execute step S379.
[0145] S378: Confirm the intent label with the most votes as the intent label of the credible cluster.
[0146] S379: Confirm a new intent label for the trusted cluster.
[0147] Exemplary devices
[0148] Figure 6 FIG. 6 is a schematic diagram of the structure of an intention recognition device 600 provided by an exemplary embodiment of the present application. Figure 6 As shown, the intention recognition device 600 includes: a training module 610, a calculation module 620, a clustering module 630, a labeling module 640 and an output module 650.
[0149] The training module 610 is used to input the first text and the second text after the N-1th round of annotation into the first model after the N-1th round of training to perform the Nth round of training on the first model, where the first text includes the known intent text with a fixed label in the sample set, and the second text after the N-1th round of annotation includes the unknown intent text with a temporary label in the sample set, wherein at least part of the unknown intent text in the sample set has a temporary label after the first round of annotation, and N≥2.
[0150] The calculation module 620 is used to input the known intent text, the unknown intent text with temporary labels and the unknown intent text without temporary labels in the sample set into the first model after the Nth round of training to obtain the representation vector of each text in the sample set.
[0151] The clustering module 630 is used to perform hierarchical clustering on all the texts in the sample set according to the representation vector of each text to obtain multiple clusters, and determine the clusters with the number of texts greater than or equal to a preset threshold as credible clusters.
[0152] The labeling module 640 is used to label the unknown intent text in the credible cluster with temporary labels based on the ratio of fixed labels corresponding to the known intent text and temporary labels corresponding to the unknown intent text in each credible cluster, and obtain the second text after the Nth round of labeling.
[0153] The output module 650 is configured to output the second text and a temporary label corresponding to the second text when the plurality of clusters meet a preset convergence condition.
[0154] The embodiment of the present application provides an intent recognition device, which iteratively trains a first model based on known intent texts and updated unknown intent texts with temporary labels, hierarchically clusters all texts based on the representation vectors of the texts output by the trained first model using a hierarchical clustering algorithm, labels the unknown intent texts based on the clustering results, and outputs the unknown intent texts with temporary labels when the clustering results meet the convergence conditions. In this way, by learning more text intents, the representation vectors of the texts output by the first model can accurately distinguish the different intents of the texts, and then cluster all texts using a hierarchical clustering algorithm that does not require setting the number of clusters. The clustering results are more accurate, so that new intent texts can be more effectively identified from unknown intent texts, thereby improving the effect of identifying new intents.
[0155] In one embodiment, the preset convergence condition is that the silhouette coefficient of the credible clustering cluster obtained according to the first model after the Mth round of training is greater than or equal to the silhouette coefficient of the credible clustering cluster obtained according to the first model after the M-1th round of training, and the silhouette coefficient of the credible clustering cluster obtained according to the first model after the M+1th round of training is less than the silhouette coefficient of the credible clustering cluster obtained according to the first model after the Mth round of training, where M≥2.
[0156] In one embodiment, the clustering module 630 is also used to generate a hierarchical tree based on the sentence vector in the representation vector of each text in the sample set; traverse the multiple candidate bifurcation distances in the hierarchical tree in order from small to large, and obtain multiple candidate clustering clusters based on each candidate bifurcation distance, until one of the current multiple candidate clustering clusters meets the preset rules, and stop traversing the multiple candidate bifurcation distances, wherein each candidate bifurcation distance in the multiple candidate bifurcation distances represents the average value of the distances between the multiple texts of the bifurcation corresponding to the candidate bifurcation distance; determine the current candidate bifurcation distance as the target bifurcation distance, divide the hierarchical tree based on the target bifurcation distance, and obtain multiple clustering clusters.
[0157] Furthermore, the current multiple candidate clusters include a first candidate cluster, the sample set includes a first number of first intent texts, the first intent texts are texts marked with a first intent label, and the preset rule is: the ratio of the number of first intent texts in the first candidate cluster to the number of all texts in the first candidate cluster is greater than or equal to a first threshold, and the ratio of the number of first intent texts in the first candidate cluster to the first number is greater than or equal to a second threshold.
[0158] In one embodiment, the trusted cluster includes a first trusted cluster, and the first trusted cluster includes a second intent text marked with a second intent label. The marking module 640 is also used to use the second intent label to mark the unknown intent text in the first trusted cluster when the number of second intent texts in the first trusted cluster meets a preset condition; when there is no text that meets the preset condition in the first trusted cluster, use the newly added temporary label to mark the unknown intent text in the first trusted cluster.
[0159] In one embodiment, the network structure of the first model includes a first encoding network and a first classification network, and the training module 610 is further used to use the first encoding network to process the first text and the second text after the N-1th round of annotation to obtain a representation vector of each text; use the first classification network to process the sentence vector in the representation vector of each text to obtain a first classification feature vector of each text; determine the loss function based on the first classification feature vector and the fixed label of the first text and the temporary label of the second text; perform the Nth round of training on the first model based on the loss function to obtain the first model after the Nth round of training.
[0160] In one embodiment, the training module 610 is further configured to input the first text into the first model for a first round of training to obtain a first model after the first round of training.
[0161] In one embodiment, the first text is a text in a single business field, and the training module 610 is further used to train the second model using a third text in multiple business fields to obtain a trained second model, wherein the second model includes a second encoding network, and the third text is a known intent text with a fixed label; the parameters of the second encoding network of the trained second model are used as the initial values of the parameters of the first encoding network of the first model.
[0162] In one embodiment, the network structure of the second model includes a second encoding network, a language model network, a second classification network and a text representation network. The training module 610 is further used to use the encoding network to process the third text to obtain a representation vector for each text in the third text; use the language model network to process the representation vector of each text in the third text to obtain a language model feature vector; use the second classification network to process the sentence vector in the representation vector of each text in the third text to obtain a second classification feature vector; use the text representation network to process the sentence vector in the representation vector of each text in the third text to obtain a text representation vector; wherein, the first loss is calculated based on the language model feature vector, the second loss is calculated based on the second classification feature vector, and the third loss is calculated based on the third text representation vector, and the second model is trained based on the first loss, the second loss and the third loss.
[0163] It should be understood that the operations and functions of the training module 610, the calculation module 620, the clustering module 630, the labeling module 640 and the output module 650 in the above embodiment can refer to the above Figure 1a ,or Figure 3 To avoid repetition, the description of the intention recognition method provided in the embodiment will not be repeated here.
[0164] Figure 7 FIG2 is a block diagram of an electronic device 700 for executing an intent recognition method provided by an exemplary embodiment of the present application.
[0165] Reference Figure 7 The electronic device 700 includes a processing component 710, which further includes one or more processors, and a memory resource represented by a memory 720 for storing instructions executable by the processing component 710, such as an application. The application stored in the memory 720 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 710 is configured to execute the instructions to perform the above-mentioned intent recognition method.
[0166] The electronic device 700 may further include a power supply component configured to perform power management of the electronic device 700, a wired or wireless network interface configured to connect the electronic device 700 to a network, and an input / output (I / O) interface. The electronic device 700 may be operated based on an operating system stored in the memory 720, such as Windows Server 200. TM , Mac OSX TM , Unix TM , Linux TM , FreeBSD TM or similar.
[0167] A non-temporary computer-readable storage medium, when the instructions in the storage medium are executed by the processor of the electronic device 700, enables the electronic device 700 to perform an intent recognition method. The intent recognition method includes: inputting a first text and a second text after the N-1th round of annotation into a first model after the N-1th round of training to perform the Nth round of training on the first model, the first text includes a known intent text with a fixed label in the sample set, and the second text after the N-1th round of annotation includes an unknown intent text with a temporary label in the sample set, wherein at least part of the unknown intent text in the sample set has a temporary label after the first round of annotation, N≥2; inputting the known intent text, the unknown intent text with a temporary label, and the unknown intent text without a temporary label in the sample set into the first model after the Nth round of training , obtain the representation vector of each text in the sample set; hierarchically cluster all the texts in the sample set according to the representation vector of each text to obtain multiple clusters, and determine the clusters in which the number of texts is greater than or equal to a preset threshold as credible clusters; based on the ratio of fixed labels corresponding to known intent texts and temporary labels corresponding to unknown intent texts in each credible cluster, label the unknown intent texts in the credible clusters with temporary labels to obtain the second text after the Nth round of labeling; iterate the above steps, and output the second text and the temporary label corresponding to the second text when multiple clusters meet the preset convergence conditions.
[0168] All of the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, and will not be described in detail here.
[0169] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0170] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0171] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0172] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0173] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0174] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program check codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0175] It should be noted that, in the description of this application, the terms "first," "second," "third," etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, "plurality" means two or more.
[0176] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for identifying intention, characterized in that: include: Inputting a first text and a second text after the N-1th round of annotation into the first model after the N-1th round of training to perform an Nth round of training on the first model, wherein the first text includes texts with known intent having fixed labels in a sample set, and the second text after the N-1th round of annotation includes texts with unknown intent having temporary labels in the sample set, wherein at least some of the texts with unknown intent in the sample set have temporary labels after the first round of annotation, and N ≥ 2; Inputting the known intent text, the unknown intent text with the temporary label, and the unknown intent text without the temporary label in the sample set into the first model after the Nth round of training to obtain a representation vector for each text in the sample set; Performing hierarchical clustering on all the texts in the sample set according to the representation vector of each text to obtain a plurality of clusters, and determining a cluster in which the number of texts is greater than or equal to a preset threshold as a credible cluster; Based on the ratio of fixed labels corresponding to texts with known intent and temporary labels corresponding to texts with unknown intent in each credible cluster, the texts with unknown intent in the credible cluster are labeled with temporary labels to obtain a second text after the Nth round of labeling; Iterate the above steps, and when the multiple clusters meet a preset convergence condition, output the second text and a temporary label corresponding to the second text.
2. The method according to claim 1, characterized in that The preset convergence condition is that the silhouette coefficient of the credible clustering cluster obtained according to the first model after the Mth round of training is greater than or equal to the silhouette coefficient of the credible clustering cluster obtained according to the first model after the M-1th round of training, and the silhouette coefficient of the credible clustering cluster obtained according to the first model after the M+1th round of training is less than the silhouette coefficient of the credible clustering cluster obtained according to the first model after the Mth round of training, where M≥2.
3. The method according to claim 1, characterized in that The step of performing hierarchical clustering on all the texts in the sample set according to the representation vector of each text to obtain a plurality of clusters includes: Generate a hierarchical tree based on the sentence vectors in the representation vectors of each text in the sample set; According to the order of the multiple candidate bifurcation distances in the hierarchical tree from small to large, the multiple candidate bifurcation distances are sequentially traversed, and multiple candidate clusters are obtained based on each candidate bifurcation distance, until one of the current multiple candidate clusters meets a preset rule, and then the traversal of the multiple candidate bifurcation distances is stopped, wherein each candidate bifurcation distance in the multiple candidate bifurcation distances represents the average value of the distances between the multiple texts of the bifurcation corresponding to the candidate bifurcation distance; The current candidate bifurcation distance is determined as a target bifurcation distance, and the hierarchical tree is divided based on the target bifurcation distance to obtain the multiple clusters.
4. The method according to claim 3, characterized in that The current plurality of candidate clusters include a first candidate cluster, the sample set includes a first number of first intent texts, the first intent texts are texts marked with a first intent label, and the preset rule is: A ratio of the number of first-intent texts in the first candidate cluster to the number of all texts in the first candidate cluster is greater than or equal to a first threshold, and a ratio of the number of first-intent texts in the first candidate cluster to the first number is greater than or equal to a second threshold.
5. The method according to claim 1, wherein The trusted cluster includes a first trusted cluster, the first trusted cluster includes a second intent text labeled with a second intent label, and the labeling of the unknown intent text in the trusted cluster with a temporary label includes: When the number of the second intent texts in the first credible cluster meets a preset condition, labeling the unknown intent texts in the first credible cluster using the second intent label; When there is no text meeting the preset condition in the first credible cluster, the unknown intent text in the first credible cluster is labeled using the newly added temporary label.
6. The method according to claim 1, wherein The network structure of the first model includes a first encoding network and a first classification network, and the N-th round of training of the first model includes: Using the first encoding network, the first text and the second text after the N-1th round of annotation are processed to obtain a representation vector for each text; Using the first classification network to process the sentence vector in the representation vector of each text to obtain a first classification feature vector for each text; determining a loss function based on the first classification feature vector, the fixed label of the first text, and the temporary label of the second text; The first model is trained for an Nth round based on the loss function to obtain a first model after the Nth round of training.
7. The method according to claim 6, characterized in that The first text is a text in a single business field. Before inputting the first text into the first model for the first round of training, the method further includes: Training the second model using third texts from multiple business fields to obtain a trained second model, wherein the second model includes a second encoding network, and the third texts are known intent texts with fixed labels; The parameters of the second encoding network of the trained second model are used as initial values of the parameters of the first encoding network of the first model.
8. The method according to claim 7, characterized in that The network structure of the second model includes the second encoding network, the language model network, the second classification network and the text representation network, and the training of the second model using third texts from multiple business fields includes: Processing the third text using the encoding network to obtain a representation vector for each text in the third text; Processing the representation vector of each text in the third text using the language model network to obtain a language model feature vector; Using the second classification network to process the sentence vector in the representation vector of each text in the third text to obtain a second classification feature vector; The sentence vector in the representation vector of each text in the third text is processed using the text representation network to obtain a text representation vector; wherein, A first loss is calculated based on the language model feature vector, a second loss is calculated based on the second classification feature vector, a third loss is calculated based on the third text representation vector, and the second model is trained based on the first loss, the second loss, and the third loss.
9. An intention recognition device, characterized in that: The device comprises: A training module is configured to input a first text and a second text after the N-1th round of annotation into the first model after the N-1th round of training, so as to perform an Nth round of training on the first model, wherein the first text includes texts with fixed labels of known intent in a sample set, and the second text after the N-1th round of annotation includes texts with temporary labels of unknown intent in the sample set, wherein at least part of the texts with unknown intent in the sample set have temporary labels after the first round of annotation, and N ≥ 2; a calculation module, configured to input the known intent texts, the unknown intent texts with the temporary labels, and the unknown intent texts without the temporary labels in the sample set into the first model after the Nth round of training, to obtain a representation vector for each text in the sample set; A clustering module is used to perform hierarchical clustering on all the texts in the sample set according to the representation vector of each text to obtain multiple clusters, and determine the clusters in which the number of texts is greater than or equal to a preset threshold as credible clusters; A labeling module is used to label the unknown intent texts in each credible cluster with temporary labels based on the ratio of fixed labels corresponding to the known intent texts and temporary labels corresponding to the unknown intent texts in the credible clusters, to obtain a second text after the Nth round of labeling; An output module is configured to output the second text and a temporary label corresponding to the second text when the plurality of clusters meet a preset convergence condition.
10. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor, The processor is configured to execute the intention recognition method described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that The storage medium stores a computer program, and the computer program is used to execute the intention recognition method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Text noise data recognition method and device, computer equipment and storage medium
CN112580329A
Classification model training method, clustering method and electronic equipment
CN113918714A