A method for retrieving standard questions in a digital human system
By using clustering and attribution modeling to process the standard questions in the digital human system, the problems of slow retrieval speed and low accuracy were solved, enabling fast and accurate retrieval of standard questions and improving the system's intelligence level and user experience.
Patent Information
- Application Number
- CN202411585129.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2044-11-07
AI Technical Summary
In digital human systems, when there are a large number of built-in standard questions, existing technologies suffer from slow retrieval speed, large workload in similarity calculation, and difficulty in accurately classifying user questions across multiple categories, leading to inaccurate retrieval results.
By clustering standard questions to obtain centroids for each category, calculating the distance between user questions and centroids, constructing similarity sets and attribution models, determining the final category to which user questions belong, calculating similarity only within specific categories, setting similarity thresholds, and outputting answers.
It significantly reduces the workload of similarity calculation, improves the speed and accuracy of standard question retrieval, reduces misjudgments, and enhances the system's intelligence and user experience.
Smart Images

Figure CN119474310B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of digital human systems technology, and in particular to a method for retrieving standard questions in digital human systems. Background Technology
[0002] In digital human systems, there are usually some standard questions and their corresponding answers built-in. First, these standard questions are converted into word vectors using BERT or other models. When a user inputs a question, it is also converted into a word vector. Then, the similarity between the vector of the user's question and the vector of each standard question is calculated. If the similarity exceeds a preset threshold, the corresponding standard answer is output. If the similarity of all standard questions does not reach the threshold, the user's question is submitted to a subsequent large language model for answering.
[0003] A method and system for determining standard questions based on similarity, disclosed in CN112131876A, includes the following steps: S1, acquiring user question information, calculating the similarity between the user questions and existing training data according to a similarity model, storing questions with similarity below a specified threshold as data to be processed, and identifying unfamiliar data that does not conform to the features of existing standard questions; and S2, performing cluster analysis on the user questions in the data to be processed, extracting features of each category as hot words, sorting the hot words from high to low, storing the top-ranked hot questions in a database to be labeled, and expanding the standard questions for use in intelligent question answering systems.
[0004] The existing solutions have several drawbacks. When there are a large number of built-in standard questions, users have to wait a long time before a standard question is matched. The similarity calculation is labor-intensive, the standard question retrieval speed is slow, which affects the user experience. Furthermore, when performing cluster analysis on user questions, it cannot accurately classify user questions that fall between multiple categories, thus reducing the accuracy of the retrieval results. Summary of the Invention
[0005] In view of this, the present invention proposes a method for retrieving standard questions in a digital human system, which can significantly reduce the workload of similarity calculation and improve the speed of standard question retrieval while maintaining the accuracy of the results.
[0006] The technical solution of the present invention is implemented as follows: In a first aspect, the present invention provides a method for retrieving standard questions in a digital human system, comprising the following sub-steps:
[0007] S1, cluster all standard problems in the system to obtain the centroids of each category and the maximum Euclidean distance in each category;
[0008] S2: Input the user question, calculate the distance between the word vector of the user question and the centroid of each category, obtain the similarity distance, and construct the similarity set;
[0009] S3 compares the similarity distances in the similarity set with the maximum distance in the corresponding category, constructs the attribution model, and calculates and determines the final attribution category of the user's question;
[0010] S4 calculates the similarity between the word vector of the user's question and all standard questions in the final category, selects the standard question with the highest similarity, and outputs the answer corresponding to the standard question as the result, giving the user the answer.
[0011] Based on the above technical solutions, preferably, in step S1, all standard problems in the system are clustered to obtain the centroids of each category. This includes clustering all standard problems in the system using clustering algorithms or manual intervention.
[0012] Clustering is performed using clustering algorithms, which includes converting all standard questions in the system into word vectors based on the BERT model, and then using the K-Means clustering algorithm to cluster the converted word vectors to obtain the centroid of each category.
[0013] Clustering with human input involves converting all standard questions in the system into word vectors based on the BERT model, calculating the average value of all vectors in each category in each dimension, and obtaining the centroid of each category.
[0014] Based on the above technical solution, preferably, after clustering all standard problems in the system in step S1, it is determined whether the number of standard problems in each category exceeds 10% of the total number of standard problems. If the number of standard problems in a certain category exceeds 10% of the total number of standard problems, the category is further classified until the number of standard problems in the category is less than 10% of the total number of standard problems.
[0015] Based on the above technical solutions, preferably, step S1, obtaining the maximum Euclidean distance in each category, includes obtaining the word vector of each standard question in each category and the centroid of the corresponding category, using the Euclidean distance formula to calculate the Euclidean distance between each standard question in each category and the centroid of its category, and obtaining the maximum Euclidean distance in each category.
[0016] Based on the above technical solutions, preferably, in step S2, the input user question is used to calculate the distance between the word vector of the user question and the centroid of each category to obtain the similarity distance and construct a similarity set; wherein, the user question is converted into word vectors through the BERT model, the Euclidean distance formula is used to calculate the Euclidean distance between the word vector of the user question and the centroid of each category to obtain the similarity distance, the similarity set is constructed, and each similarity distance is added to the similarity set to obtain the similarity set.
[0017] Based on the above technical solutions, preferably, step S3, which compares each similarity distance in the similarity set with the maximum distance in the corresponding category, constructs an attribution model, and calculates and determines the final attribution category of the user's question, includes the following steps:
[0018] S31. Compare the distances of each similarity in the similarity set with the maximum Euclidean distance of its corresponding category. If the distances of the centroids of all categories exceed the maximum Euclidean distance of their respective categories, then input the user question into the large language model for answering. The user question is then associated with the answer of the large language model as the standard question and stored in the digital human system as the standard answer.
[0019] S32, if there exists a category whose similarity distance is less than the maximum Euclidean distance of its corresponding category, then the user problem is assigned to this category as the final category;
[0020] S33. If there are multiple categories whose similarity distances are all less than the maximum Euclidean distance of their corresponding categories, establish an attribution model, and calculate and determine the final attribution category of the user's problem based on the attribution model.
[0021] Based on the above technical solution, preferably, in step S33, if the similarity distance of multiple categories is less than the maximum Euclidean distance of their corresponding categories, then an attribution model is established, and the final attribution category of the user's question is calculated and determined according to the attribution model. The attribution model is constructed according to the following set principles:
[0022] The smaller the Euclidean distance from a user's question to the centroid of a certain category, the greater the probability of it belonging to that category; if multiple categories have the same distance, the smaller the centroid of a category to its corresponding maximum Euclidean distance, the greater the probability of it belonging to that category.
[0023] The expression for the attribution model is:
[0024]
[0025] In the formula, P(i) is the probability that the user's question belongs to the i-th class, and d i,max d is the maximum Euclidean distance of the i-th class. iThe distance between the user's question word vector and the centroid of the i-th class is called the similarity distance. β is a positive hyperparameter used to control the steepness of the function. max() is used to ensure that the probability is not negative. If the result calculated on the right is less than 0, the probability of belonging to the i-th class is 0.
[0026] Based on the above technical solution, preferably, step S4 involves calculating the similarity between the word vector of the user's question and all standard questions in the final category, selecting the standard question with the highest similarity, and outputting the answer corresponding to that standard question as the result, thus providing the user's answer. This includes the following sub-steps:
[0027] Calculate the similarity between the word vector of the user's question and all standard questions in the final category, and obtain the similarity value corresponding to each standard question. The similarity calculation expression is:
[0028]
[0029] In the formula, A is the word vector of the user input question, A i It is the word vector of the current element, A·A i Represent vectors A and A i The dot product, which is the sum of the element-wise multiplications of corresponding dimensions, is ||A|| and ||A||. i || are vectors A and A' respectively. i The Euclidean norm is the square root of the sum of the squares of the elements.
[0030] A preset similarity threshold is set. Based on the similarity values corresponding to each standard question, the maximum similarity value is obtained and compared with the similarity threshold. If the maximum similarity value is less than the similarity threshold, the user question is input into the large language model for solution, and the user question is associated with the solution result of the large language model as the standard answer and stored in the digital human system. If the maximum similarity value is greater than the similarity threshold, the standard answer corresponding to the standard question with the maximum similarity value is obtained as the output result and given to the user.
[0031] Secondly, the present invention also provides an electronic device, including at least one processor, at least one memory, a communication interface, and a bus; wherein the processor, memory, and communication interface communicate with each other through the bus; the memory stores a program for retrieving a standard problem in a digital human system that can be executed by the processor, and the program for retrieving a standard problem in a digital human system is configured to implement the above-described method for retrieving a standard problem in a digital human system.
[0032] Thirdly, the present invention also provides a computer-readable storage medium, characterized in that the storage medium stores a retrieval method program for standard questions in a digital human system, wherein when the retrieval method program for standard questions in a digital human system is executed, it implements the retrieval method for standard questions in a digital human system as described above.
[0033] The method for retrieving standard questions in the digital human system of the present invention has the following advantages over the prior art:
[0034] (1) By clustering standard questions, the distance between user questions and centroids of each category is calculated, and then similarity is calculated only in specific categories; especially when dealing with a large number of standard questions, this method significantly reduces the workload of similarity calculation and improves the speed of standard question retrieval while maintaining the accuracy of the results;
[0035] (2) By controlling the number of elements in each category to within 10% of the total, it can be ensured that the number of standard questions in each category is not too large, thereby improving the efficiency of subsequent retrieval and matching. At the same time, since the BERT model is used for word vector conversion during the clustering process, the semantic similarity between questions can be captured, further improving the accuracy of retrieval.
[0036] (3) The constructed attribution model can effectively handle the problem that user questions are at the intersection of multiple categories. The final category of user questions is determined based on the calculated probability, which reduces misjudgments caused by hard classification and further improves the accuracy of retrieval.
[0037] (4) By calculating similarity and setting a threshold, it can be ensured that the answer to the standard question is given only when the user's question is sufficiently similar to a standard question. This helps to reduce misjudgment, improve the accuracy of the answer, and by storing new questions and answers in the digital human system, the system can continuously accumulate knowledge and experience, which helps to improve the overall performance and intelligence level of the system, enabling it to better meet the needs of users and promote the accumulation of knowledge. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 This is a flowchart of the standard question retrieval method in the digital human system of the present invention;
[0040] Figure 2This diagram illustrates the user question at the boundary between two categories in the standard question retrieval method of the digital human system of the present invention.
[0041] Figure 3 This is a flowchart of the pre-calculation process for the standard question retrieval method in the digital human system of the present invention;
[0042] Figure 4 This is a flowchart illustrating the retrieval calculation process of the standard question retrieval method in the digital human system of the present invention. Detailed Implementation
[0043] The technical solutions of the present invention will be clearly and completely described below with reference to the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0044] Currently, digital human systems typically have a set of standard questions and their corresponding answers built-in. First, these standard questions are converted into word vectors using BERT or other models. When a user inputs a question, it is also converted into a word vector. Then, the similarity between the user's question vector and the vectors of each standard question is calculated. If the similarity exceeds a preset threshold, the corresponding standard answer is output. If the similarity of all standard questions does not reach the threshold, the user's question is submitted to a large language model for answering.
[0045] The current problem is that when there are many built-in standard questions, users have to wait a long time before a standard question is matched, which reduces the efficiency of the search.
[0046] The optimization approach in this embodiment is as follows: First, a clustering algorithm is used to cluster the word vectors of the standard questions and obtain the centroid of each class; the distance between the word vectors of the user questions and these centroids is calculated, and the nearest centroid is found. Then, the standard question with the highest similarity is searched in the set of standard questions corresponding to the centroid, and it is determined whether it exceeds a threshold; if no suitable standard question is found in the class, the user question is submitted to the large language model for processing; this method can significantly reduce the retrieval time without affecting the accuracy of the retrieval results.
[0047] like Figure 1 As shown, specifically, the present invention provides a method for retrieving standard questions in a digital human system, comprising the following sub-steps:
[0048] S1, cluster all standard problems in the system to obtain the centroids of each category and the maximum Euclidean distance in each category;
[0049] In step S1, clustering is performed on all standard problems in the system, including using clustering algorithms or manual intervention;
[0050] Clustering is performed using clustering algorithms, which includes converting all standard questions in the system into word vectors based on the BERT model, and then using the K-Means clustering algorithm to cluster the converted word vectors to obtain the centroid of each category.
[0051] Clustering with human input involves converting all standard questions in the system into word vectors based on the BERT model, calculating the average value of all vectors in each category in each dimension, and obtaining the centroid of each category.
[0052] It should be noted that two classification methods can be used to extract centroids from standard questions: automated and manual. The first method is to automatically classify and calculate centroids using algorithms. Standard questions are converted into 768-dimensional word vectors using BERT or other models, and then clustering algorithms, such as K-Means, are applied to cluster these vectors to obtain the centroid of each category, which is also a 768-dimensional vector. The second method is to manually classify standard questions, converting each standard question into a 768-dimensional word vector. For each category, the average value of all vectors in that category is calculated in each dimension to form a new 768-dimensional vector, which is the centroid of that category. This method ensures that the centroid of each category is more in line with actual needs.
[0053] Among them, BERT is an autoencoder language model based on Transformer that can capture the contextual information of language to generate high-quality word vector representations; the K-Means algorithm is a clustering algorithm based on iterative optimization. It divides data points into k clusters, such that each data point belongs to the nearest cluster, and the center of the cluster is the average of all data points. By iteratively updating the center point of the cluster until the convergence condition is met, the centroid of each category is finally obtained. This content is all existing technology and will not be elaborated on here.
[0054] After clustering all standard problems in the system in step S1, it is determined whether the number of standard problems in each category exceeds 10% of the total number of standard problems. If the number of standard problems in a certain category exceeds 10% of the total number of standard problems, the category is further classified until the number of standard problems in the category is less than 10% of the total number of standard problems.
[0055] It should be noted that the number of standard questions in each category is calculated, and it is determined whether the number of standard questions in each category exceeds 10% of the total number of standard questions. For those categories where the number of standard questions exceeds 10%, further subdivision is required. The standard questions in these categories can be clustered again, and the above steps are repeated until the number of standard questions in each category is less than 10% of the total number of standard questions. The final set of categories is then output, and the number of standard questions in each category meets the requirements. At the same time, the centroid of each category is recorded for comparison with the word vectors of the user's questions during subsequent retrieval.
[0056] Understandably, the 10% threshold can be adjusted based on the actual situation. If there are a large number of standard questions in the system, a lower threshold can be set to ensure retrieval efficiency; conversely, if there are few standard questions, a higher threshold can be set to reduce the complexity of classification.
[0057] According to this embodiment, the number of standard questions in each category can be ensured to be not too large, thereby improving the efficiency of subsequent retrieval and matching. At the same time, since the BERT model is used for word vector conversion during the clustering process, the semantic similarity between questions can be captured, further improving the accuracy of retrieval.
[0058] In step S1, the maximum Euclidean distance in each category is obtained, including obtaining the word vector of each standard question in each category and the centroid of the corresponding category. The Euclidean distance formula is used to calculate the Euclidean distance between each standard question in each category and the centroid of its category, and the maximum Euclidean distance in each category is obtained.
[0059] It should be noted that for each category, we iterate through each standard question, calculate the Euclidean distance between its word vector and the centroid of that category for each standard question, and record the maximum Euclidean distance between all its standard questions and the centroid for each category. This yields the maximum Euclidean distance for each category, denoted as d. i,max .
[0060] S2: Input the user question, calculate the distance between the word vector of the user question and the centroid of each category, obtain the similarity distance, and construct the similarity set;
[0061] Step S2 involves inputting a user question, calculating the distance between the word vectors of the user question and the centroids of each category to obtain similarity distances, and constructing a similarity set. This includes converting the user question into word vectors using the BERT model, calculating the Euclidean distance between the word vectors of the user question and the centroids of each category using the Euclidean distance formula to obtain similarity distances, constructing a similarity set, and adding each similarity distance to the similarity set to obtain the similarity set.
[0062] S3 compares the similarity distances in the similarity set with the maximum distance in the corresponding category, constructs the attribution model, and calculates and determines the final attribution category of the user's question;
[0063] Step S3 includes the following steps:
[0064] S31. Compare the distances of each similarity in the similarity set with the maximum Euclidean distance of its corresponding category. If the distances of the centroids of all categories exceed the maximum Euclidean distance of their respective categories, then input the user question into the large language model for answering. The user question is then associated with the answer of the large language model as the standard question and stored in the digital human system as the standard answer.
[0065] S32, if there exists a category whose similarity distance is less than the maximum Euclidean distance of its corresponding category, then the user problem is assigned to this category as the final category;
[0066] S33. If there are multiple categories whose similarity distances are all less than the maximum Euclidean distance of their corresponding categories, establish an attribution model, and calculate and determine the final attribution category of the user's problem based on the attribution model.
[0067] It should be noted that, from the maximum Euclidean distances of each category obtained in step S1, the maximum distance value of each category is extracted. Each element in the similarity set is traversed, and the similarity distance is compared with the maximum Euclidean distance of that category. If the similarity distance of all categories in the similarity set exceeds the maximum Euclidean distance of their corresponding categories, it means that the similarity between the user question and all known categories is very low. In this case, the user question is input into the large language model for solution. The user question and the solution result of the large language model are used as the new standard question and standard answer, and are associated and stored in the digital human system so that similar questions can be handled more effectively in the future. When there are multiple categories whose similarity distances are less than the maximum Euclidean distance of their corresponding categories, the attribution model is used to calculate the probability score of each possible attribution category. Based on the probability score, the category with the highest score is selected as the final attribution category of the user question, and the final attribution category of the user question is output.
[0068] This embodiment effectively determines the final category of the user's question and, when necessary, uses a large language model to answer the question and expand the knowledge base of the digital human system, which helps to improve the intelligence level of the digital human system and the user experience.
[0069] In step S33 of this embodiment, the attribution model is constructed according to a set principle, which is:
[0070] The smaller the Euclidean distance from a user's question to the centroid of a certain category, the greater the probability of it belonging to that category; if multiple categories have the same distance, the smaller the centroid of a category to its corresponding maximum Euclidean distance, the greater the probability of it belonging to that category.
[0071] like Figure 2 As shown, the word vectors for the user's question are located at the intersection of categories m and n, where d m,max >d n,max The centroid distances from the user's question to classes m and n are d, respectively. m and d n , but d m >d n Therefore, it can be determined that the user's problem should be classified as class n rather than class m.
[0072] The expression for the attribution model is:
[0073]
[0074] In the formula, P(i) is the probability that the user's question belongs to the i-th class, and d i,max d is the maximum Euclidean distance of the i-th class. i The distance between the user's question word vector and the centroid of the i-th class is called the similarity distance. β is a positive hyperparameter used to control the steepness of the function. max() is used to ensure that the probability is not negative. If the result calculated on the right is less than 0, the probability of belonging to the i-th class is 0.
[0075] It should be noted that when the distance d between the word vector of the user's question and the centroid of a certain category... i The maximum Euclidean distance d greater than that of this category i,max When d , it means that the problem does not belong to this category, and its probability P(i) is 0; similarly, when d i =d i,max When the word vector of the user's question is located on the boundary of this category, it is also determined that it does not belong to this category, so P(i) is still 0.
[0076] If under certain circumstances, d i =d i,max When the probability of the problem belonging to this category is 0.8, we can calculate β = 4.5. If the probability of belonging to this category is 0.75 under the same conditions, then β = 4. In this way, we can determine the value of β.
[0077] Therefore, by calculating the distance d between the word vector of the user question and the centroid of each category... iThe probability of a user's problem belonging to each category is calculated using a formula. Among all categories, the category with the highest probability is selected as the classification result of the user's problem. If the calculated probability of all categories is 0, it means that the user's problem is not related to any known category and should be classified into other categories.
[0078] S4 calculates the similarity between the word vector of the user's question and all standard questions in the final category, selects the standard question with the highest similarity, and outputs the answer corresponding to the standard question as the result, giving the user the answer.
[0079] Step S4 includes the following sub-steps:
[0080] Calculate the similarity between the word vector of the user's question and all standard questions in the final category, and obtain the similarity value corresponding to each standard question. The similarity calculation expression is:
[0081]
[0082] In the formula, A is the word vector of the user input question, A i It is the word vector of the current element, A·A i Represent vectors A and A i The dot product, which is the sum of the element-wise multiplications of corresponding dimensions, is ||A|| and ||A||. i || are vectors A and A' respectively. i The Euclidean norm is the square root of the sum of the squares of the elements.
[0083] A preset similarity threshold is set. Based on the similarity values corresponding to each standard question, the maximum similarity value is obtained and compared with the similarity threshold. If the maximum similarity value is less than the similarity threshold, the user question is input into the large language model for solution, and the user question is associated with the solution result of the large language model as the standard answer and stored in the digital human system. If the maximum similarity value is greater than the similarity threshold, the standard answer corresponding to the standard question with the maximum similarity value is obtained as the output result and given to the user.
[0084] It should be noted that by calculating similarity and setting a threshold, the system can ensure that the answer to a standard question is only given when the user's question is sufficiently similar to that of a standard question. This helps reduce misjudgments and improve the accuracy of the answers. By storing new questions and answers in the digital human system, the system can continuously accumulate knowledge and experience, which helps improve the overall performance and intelligence level of the system, enabling it to better meet the needs of users and promote the accumulation of knowledge.
[0085] This embodiment clusters standard questions, first calculating the distance between the user's question and the centroids of each category, and then calculating similarity only within specific categories. Especially when dealing with a large number of standard questions, this method significantly reduces the workload of similarity calculation, while the increased computational cost for distance calculation and classification judgment is very limited. This method improves the speed of standard question retrieval while maintaining the accuracy of the results.
[0086] Example 1
[0087] This method consists of two parts: pre-calculation and retrieval calculation.
[0088] Preliminary calculations involve classifying the standard problems given their knowledge and calculating the centroid of each class and the maximum Euclidean distance between the centroid and all elements in that class. This process is a one-time operation and does not require recalculation unless the standard problems are added to or modified.
[0089] The retrieval calculation includes, firstly, classifying the question after the user inputs it, then calculating the similarity within the specific category and selecting the standard question with the highest similarity; then comparing the similarity with a preset threshold; if the similarity exceeds the threshold, the answer to the standard question is output; otherwise, the user's question is submitted to the large language model for solution.
[0090] This method can significantly reduce the workload of similarity calculation when dealing with a large number of standard questions, while maintaining retrieval speed and accuracy.
[0091] like Figure 3 As shown, the pre-calculation involves classifying a large number of standard problems, calculating the centroid of each class, and the maximum distance between each element in each class and the centroid. The specific implementation steps are as follows:
[0092] Step 1: Collect standard questions and answers; First, collect known standard questions and their corresponding answers; These standard questions usually come from the company's internal knowledge base, such as company introductions or introductions of a certain system, which are usually difficult for large language models to answer accurately; After completing this step, proceed to Step 2.
[0093] Step 2: Standard problem vectorization; Vectorize the standard problem using BERT or another model; In this embodiment, the vectorization dimension is 768; If other models are used, the dimensions may be different, but it is necessary to ensure that the model and dimensions are consistent with those used when vectorizing user problems later; After completing this step, proceed to Step 3.
[0094] Step 3: Standard Problem Classification and Centroid Calculation; All standard problems can be automatically classified using the K-Means algorithm or other classification algorithms, and the centroid of each class can be calculated. If manual classification is chosen, the standard problems need to be manually classified, and then the mean of each dimension is calculated using word vectors to form the centroid vector. After classification, it is necessary to check if any class contains too many elements. If so, that class needs to be further classified until each class contains no more than 10% of the total number of elements. After completing this step, proceed to Step 4.
[0095] Step 4: Initialize an empty set T; this set is used to store the results of the previous calculations; each element in the set contains the classification number, the centroid of each class, and the maximum distance between each element in the class and the centroid; first, initialize the set T to empty, and construct a framework to store the above structure; after completing this step, proceed to step 5.
[0096] Step 5: Initialize i = 1. Initialize the category number i to 1 to record the category sequence number; after completing this step, proceed to step 6.
[0097] Step 6: Select a category; select a category from the general categories; if this is the first time selecting, select the first category; otherwise, select the next category after the current category; after completing this step, proceed to Step 7.
[0098] Step 7: Transfer variable V i Set the centroid of the current category. Each category has one and only one centroid. After completing this step, proceed to step 8.
[0099] Step 8: Initialize variable d i,max The value is zero; this variable is used to store the maximum Euclidean distance from the centroid in each class. After completing this step, proceed to step 9.
[0100] Step 9: Select a word vector from this category. Select a word vector from the current category. If this is the first selection, select the first word vector; otherwise, select the next word vector after the current word vector. After completing this step, proceed to Step 10.
[0101] Step 10: Calculate V i The distance tempd from the current vector; calculate V using the Euclidean distance formula. i The distance tempd between the current word vector and the current word vector is stored in the variable d. i,max After completing this step, proceed to step 11.
[0102] Step 11: If d i,max If <tempd, proceed to step 12; otherwise, proceed to step 13.
[0103] Step 12: Assign the value of tempd to d i,max To ensure d i,max It is always the maximum Euclidean distance from the centroid within the current category. After completing this step, proceed to step 13.
[0104] Step 13: Determine whether the distance to the centroid of all elements in the current category has been calculated. If yes, proceed to Step 14; otherwise, continue calculating the distance to the remaining elements and return to Step 9.
[0105] Step 14: Set the current classification number i and centroid V. i and maximum distance d i,max Combine them into a single element and add it to set T; after completing this step, proceed to step 15.
[0106] Step 15: Determine whether the distance to the centroid has been calculated for all elements of all categories; if yes, proceed to step 17; if not, continue processing the remaining categories and proceed to step 16.
[0107] Step 16: After completing the calculation for the current category and obtaining its maximum distance, increment the category number i by 1 and update the category number i to prepare for the calculation of the next category. Then return to step 6.
[0108] Step 17: Output the result set T of the previous calculations for subsequent calculations.
[0109] like Figure 4 As shown, the retrieval calculation uses the data generated in the first step to classify user questions and then determines whether to select the answer corresponding to a standard question or let the large language model generate the answer. The specific implementation steps are as follows:
[0110] Step 1: The user asks a question; after the user wakes up the digital human system, they can input a question via voice or text; the system will collect the user's question, and if the input is voice, it will be converted into text; after completing this step, proceed to Step 2.
[0111] Step 2: Vectorize the user question A; Convert the text question obtained in Step 1 into a word vector, denoted as A, using a vectorization model, ensuring that it has the same dimension as the vector in the previous calculation step; After completing this step, proceed to Step 3.
[0112] Step 3: Set thresh; thresh is used to determine the similarity between the user's input question and a standard question; if the similarity exceeds this threshold, the user's question is considered to be the same as a standard question, and the answer corresponding to the standard question can be used directly to answer the user; usually, the value of thresh is set above 0.9 and is read from the configuration file; after completing this step, proceed to step 4.
[0113] Step 4: Initialize variables tmpi and tp; initialize variable tmpi to -1 to store the category to which the user's question belongs, with an initial value of -1 indicating that it belongs to other categories; initialize variable tp to 0 to store the probability that the user's question belongs to a certain category; after completing this step, proceed to step 5.
[0114] Step 5: Select an element from set T; Select an element from the set of previous calculation results T for processing. If it is the first selection, select the first element; otherwise, select the next element after the current element; After completing this step, proceed to step 6.
[0115] Step 6: Calculate the centroid V between the user question vector A and the current element. i The Euclidean distance d between them i After completing this step, proceed to step 7.
[0116] Step 7: Calculate the attribution probability P(i). Use the attribution model to calculate the probability that the user's question belongs to the category represented by the current element, d. i It is the result of the previous calculation, and d i,max This is the maximum Euclidean distance value corresponding to the current element; after completing this step, proceed to step 8.
[0117] Step 8: P(i) > tp; Determine whether the probability P(i) of the user's question belonging to the current category is greater than the currently stored maximum probability tp; if yes, proceed to step 9; otherwise, proceed to step 10.
[0118] Step 9: Update tmpi and tp; assign the current element's category number i to tmpi, and assign the currently calculated probability P(i) to tp; at this point, tp stores the maximum probability that the user's question belongs to a certain category, while tmpi stores the category number corresponding to that maximum probability; after completing this step, proceed to step 10.
[0119] Step 10: Has set T been traversed completely? Determine if all elements in set T have completed the probability calculation for the user's question. If yes, proceed to step 11; otherwise, return to step 5 and continue the calculation and judgment.
[0120] Step 11: tmpi > 0; Determine if tmpi is greater than 0; If tmpi is greater than 0, it means the user's question belongs to a certain category, and further similarity needs to be determined, proceed to step 12; Otherwise, it means the user's question does not belong to any category, and large language model is needed for processing, proceed to step 20.
[0121] Step 12: Obtain classification information through TMPI; using the category number stored in TMPI, obtain the classification information corresponding to that number, including the word vector of the standard question and the corresponding answer; after completing this step, proceed to step 13.
[0122] Step 13: Initialize tmps and tmpk; initialize tmps to 0 to store the maximum similarity between the user's question vector and the current standard question word vector; initialize tmpk to an empty string to store the corresponding answer text; after completing this step, proceed to step 14.
[0123] Step 14: Select an element from the acquired classification information for processing; if this is the first selection, select the first element; otherwise, select the next element after the current element; after completing this step, proceed to Step 15.
[0124] Step 15: Compare the word vector A of the user's question with the word vector A of the current element. i Calculate the similarity w; after completion, proceed to step 16.
[0125] Step 16: Determine whether the currently calculated similarity w is greater than tmps; if so, it means that the current similarity w is greater than the previously stored maximum similarity tmps, proceed to step 17; otherwise, proceed to step 18.
[0126] Step 17: Update tmps and tmpk; assign the current similarity w to tmps to ensure that tmps always stores the maximum similarity; assign the answer for the current element to tmpk so that tmpk stores the answer corresponding to the maximum similarity. After completing this step, proceed to step 18.
[0127] Step 18: Has the category set been completely traversed? Determine if all elements in the category set have been traversed and similarity calculated. If yes, proceed to Step 19; otherwise, return to Step 14 and select the next element for calculation.
[0128] Step 19: Determine whether the maximum similarity tmps is greater than or equal to the preset threshold thresh. If yes, it means that the user question is very similar to a certain standard question, proceed to step 21; otherwise, it means that the user question has no obvious similarity to any question in this category, proceed to step 20.
[0129] Step 20: Obtain the text information input by the user and submit it to the large language model for processing. After completing this step, proceed to step 22.
[0130] Step 21: Obtain the answer through tmpk; output the answer stored in tmpk to the digital human system, which will convert it into speech to respond.
[0131] Step 22: Output the results generated by the large language model to the digital human system, which then converts them into speech to respond.
[0132] In this embodiment, similarity is calculated to determine whether the user's input question is similar to the word vectors of standard questions. Traditional methods require calculating the similarity for each of the 1000 standard questions, i.e., performing 1000 calculations. By first classifying the questions, this step is completed in advance and does not consume response time. The number of elements in each category is controlled within 10% of the total, requiring only about 100 similarity calculations, as well as distance calculations between the user's question vector and the centroids of each category. When there are a large number of standard questions and answers, this method greatly reduces the amount of computation and improves the response speed of the digital human.
[0133] Secondly, the present invention also provides an electronic device, including at least one processor, at least one memory, a communication interface, and a bus; wherein the processor, memory, and communication interface communicate with each other through the bus; the memory stores a program for retrieving a standard problem in a digital human system that can be executed by the processor, and the program for retrieving a standard problem in a digital human system is configured to implement the above-described method for retrieving a standard problem in a digital human system.
[0134] Thirdly, the present invention also provides a computer-readable storage medium, characterized in that the storage medium stores a retrieval method program for standard questions in a digital human system, wherein when the retrieval method program for standard questions in a digital human system is executed, it implements the retrieval method for standard questions in a digital human system as described above.
[0135] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for searching a standard question in a digital human system, characterized by, The step S1 comprises the following sub-steps: S1, clustering all standard questions in the system to obtain the centroid of each category and the maximum Euclidean distance in the category, including obtaining the word vector of each standard question in each category and the centroid of the corresponding category, calculating the Euclidean distance between each standard question in each category and the centroid of the category by using the Euclidean distance formula, and obtaining the maximum Euclidean distance in each category; S2, inputting the user question, calculating the distance between the word vector of the user question and the centroid of each category, obtaining the similar distance, and constructing a similar set; S3, comparing each similar distance in the similar set with the maximum Euclidean distance in the corresponding category, constructing a belonging model, and calculating and determining the final belonging category of the user question; The step S3 comprises: comparing each similar distance in the similar set with the maximum Euclidean distance in the corresponding category; If the Euclidean distance of all category centroids exceeds the maximum Euclidean distance of the corresponding category, the user question is input into the large language model for answering, and the user question and the answer of the large language model are associated and stored in the digital human system as standard questions and standard answers; If the similar distance of one category is less than the maximum Euclidean distance of the corresponding category, the user question is classified into this category as the final belonging category; If the similar distances of multiple categories are all less than the maximum Euclidean distances of the corresponding categories, a belonging model is established, and the final belonging category of the user question is calculated and determined according to the belonging model; S4, calculating the similarity between the word vector of the user question and all standard questions in the final belonging category, selecting the standard question with the highest similarity, and outputting the answer corresponding to the standard question as the result, and giving the user answer.
2. The method of claim 1, wherein the standard question is retrieved by using a keyword search function. In the step S1, all standard questions in the system are clustered to obtain the centroid of each category, wherein all standard questions in the system include clustering by using a clustering algorithm or manual participation; The clustering by using the clustering algorithm comprises converting all standard questions in the system into word vectors based on a BERT model, clustering the converted word vectors by using a K-Means clustering algorithm, and obtaining the centroid of each category; The clustering by manual participation comprises converting all standard questions in the system into word vectors based on a BERT model, calculating the average value of all vectors in each dimension in the corresponding category for each category, and obtaining the centroid of each category.
3. The method of claim 2, wherein the standard question is retrieved by searching a database of standard questions based on the keyword. After clustering all standard questions in the system in the step S1, it is judged whether the number of standard questions in each category exceeds 10% of the number of all standard questions, if the number of standard questions in a category exceeds 10% of the number of all standard questions, the category is further classified until the number of standard questions in the category is less than 10% of the number of all standard questions.
4. The method of claim 1, wherein the standard question is retrieved by using a keyword search function of the digital human system. In step S2, the input user question is calculated, the distance between the word vector of the user question and the centroid of each category is calculated, the similarity distance is obtained, and the similarity set is constructed; wherein, the user question is converted into a word vector through a BERT model, the Euclidean distance between the word vector of the user question and the centroid of each category is calculated by using the Euclidean distance formula, the similarity distance is obtained, the similarity set is constructed, each similarity distance is added to the similarity set, and the similarity set is obtained.
5. The method of claim 1, wherein the standard question is retrieved by using a keyword search function of the digital human system. In step S33, if the similarity distance of multiple categories is less than the maximum Euclidean distance of the corresponding category, a belonging model is established, and the final belonging category of the user question is calculated and determined according to the belonging model, wherein the belonging model is constructed according to a set principle, and the set principle is: The smaller the Euclidean distance from the centroid of a category to the user question, the greater the probability of belonging to the category; if there are the same distances in multiple categories, the smaller the maximum Euclidean distance from the centroid of the category to the corresponding category, the greater the probability of belonging to the category; The expression of the belonging model is: where P(i) is the probability of the user question belonging to the i-th class, d i,max is the maximum Euclidean distance of the i-th class, d i is the distance between the user question vector and the i-th class centroid, i.e., the similarity distance, β is a positive hyper-parameter to control the steepness of the function, and max() is used to ensure that the probability is not negative, and if the result of the right side calculation is less than 0, the probability of belonging to the i-th class is 0.
6. The method of claim 1, wherein the standard question is retrieved by: In step S4, the similarity between the word vector of the user question and all standard questions in the final belonging category is calculated, the standard question with the highest similarity is selected, and the answer corresponding to the standard question is output as the result, and the user answer is given, wherein, the following sub-steps are included: The similarity between the word vector of the user question and all standard questions in the final belonging category is calculated, and the similarity value corresponding to each standard question is obtained, and the similarity calculation expression is: where A is a word vector for the user input question, A i is a word vector in the current element, A·A i denotes the dot product of vectors A and A i , i.e., the sum of the products of the corresponding dimensions, ||A|| and ||A i || are the Euclidean norms of vectors A and A i , i.e., the square root of the sum of the squares of the elements. A preset similarity threshold is set, the maximum similarity value is obtained according to the similarity value corresponding to each standard question, and the maximum similarity value is compared with the similarity threshold; if the maximum similarity value is less than the similarity threshold, the user question is input into the large language model for answering, and the user question is associated and stored in the digital human system as a standard question and the answering result of the large language model as a standard answer; if the maximum similarity value is greater than the similarity threshold, the standard answer corresponding to the standard question with the maximum similarity value is obtained as the output result, and the user answer is given.
7. An electronic device, comprising: The digital human system includes at least one processor, at least one memory, a communication interface, and a bus; wherein the processor, memory, and communication interface communicate with each other through the bus; the memory stores a digital human system standard question retrieval method program executable by the processor, and the digital human system standard question retrieval method program is configured to implement the digital human system standard question retrieval method of any one of claims 1-6.
8. A computer-readable storage medium, characterized in that, The storage medium stores a digital human system standard question retrieval method program, and the digital human system standard question retrieval method program is executed to implement the digital human system standard question retrieval method of any one of claims 1-6.
Citation Information
Patent Citations
Method and system for determining standard problem based on similarity
CN112131876A
A problem warehousing method and device
CN109918498A
Text classification method and system
CN115345243A