Intention recognition method and device
By generating question vectors and obtaining matching intent vectors from a preset vector library, and using multiple similarity algorithms for weighted fusion, the problem of insufficient accuracy and coverage in existing intent recognition methods is solved, achieving intent recognition with high accuracy and high coverage.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ULTRAPOWER SOFTWARE
- Filing Date
- 2021-08-16
- Publication Date
- 2026-06-26
AI Technical Summary
Existing intent recognition methods lack accuracy and coverage when faced with weak rules or new questions. In particular, dictionary-based rule template methods and methods based on past log matching make mistakes when faced with different question formats or new questions. Machine learning-based methods are not robust when training data is scarce.
By generating question vectors and obtaining matching intent vectors from a preset vector library, similarity is calculated using at least two similarity algorithms and then weighted and fused to determine candidate intents, thus achieving intent recognition.
It improves the accuracy and coverage of intent recognition, reduces the reliance on large amounts of labeled data, and adapts to the intent recognition needs of different business domains.
Smart Images

Figure CN115705355B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of text processing technology, and in particular to an intent recognition method and apparatus. Background Technology
[0002] Intent recognition, as the name suggests, refers to determining what a user wants to do; specifically, it involves categorizing sentences or questions into corresponding intent types. In this era of rapid development in artificial intelligence, search engines, dialogue systems, and chatbots are gradually integrating into various fields. Accurately identifying user intent helps to understand or predict potential user needs, thereby providing users with accurate search results or answers.
[0003] Currently, commonly used intent recognition methods include dictionary-based rule template methods, historical log matching methods, and machine learning-based methods. Dictionary-based rule template methods identify the intent contained in sentences that conform to certain rules through rule parsing. In practical applications, this method is only suitable for highly rule-based queries and has low coverage; for example, it cannot accurately identify user intent when the user slightly changes the query format. Historical log matching methods are suitable for search engines. They mainly statistically classify the subsequent behaviors corresponding to past questions to obtain a vocabulary for each intent. When a new question arises, its intent is identified by matching the new question with the vocabulary. This method is prone to identification errors for long-tail questions, cannot correctly identify new questions, and lacks generalization ability. Machine learning-based methods first train an intent classification model using machine learning methods, and then use the trained intent classification model to identify user intent. However, due to the scarcity of training data, the accuracy and robustness of the trained intent classification model are often unsatisfactory. Summary of the Invention
[0004] This application provides an intent recognition method and apparatus. The method and apparatus have high accuracy and high coverage, and do not require a large amount of labeled training data, so they are not limited by data scarcity.
[0005] In a first aspect, this application provides an intent recognition method, the method comprising:
[0006] Obtain the text of the first question;
[0007] A question vector is generated based on the first question text, and multiple intent vectors matching the question vector are obtained from a preset vector library. The intent vectors are generated based on the second question text with known intents.
[0008] Using at least two similarity algorithms, the similarity between the first question text and the second question text corresponding to each intent vector is calculated, and the at least two similarity calculation results are weighted and fused.
[0009] The intent corresponding to the second question text whose weighted fusion result meets the preset similarity conditions is determined as the candidate intent of the first question text.
[0010] Secondly, this application also provides an intent recognition device, the device comprising:
[0011] The acquisition module is used to retrieve the text of the first question;
[0012] The matching module is used to generate a question vector based on the first question text and obtain multiple intent vectors that match the question vector from a preset vector library. The intent vectors are generated based on the second question text with known intents.
[0013] The sorting module is used to calculate the similarity between the first question text and the second question text corresponding to each intent vector using at least two similarity algorithms, and to perform weighted fusion on the at least two similarity calculation results.
[0014] The determination module is used to determine the intent corresponding to the second question text whose weighted fusion result meets the preset similarity conditions as the candidate intent of the first question text.
[0015] As can be seen from the above technical solutions, the embodiments of this application provide an intent recognition method and apparatus. The method pre-generates feature vectors based on question texts containing multiple known intents from one or more business domains and saves them in a preset vector library. When a first question text to be processed is generated, a question vector is first generated based on the first question text, and multiple intent vectors matching the question vectors are obtained from the preset vector library. Since these intent vectors match the features of the question vectors, the intent vectors and question vectors have completely identical or sufficiently similar intents. Then, at least two similarity algorithms are used to calculate the similarity between the first question text and the second question text corresponding to each intent vector, and the at least two similarity calculation results are weighted and fused. Finally, the intent corresponding to the second question text whose weighted fusion result meets preset similarity conditions is determined as a candidate intent of the first question text. By evaluating the intent recognition results from multiple algorithm dimensions, the intent recognition results are made more accurate. Attached Figure Description
[0016] To more clearly illustrate the technical solution of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart illustrating an intent recognition method in some embodiments of this application;
[0018] Figure 2 This is a block diagram of an intent recognition device shown in some embodiments of this application. Detailed Implementation
[0019] To enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of this application.
[0020] Intent recognition is a natural language processing technique commonly used in various artificial intelligence fields such as search engines, dialogue systems, and chatbots. As the name suggests, intent recognition involves processing sentences or questions input by the user to determine their intent. For example, in a chatbot scenario, if a user says, "I want to buy a train ticket," then "I want to buy a train ticket" is the user's input sentence, also known as the question text. Next, the chatbot uses intent recognition to determine that the intent corresponding to this question text is "buy a train ticket." Then, it can provide corresponding answers or prompts based on this intent, such as asking for travel time, destination, etc. Finally, based on the collected information, it completes order confirmation, payment, and ticket booking. Therefore, accurately identifying user intent helps to understand or predict potential user needs, which is crucial for providing accurate search results or answers.
[0021] This application provides an intent recognition method and apparatus. The method achieves intent recognition based on feature vector matching and text similarity fusion ranking. It has high accuracy and high coverage, and does not require a large amount of labeled training data, so it is not limited by data scarcity. Figure 1 The flowchart of the intent recognition method shown in this application is an example. Figure 1 As shown, the method may include:
[0022] S101, retrieve the text of the first question.
[0023] The first question text can be a sentence directly entered by the user, or a sentence converted from user-input speech data. The intent of the first question text is unknown. In other words, the first question text refers to the text to be processed in this embodiment.
[0024] It should be noted that the business domain to which the first question text belongs can be known or unknown. This business domain can be pre-defined based on application scenario type and / or business type, such as a ticketing system application domain, a shopping platform application domain, a mobile payment business domain, etc. Furthermore, this application does not limit the string length of the first question text. For example, the first question text can be a short sentence, a long sentence, or a paragraph composed of multiple sentences.
[0025] For example, the first question text could specifically be:
[0026] What is the latest shipping date for my order?
[0027] As can be seen in this example, the first question text is the question text entered on a shopping platform.
[0028] S102, generate a question vector based on the first question text, and obtain multiple intent vectors that match the question vector from a preset vector library. The intent vectors are generated based on the second question text with known intents.
[0029] In some embodiments, the preset vector library includes at least feature vectors generated from question texts based on multiple known intents of one or more business domains, and these feature vectors are pre-saved into the vector library.
[0030] In specific implementation, a text dataset for a certain business domain is first obtained. This text dataset includes at least multiple sets of text data, and each set of text data includes at least a question text with known intent, and may also include the answer corresponding to the question text. To facilitate differentiation from the question text with unknown intent in S101, in the following embodiments, the question text with known intent in the aforementioned text dataset is referred to as the second question text.
[0031] For example, each set of text data includes:
[0032] When will my order be shipped? (Orders will be shipped within 48 hours of being placed.)
[0033] In this example, <When will my order ship?> is the second question text, and the intent corresponding to this question text is "inquiring about the shipping time". <Ships within 48 hours after ordering> is the answer corresponding to this question text or intent.
[0034] Next, a cleaning operation is performed on the second question text in the text dataset to remove useless information, including but not limited to emojis, abbreviations, and stop words. Then, the cleaned second question text is segmented using preset word segmentation rules to obtain a sequence of question words for each second question text. For example, after cleaning the second question text in the example above, we get "<When will the order be shipped>". Using the preset word segmentation rules, the resulting sequence of question words is "[When will the order be shipped>".
[0035] In some embodiments, the preset word segmentation rules can specifically be pre-trained word segmenters, such as the LAC word segmenter. The training data used to train the word segmenter includes not only a regular dictionary but also a specialized vocabulary and a sensitive vocabulary list for a specific business domain. This enables the word segmenter to accurately identify specialized and sensitive words within that business domain, ensuring its accuracy and adaptability to the business domain. It should be noted that those skilled in the art can train the word segmenter based on existing technology, and the training termination conditions can be set according to actual needs; these will not be elaborated upon herein.
[0036] After obtaining the sequence of question words, a pre-trained word embedding model is used to process the sequence to obtain the feature vector corresponding to the second question text. Finally, the obtained feature vector of known intent is inserted into a preset vector library. In some embodiments, the word embedding model used can be a Skip-gram model. During the training process of the Skip-gram model, the input of each round is an n-dimensional One-Hot vector of the center word. With a window width of K, the model output is a K-dimensional vector. The element value at each position in this K-dimensional vector represents the predicted probability that a word in the vocabulary appears near the center word. It can be seen that since the Skip-gram model predicts the words before and after the center word, it is equivalent to having K words as output for each center word, that is, training K times for each word in the text. Therefore, it can learn the information in the text more effectively and also has a good effect on low-frequency words.
[0037] In some embodiments, each feature vector in the preset vector library has a vector ID. Different feature vectors can be distinguished by this vector ID, allowing feature vector data to be retrieved based on a specified vector ID. Furthermore, each feature vector can be associated with its corresponding second question text, intent, and answer via the vector ID, enabling the retrieval of the corresponding second question text, intent, and answer based on a specified vector ID.
[0038] In some embodiments, the answers corresponding to the question text in each of the above sets of text data can be stored in the answer database, and an index associated with the corresponding question text, feature vector, or intent can be generated, so that the answer corresponding to the specified intent can be retrieved from the answer database based on the index.
[0039] After saving the feature vectors of known intents for a specific business domain to a pre-defined vector library, when the first question text to be processed is generated, a cleaning operation is first performed on the first question text to remove useless information such as emojis, abbreviations, and stop words. Then, the cleaned first question text is segmented using the aforementioned pre-defined word segmentation rules to obtain the question word sequence corresponding to the first question text. Next, a pre-trained word embedding model is used to process the question word sequence to obtain the question vector corresponding to the first question text. Then, multiple feature vectors matching the question vector are obtained from the aforementioned pre-defined vector library. For ease of explanation and distinction, the feature vectors that match the question vector obtained from the pre-defined vector library are called intent vectors. Because these intent vectors match the features of the question vector, the intent vectors and question vectors have the same or sufficiently similar intents.
[0040] In some implementations, the intent vector that matches the question vector is a feature vector whose Euclidean distance to the question vector is less than a preset distance value. In these implementations, the Euclidean distance between the question vector and each feature vector in a preset vector library is first calculated. Then, it is determined whether the calculated result for each feature vector is less than the preset distance value. The feature vectors whose calculated results are less than the preset distance value are identified as intent vectors that match the question vector. In this way, since these intent vectors are sufficiently similar to the question vector, the intents they correspond to are also the same or similar.
[0041] In some embodiments, the aforementioned preset vector library is the Milvus vector library. Milvus is an open-source vector search engine that supports adding, deleting, and modifying terabyte-level vectors and near real-time queries, featuring high flexibility, stability, reliability, and high-speed querying. Milvus integrates widely used vector index libraries such as Faiss (Facebook AI Similarity Search), NMSLIB (Non-Metric Space Library), and Annoy (Approximate Nearest Neighbors Oh Yeah), providing a complete set of simple and intuitive APIs for users to choose different index types for different scenarios. In these embodiments, obtaining multiple intent vectors matching the question vector from the preset vector library includes: retrieving the question vector from the Milvus vector library to obtain a result set, which includes at least multiple sets of feature vector data. Each set of feature vector data includes a vector ID and a Euclidean distance, which is the Euclidean distance between the feature vector corresponding to the vector ID and the question vector; filtering out vector IDs whose Euclidean distance is less than a preset distance from the result set; and obtaining the corresponding intent vector, second question text, intent, and answer based on the filtered vector IDs.
[0042] It should be noted that in some implementation scenarios, when retrieving question vectors from the Milvus vector library, the recalled feature vector data are all intent vectors whose Euclidean distance is less than a preset distance, thus saving further filtering. It should be understood that search conditions can be configured for the Milvus vector library, allowing it to retrieve search results based on these conditions. For example, search conditions include the matching algorithm used during the search and filtering conditions for the search results. The aforementioned Euclidean distance algorithm is one type of matching algorithm; requiring the Euclidean distance between the feature vector and the question vector to be less than a preset distance is one filtering condition.
[0043] In the above embodiments, the Milvus vector library with vector search engine function is used to fully utilize the high flexibility, stability, reliability and high-speed query characteristics of the Milvus vector library to achieve near real-time search of intent vectors.
[0044] S103, using at least two similarity algorithms, calculate the similarity between the first question text and the second question text corresponding to each intent vector, and perform weighted fusion on the at least two similarity calculation results.
[0045] In some embodiments, at least two of the first similarity, second similarity, third similarity, and fourth similarity are calculated according to the following formula:
[0046]
[0047] In equation (1), a represents the first question text, i represents the position of each word (i.e., character) in the first question text a, b represents the second question text corresponding to a certain intent vector, j represents the position of each word (i.e., character) in the second question text b, and lev a,b This represents the edit distance between the first question text a and the second question text b, i.e., the number of steps required to change from the first question text a to the second question text b. It should be understood that lev a,b The smaller the value, the more similar the first question text a and the second question text b are, and therefore the larger the first similarity P1 is.
[0048]
[0049] It is worth noting that, for the first question text a, assuming the word sequence corresponding to a is A[a1,a2,a3,...,am], and for the second question text b corresponding to a certain intent vector, assuming the word sequence corresponding to b is B[b1,b2,b3,...,bm], then dividing the word sequence A and word sequence B into subsequences, the subsequences of word sequence A and word sequence B respectively include:
[0050] A1[a1], A2[a1,a2],…,Am[a1,a2,…,am]
[0051] B1[b1], B2[b1,b 2],…,Bn[b1,b2,…,bn]
[0052] According to the recursive formula (2), the length of the longest common subsequence num[i][j] between each subsequence of A and each subsequence of B can be calculated sequentially and recorded in the array num[m][n]. The maximum num[i][j] represents the maximum value in num[m][n], which is the length of the longest common subsequence between A and B. It should be understood that the longer the length of the longest common subsequence between A and B, the more similar a and b are, and the larger the second similarity P2 is.
[0053]
[0054] In equation (3), a∩b represents the intersection of the words contained in the first question text a and the words contained in the second question text b, a∪b represents the union of the words contained in the first question text a and the words contained in the second question text b, and J(a,b) represents the proportion of the words in the intersection in the union. It should be understood that the larger J(a,b) is, the more similar a and b are, and the higher the third similarity P3 is.
[0055]
[0056] In equation (4), X represents the set of words contained in the first question text a, Y represents the set of words contained in the second question text b, cov represents the covariance, E represents the expected value, and ρ represents the expected value. (X,Y) P represents the Pearson correlation coefficient between X and Y, and P4 represents the fourth similarity.
[0057] It should be noted that the similarity algorithms that can be used are not limited to the four algorithms listed above. Other methods for calculating the similarity between texts can also be used, such as cosine similarity, Euclidean distance, Manhattan distance, etc.
[0058] In some embodiments, the information entropy between the first question text and the second question text is calculated based on multiple similarity calculation results, thereby achieving a weighted fusion of the multiple similarity calculation results. Specifically, the information entropy between the first question text and the second question text corresponding to each intent vector can be calculated according to the following formula (5):
[0059]
[0060] Among them, H s Let Pk represent the information entropy of the first question text and the second question text corresponding to the s-th intent vector, and let Pk represent the k-th similarity among the m similarity calculation results between the first question text and the second question text corresponding to the s-th intent vector, where m≥2.
[0061] In other embodiments, the multiple similarity calculation results between the first question text and the second question text are weighted according to the preset weight values of each similarity algorithm, thereby achieving weighted fusion of the multiple similarity calculation results. Specifically, the weighted similarity between the first text and the second question text corresponding to each intent vector can be calculated according to the following formula (6):
[0062]
[0063] Where Ps represents the weighted similarity between the first question text and the second question text corresponding to the s-th intent vector, Pk represents the k-th of the m similarity calculation results between the first question text and the second question text corresponding to the s-th intent vector, and wk is the preset weight value corresponding to the k-th similarity calculation result.
[0064] As shown in S103, by using at least two similarity algorithms to calculate the similarity between the first question text and the second question text, and by weighting and fusing the at least two similarity calculation results, the intent recognition results can be evaluated from multiple algorithm dimensions, making the intent recognition results more accurate.
[0065] S104, the intent corresponding to the second question text whose weighted fusion result meets the preset similarity conditions is determined as the candidate intent of the first question text.
[0066] In an embodiment where the information entropy between the first question text and the second question text is used as the weighted fusion result, since a larger information entropy means a smaller uncertainty that the first question text and the second question text have the same intention, all second question texts can be sorted in ascending order of information entropy. Then, the intentions corresponding to a predetermined number of second question texts with the highest position are determined as candidate intentions of the first question text. That is, the Top N second question texts with smaller information entropy with the first question text are selected, and the intentions corresponding to these N second question texts are determined as candidate intentions of the first question text, where N≥1.
[0067] In other implementations, the reciprocal of the information entropy corresponding to each second question text can be taken to obtain the weight value between the first and second question texts. The weight value corresponding to each second question text can represent its similarity to the first question text. In other words, the higher the weight value of the second question text, the more similar it is considered to be to the first question text. Based on this, all second question texts can be sorted in descending order of weight value. Then, the intentions corresponding to the top-ranked, predetermined number of second question texts can be determined as candidate intentions for the first question text. That is, the top N second question texts with larger weight values are selected, and the intentions corresponding to these N second question texts are determined as candidate intentions for the first question text, where N≥1.
[0068] In an embodiment where the weighted similarity between the first question text and the second question text is used as the weighted fusion result, since a larger weighted similarity value means that the first question text and the second question text are more similar, that is, the first question text and the second question text are more likely to have the same intention, all second question texts can be sorted in descending order of weighted similarity. Then, the intentions corresponding to the top-ranked preset number of second question texts are determined as the candidate intentions of the first question text. That is, the top N second question texts with larger weighted similarity are selected, and the intentions corresponding to these N second question texts are determined as the candidate intentions of the first question text, where N≥1.
[0069] For example, the second question text that meets the preset similarity conditions in the weighted fusion result can be the top 3 second question texts with lower information entropy, or the top 3 second question texts with higher weighted similarity, thereby determining the three candidate intentions of the first question text as the intentions corresponding to the top 3 second question texts.
[0070] In some embodiments, the answer corresponding to each candidate intent is obtained, for example, from an answer database. When the number of candidate intents for the determined first question text is 1, the candidate intent is identified as the target intent, and the answer corresponding to that intent is fed back to the user as the target answer. When the number of candidate intents for the determined first question text is greater than 1, one of the multiple candidate intents is identified as the target intent, the answer corresponding to the target intent is fed back to the user as the target answer, and the answers corresponding to the remaining candidate intents are fed back to the user as candidate answers. For example, when multiple candidate intents are generated, the intent corresponding to the second question text most similar to the first question text can be identified as the target intent based on the weighted fusion result corresponding to each candidate intent.
[0071] As can be seen from the above embodiments, this application provides an intent recognition method. This method pre-generates feature vectors from question texts containing multiple known intents from one or more business domains and saves them in a preset vector library. When a first question text to be processed is generated, a question vector is first generated based on the first question text, and multiple intent vectors matching the question vector are obtained from the preset vector library. Since these intent vectors match the features of the question vectors, the intent vectors and question vectors have completely identical or sufficiently similar intents. Then, at least two similarity algorithms are used to calculate the similarity between the first question text and the second question text corresponding to each intent vector, and the at least two similarity calculation results are weighted and fused. Finally, the intent corresponding to the second question text whose weighted fusion result meets preset similarity conditions is determined as a candidate intent of the first question text. By evaluating the intent recognition result from multiple algorithm dimensions, the intent recognition result is made more accurate.
[0072] It is worth noting that, unlike traditional intent recognition methods such as those based on dictionary rule templates, those based on past log matching, and those based on machine learning, the intent recognition method provided in this application is based on feature vector matching and text similarity fusion ranking to achieve intent recognition. It has high accuracy and high coverage, and does not require a large amount of labeled training data, so it is not limited by data scarcity.
[0073] Based on the intent recognition method provided in the above embodiments, this application also provides an intent recognition device, such as... Figure 2 As shown, the device may include:
[0074] The acquisition module 201 is used to acquire a first question text. The matching module 202 is used to generate a question vector based on the first question text and acquire multiple intent vectors matching the question vector from a preset vector library, wherein the intent vectors are generated based on second question texts with known intents. The sorting module 203 is used to calculate the similarity between the first question text and the second question text corresponding to each intent vector using at least two similarity algorithms, and to perform a weighted fusion of the at least two similarity calculation results. The determination module 204 is used to determine the intents corresponding to the second question texts whose weighted fusion results meet preset similarity conditions as candidate intents for the first question text.
[0075] In some embodiments, the sorting module 203 is specifically used to calculate the information entropy between the first question text and the second question text corresponding to each intent vector according to the following formula:
[0076]
[0077] Among them, H s Let Pk represent the information entropy of the first question text and the second question text corresponding to the s-th intent vector, and let Pk represent the k-th similarity among the m similarity calculation results between the first question text and the second question text corresponding to the s-th intent vector, where m≥2.
[0078] In some embodiments, the sorting module 203 is specifically used to sort all the second question texts in ascending order of information entropy; and to determine the intents corresponding to a preset number of second question texts with the highest position as candidate intents of the first question texts.
[0079] In some embodiments, the matching module 202 is specifically used to obtain feature vectors from a preset vector library whose Euclidean distance from the problem vector is less than a preset distance.
[0080] In some embodiments, the matching module 202 is specifically a Milvus vector library, which includes the preset vector library. The Milvus vector library is specifically used to: retrieve the question vector in the Milvus vector library to obtain a result set, wherein the result set includes at least multiple sets of feature vector data, each set of feature vector data including a vector ID and the Euclidean distance between the feature vector corresponding to the vector ID and the question vector; and filter out vector IDs whose corresponding Euclidean distance is less than a preset distance from the result set, wherein the vector ID is used to obtain the corresponding feature vector and the corresponding second question text.
[0081] In some embodiments, the sorting module 203 is specifically used to calculate at least two of the first similarity, second similarity, third similarity, and fourth similarity according to the following formula:
[0082]
[0083] In equation (1), a represents the first question text, i represents the position of the character in the first question text a, b represents the second question text, and j represents the position of the character in the second question text b. Let P1 be the indicator function, representing the first similarity.
[0084]
[0085] In equation (2), num[i][j] represents the longest common subsequence of the word sequence corresponding to the first question text a and the word sequence corresponding to the second question text b, and P2 represents the second similarity.
[0086]
[0087] In equation (3), a∩b represents the intersection of the words contained in the first question text a and the words contained in the second question text b, a∪b represents the union of the words contained in the first question text a and the words contained in the second question text b, and P3 represents the third similarity.
[0088]
[0089] In Equation (4), X represents the set of words contained in the first question text a, Y represents the set of words contained in the second question text b, E represents the mathematical expectation, and P4 represents the fourth similarity.
[0090] In some embodiments, the matching module 202 is specifically used to: clean the first question text; segment the cleaned first question text using a preset word segmentation rule to obtain a question word sequence; and process the question word sequence using a pre-trained Skip-gram model to obtain the question vector.
[0091] The intent recognition device provided in this application pre-generates feature vectors from question texts containing multiple known intents from one or more business domains and saves them in a preset vector library. When a first question text to be processed is generated, a question vector is first generated based on the first question text, and multiple intent vectors matching the question vectors are obtained from the preset vector library. Since these intent vectors match the features of the question vectors, the intent vectors and question vectors have completely identical or sufficiently similar intents. Then, at least two similarity algorithms are used to calculate the similarity between the first question text and the second question text corresponding to each intent vector, and the at least two similarity calculation results are weighted and fused. Finally, the intent corresponding to the second question text whose weighted fusion result meets the preset similarity conditions is determined as the candidate intent of the first question text. By evaluating the intent recognition results from multiple algorithm dimensions, the intent recognition results are made more accurate.
[0092] In a specific implementation, the present invention also provides a computer storage medium, wherein the computer storage medium may store a program, which, when executed, may include some or all of the steps of the various embodiments of the intent recognition method provided by the present invention. The storage medium may be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0093] Those skilled in the art will clearly understand that the techniques in the embodiments of the present invention can be implemented using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions in the embodiments of the present invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or certain parts of the embodiments of the present invention.
[0094] The same or similar parts between the various embodiments in this specification can be referred to mutually. In particular, the device embodiments are basically similar to the method embodiments, so the description is relatively simple, and the relevant parts can be referred to the description in the method embodiments.
[0095] The embodiments of the present invention described above do not constitute a limitation on the scope of protection of the present invention.
Claims
1. An intent recognition method, characterized in that, The method includes: Obtain the text of the first question; A question vector is generated based on the first question text, and multiple intent vectors matching the question vector are obtained from a preset vector library. The intent vectors are generated based on the second question text with known intents. Using at least two similarity algorithms, the similarity between the first question text and the second question text corresponding to each intent vector is calculated, and at least two similarity calculation results between the first question text and the second question text corresponding to each intent vector are obtained; For each of the intent vectors corresponding to the second question text, at least two similarity calculation results are weighted and fused to obtain a weighted fusion result; wherein, the weighted fusion result is the information entropy between the first question text and the second question text corresponding to the intent vector; Sort the second question texts corresponding to all the intent vectors in ascending order of information entropy; The intents corresponding to the first few pre-ordered second question texts are determined as candidate intents for the first question text.
2. The intent recognition method according to claim 1, characterized in that, The formula for calculating the information entropy between the first question text and the second question text corresponding to each intent vector is: in, Let represent the information entropy of the first question text and the second question text corresponding to the s-th intent vector. It represents the k-th similarity among m similarity calculation results between the first question text and the second question text corresponding to the s-th intent vector, where m≥2.
3. The intent recognition method according to claim 2, characterized in that, The intent corresponding to the second question text whose weighted fusion result meets preset similarity conditions is determined as a candidate intent of the first question text, including: Sort all texts related to the second question in ascending order of information entropy; The intents corresponding to the first few pre-ordered second question texts are determined as candidate intents for the first question text.
4. The intent recognition method according to claim 1, characterized in that, Multiple intent vectors matching the question vector are obtained from a preset vector library, including: Obtain feature vectors from a preset vector library whose Euclidean distance from the problem vector is less than a preset distance.
5. The intent recognition method according to claim 1, characterized in that, The preset vector library is the Milvus vector library. Multiple intent vectors matching the question vector are obtained from the preset vector library, including: The problem vector is retrieved from the Milvus vector library to obtain a result set. The result set includes at least multiple sets of feature vector data. Each set of feature vector data includes a vector ID and the Euclidean distance between the feature vector corresponding to the vector ID and the problem vector. The vector IDs corresponding to Euclidean distances less than a preset distance are selected from the result set. The vector IDs are used to obtain the corresponding feature vectors and the corresponding second question text.
6. The intent recognition method according to claim 1, characterized in that, Using at least two similarity algorithms, the similarity between the first question text and the second question text corresponding to each intent vector is calculated, including calculating at least two of the following formulas: first similarity, second similarity, third similarity, and fourth similarity: (1) In equation (1), a represents the first question text, i represents the position of the character in the first question text a, b represents the second question text, and j represents the position of the character in the second question text b. For indicator functions, Indicates the first similarity; (2) In equation (2), Let represent the longest common subsequence of the word sequence corresponding to the first question text 'a' and the word sequence corresponding to the second question text 'b'. Indicates the second similarity; (3) In equation (3), This represents the intersection of the words contained in the first question text a and the words contained in the second question text b. This represents the union of the words contained in the first question text a and the words contained in the second question text b. Indicates third similarity; (4) In equation (4), X represents the set of words contained in the first question text a, Y represents the set of words contained in the second question text b, and E represents the mathematical expectation. This indicates the fourth similarity.
7. The intent recognition method according to claim 1, characterized in that, Generate a question vector based on the first question text, including: Clean the text of the first question; The first problem text after cleaning is segmented using preset word segmentation rules to obtain a sequence of problem words; The question word sequence is processed using a pre-trained Skip-gram model to obtain the question vector.
8. The intent recognition method according to claim 7, characterized in that, Before retrieving the set of intent vectors from a pre-defined vector library, the process includes: Obtain a text dataset, which includes multiple sets of text data, wherein the text data includes at least a second question text with a known intent; Clean the second question text with the known intent; The cleaned second problem text is segmented using the preset word segmentation rules to obtain a sequence of problem words; The Skip-gram model is used to process the question word sequence to obtain a feature vector of known intent; The feature vector is inserted into the preset vector library.
9. The intent recognition method according to claim 8, characterized in that, The first question text and the second question text are both from the same business domain.
10. An intent recognition device, characterized in that, The device includes: The acquisition module is used to retrieve the text of the first question; The matching module is used to generate a question vector based on the first question text and obtain multiple intent vectors that match the question vector from a preset vector library. The intent vectors are generated based on the second question text with known intents. The sorting module is used to calculate the similarity between the first question text and the second question text corresponding to each intent vector using at least two similarity algorithms, and to obtain at least two similarity calculation results between the first question text and the second question text corresponding to each intent vector. For each of the intent vectors corresponding to the second question text, at least two similarity calculation results are weighted and fused to obtain a weighted fusion result; wherein, the weighted fusion result is the information entropy between the first question text and the second question text corresponding to the intent vector; The determination module is used to sort the second question texts corresponding to all the intent vectors in ascending order of information entropy; The intents corresponding to the first few pre-ordered second question texts are determined as candidate intents for the first question text.