Retrieval method for standard questions in digital human system

By clustering and center of mass calculation of standard problems in the digital human system, combining the distance between the word vector and the center of mass and the probability model of the user's problem, the problem of slow retrieval speed and low accuracy of standard problems is solved, and fast and efficient Standard question search and answer output.

CN119474310AActive Publication Date: 2025-02-18HUBEI TAIYUE SATELLITE TECH DEV CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202411585129.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-07
Publication Date
2025-02-18
Estimated Expiration
2044-11-07

AI Technical Summary

Technical Problem

In the digital human system, when the number of built-in standard questions is large, the user needs to wait for a long search time, the similarity calculation work is large, the standard problem retrieval speed is slow, which affects the user experience, and performs a gathering in user questions. During class analysis, it is impossible to accurately classify, which reduces the accuracy of the search results.

Method used

By clustering all standard problems in the system, the maximum European-style distance in each category of centroid and categories is obtained, the distance between the word vector and the centroid of each category of centroid is calculated for the user's problems, a similar set is constructed, and the similar distance and maximum distance are judged. Comparison, build an attribution probability model, determine the final attribution category of user questions, and calculate the similarity in this category, and select the standard question with the highest similarity output answer.

Benefits of technology

It significantly reduces the workload of similarity calculation, improves the speed of standard problem retrieval, maintains the accuracy of results, can handle a large number of standard problems, and improves the user experience and system intelligence level.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119474310A_ABST
    Figure CN119474310A_ABST
Patent Text Reader

Abstract

The invention provides a method for retrieving standard questions in a digital human system, which comprises the following sub-steps of: clustering all standard questions in the system to obtain the centroid of each category and the maximum Euclidean distance in the category; inputting a user question, calculating the distance between the word vector of the user question and the centroid of each category to obtain a similar distance, and constructing a similar set; all similar distances in the similar set are judged and compared with the maximum distance in the corresponding categories, an affiliation probability model is constructed, and the final affiliation category of the user question is calculated and determined; the similarity between the word vector of the user question and all the standard questions in the final affiliation category is calculated, the standard question with the highest similarity is selected, the answer corresponding to the standard question is output as a result, and the user answer is given, so that the workload of similarity calculation is remarkably reduced, the standard question retrieval speed is increased, and the user experience is improved. Meanwhile, the result accuracy is kept.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of digital human systems, and in particular to a method for retrieving standard questions in a digital human system. Background Art

[0002] In the digital human system, some standard questions and their corresponding answers are usually built in. First, these standard questions are converted into word vectors through BERT or other models; when the user enters 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 the 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 the subsequent large language model for answering.

[0003] A method and system for determining standard questions based on similarity, with publication number CN112131876A, includes step S1 of acquiring user question information, calculating the similarity between the user question and existing training data according to a similarity model, storing the questions with a similarity lower than a specified threshold as data to be processed, and determining unfamiliar data that does not conform to the characteristics of the existing standard questions; and step S2 of performing cluster analysis on the user questions in the data to be processed, extracting the characteristics of each category as hot words, sorting the hot words from high to low, storing the hot questions with the highest ranking in a database to be labeled, and expanding them for standard questions in an intelligent question-answering system.

[0004] The above existing solutions have the problem that when there are a large number of built-in standard questions, the user needs to wait for a long search time before a standard question is matched, the workload of similarity calculation is large, and the speed of standard question retrieval is slow, which affects the user experience. In addition, when performing cluster analysis on user questions, when the user questions are between multiple categories, they cannot be accurately classified, thereby 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 centroid of each category and the maximum Euclidean distance within the 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 a similarity set;

[0009] S3, comparing each similarity distance in the similarity set with the maximum distance in the corresponding category, and constructing an attribution probability model to calculate and determine the final attribution category of the user question;

[0010] S4, calculates the similarity between the word vector of the user question and all standard questions in the final belonging category, selects the standard question with the highest similarity, and outputs the answer corresponding to the standard question as the result, giving the user answer.

[0011] Based on the above technical solution, preferably, in step S1, all standard questions in the system are clustered to obtain the centroid of each category, wherein all standard questions in the system are clustered using a clustering algorithm or manual participation;

[0012] Clustering using a clustering algorithm includes converting all standard questions in the system into word vectors based on the BERT model, clustering the converted word vectors using the K-Means clustering algorithm, and obtaining the centroid of each category;

[0013] Clustering using manual participation includes converting all standard questions in the system into word vectors based on the BERT model, calculating the average value of all vectors in each dimension in the corresponding category, and obtaining the centroid of each category.

[0014] Based on the above technical solution, preferably, after clustering all standard questions in the system in step S1, determine whether the number of standard questions contained 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, further classify the category until the number of standard questions contained in the category is less than 10% of the number of all standard questions.

[0015] Based on the above technical solution, preferably, the maximum Euclidean distance in each category is obtained in step S1, including 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] On the basis of the above technical solution, preferably, the user question is input in step S2, the distance between the word vector of the user question and the centroid of each category is calculated, the similarity distance is obtained, and a similarity set is constructed; wherein, the user question is converted into a word vector through a BERT model, and 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, construct a similarity set, and each similarity distance is added to the similarity set to obtain a similarity set.

[0017] Based on the above technical solution, preferably, the step S3 of comparing each similarity distance in the similarity set with the maximum distance in the corresponding category, building an attribution probability model, and calculating and determining the final attribution category of the user question includes the following steps:

[0018] S31, comparing each similarity distance 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 the corresponding category, the user question is input into the large language model for answering, and the user question is taken as a standard question and the answer result of the large language model is taken as a standard answer, and stored in the digital human system in association;

[0019] S32, if there is a category whose similarity distance is smaller than the maximum Euclidean distance of its corresponding category, the user question is classified into this category as the final category;

[0020] S33, if there are multiple categories whose similarity distances are all smaller than the maximum Euclidean distance of their corresponding categories, establish an attribution model, and calculate and determine the final attribution category of the user question according to the attribution model.

[0021] On the basis of the above technical solution, preferably, in step S33, if there are multiple categories whose similarity distances are all smaller than the maximum Euclidean distance of their corresponding categories, an attribution model is established, and the final attribution category of the user question is calculated and determined according to the attribution model, wherein the attribution model is constructed according to a set principle, and the set principle is:

[0022] The smaller the Euclidean distance from the user question to the centroid of a category, the greater the probability of belonging to that category; if there are the same distances in multiple categories, the smaller the Euclidean distance from the centroid of a category to its corresponding maximum Euclidean distance, the greater the probability of belonging to that category;

[0023] The expression of the attribution model is:

[0024]

[0025] Where P(i) is the probability that the user's question belongs to the i-th category, d i,max is the maximum Euclidean distance of the i-th class, d iis the distance between the user question word vector and the centroid of the i-th category, that is, 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 category is 0.

[0026] Based on the above technical solution, preferably, the similarity between the word vector of the user question and all the standard questions in the final belonging category is calculated in step S4, the standard question with the highest similarity is selected, and the answer corresponding to the standard question is output as a result to give the user answer, which 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] Where A is the word vector of the user input question, A i is the word vector in the current element, A·A i Represents vectors A and A i The dot product of ||A|| and ||A i || are vectors A and A respectively i The Euclidean norm of , which is the square root of the sum of the squares of its elements;

[0030] A similarity threshold is preset, and the maximum similarity value is obtained according to the similarity values ​​corresponding to the standard questions, 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 with the standard question and the answer 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 the user answer is given.

[0031] In a second aspect, the present invention also provides an electronic device comprising 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 via the bus; the memory stores a program for a method for retrieving standard questions in a digital human system that can be executed by the processor, and the program for a method for retrieving standard questions in a digital human system is configured to implement a method for retrieving standard questions in a digital human system as described above.

[0032] In a third aspect, the present invention also provides a computer-readable storage medium, characterized in that a program for a method for retrieving standard questions in a digital human system is stored on the storage medium, and when the program for a method for retrieving standard questions in a digital human system is executed, a method for retrieving standard questions in a digital human system as described above is implemented.

[0033] The method for retrieving standard questions in the digital human system of the present invention has the following beneficial effects compared with the prior art:

[0034] (1) By clustering standard questions, the distance between user questions and the centroid 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 less than 10% of the total, it can ensure 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 in 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 the user's questions are at the intersection of multiple categories. The final attribution category of the user's questions is determined based on the calculated probability, which reduces the misjudgment caused by rigid 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 a standard question is given only when the user's question is similar enough to a standard question; this helps reduce misjudgments and improve the accuracy of answers. 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 user needs and promote the accumulation of knowledge. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0039] Figure 1 A flowchart of a method for retrieving standard questions in a digital human system of the present invention;

[0040] Figure 2A schematic diagram of a user question at the junction between two categories in the method for retrieving standard questions in the digital human system of the present invention;

[0041] Figure 3 A pre-calculation flow chart of a retrieval method for standard questions in a digital human system of the present invention;

[0042] Figure 4 This is a retrieval calculation flow chart of the retrieval method for standard questions in the digital human system of the present invention. DETAILED DESCRIPTION

[0043] The following will be combined with the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0044] At present, some standard questions and their corresponding answers are usually built into the digital human system. First, these standard questions are converted into word vectors through BERT or other models. When the user enters 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 the 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 the large language model for answering.

[0045] The current problem is that when there are a large number of built-in standard questions, users need to wait for a long time before matching the standard questions, which reduces the efficiency of the search.

[0046] The optimization idea of ​​this embodiment is: first use a clustering algorithm to cluster the word vectors of standard questions and obtain the centroid of each class; calculate the distance between the word vectors of user questions and these centroids, find the nearest centroid, and then find the standard question with the greatest similarity in the standard question set corresponding to the centroid to determine whether it exceeds the threshold; if no suitable standard question is found in the class, submit the user question 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 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 centroid of each category and the maximum Euclidean distance within the category;

[0049] In step S1, all standard problems in the system are clustered using a clustering algorithm or manual participation;

[0050] Clustering using a clustering algorithm includes converting all standard questions in the system into word vectors based on the BERT model, clustering the converted word vectors using the K-Means clustering algorithm, and obtaining the centroid of each category;

[0051] Clustering using manual participation includes converting all standard questions in the system into word vectors based on the BERT model, calculating the average value of all vectors in each dimension in the corresponding category, and obtaining the centroid of each category.

[0052] It should be noted that in order to extract the centroid from the standard questions, two classification methods can be used: automated and manual. The first method is to automatically classify and calculate the centroid through an algorithm; convert the standard questions into 768-dimensional word vectors through BERT or other models, and then apply clustering algorithms such as K-Means to cluster these vectors to obtain the centroid of each category. The centroid of each category is also a 768-dimensional vector. The second method is to manually classify the standard questions and convert each standard question into a 768-dimensional word vector; for each category, calculate the average value of all vectors in the category in each dimension to form a new 768-dimensional vector, that is, the centroid of the category, which can ensure that the centroid of each category is more in line with actual needs.

[0053] Among them, BERT is a Transformer-based autoencoding language model that can capture the contextual information of the language to generate high-quality word vector representations; the K-Means algorithm is a clustering algorithm based on iterative optimization, which divides data points into k clusters so that each data point belongs to the nearest cluster, and the center of the cluster is the average of all data points; the center point of the cluster is iteratively updated until the convergence condition is reached, and finally the centroid of each category is obtained. This content is all existing technology and will not be elaborated here.

[0054] After clustering all standard questions in the system in step S1, determine whether the number of standard questions contained 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, further classify the category until the number of standard questions contained in the category is less than 10% of the number of all standard questions.

[0055] It should be noted that the number of standard questions contained 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 with more than 10% of standard questions, further subdivision is required. The clustering algorithm can be performed again on the standard questions in this category, and the above steps are repeated until the number of standard questions contained in each category is less than 10% of the total number of standard questions. The final set of categories is output, and the number of standard questions contained in each category meets the requirements. At the same time, the centroid of each category is recorded for comparison with the word vector of the user's question during subsequent retrieval.

[0056] It is understandable that the 10% threshold can be adjusted according to actual conditions. If the number of standard questions in the system is very large, a lower threshold can be set to ensure retrieval efficiency; conversely, if the number of standard questions is small, a higher threshold can be set to reduce the complexity of classification.

[0057] According to this embodiment, it can be ensured that the number of standard questions in each category will not be 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 in 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, 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.

[0059] It should be noted that for each category, each standard question in it is traversed, and for each standard question, the Euclidean distance between its word vector and the centroid of the category is calculated. For each category, the maximum value of the Euclidean distance between all its standard questions and the centroid is recorded, and the maximum Euclidean distance of each category is obtained, which is recorded 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 a similarity set;

[0061] Step S2 includes inputting a user question, calculating the distance between the word vector of the user question and the centroid of each category, obtaining a similarity distance, and constructing a similarity set; wherein the user question is converted into a word vector through a BERT model, and 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 a similarity distance, construct a similarity set, and each similarity distance is added to the similarity set to obtain a similarity set.

[0062] S3, comparing each similarity distance in the similarity set with the maximum distance in the corresponding category, and constructing an attribution probability model to calculate and determine the final attribution category of the user question;

[0063] Step S3 includes the following steps:

[0064] S31, comparing each similarity distance 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 the corresponding category, the user question is input into the large language model for answering, and the user question is taken as a standard question and the answer result of the large language model is taken as a standard answer, and stored in the digital human system in association;

[0065] S32, if there is a category whose similarity distance is smaller than the maximum Euclidean distance of its corresponding category, the user question is classified into this category as the final category;

[0066] S33, if there are multiple categories whose similarity distances are all smaller than the maximum Euclidean distance of their corresponding categories, establish an attribution model, and calculate and determine the final attribution category of the user question according to the attribution model.

[0067] It should be noted that, from the maximum Euclidean distance 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 the category. If the similarity distances of all categories in the similarity set exceed the maximum Euclidean distance of their corresponding categories, it means that the similarity between the user question and all known categories is very low. At this time, the user question is input into the large language model for answering, and the user question and the answer result of the large language model are used as new standard questions and standard answers, and are associated and stored in the digital human system so that similar problems 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. According to 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] In this embodiment, the final category of the user's question is effectively determined, and when necessary, a large language model is used to answer and expand the knowledge base of the digital human system, which helps to improve the intelligence level of the digital human system and user experience.

[0069] In step S33 of this embodiment, the attribution model is constructed according to the setting principle, and the setting principle is:

[0070] The smaller the Euclidean distance from the user question to the centroid of a category, the greater the probability of belonging to that category; if there are the same distances in multiple categories, the smaller the Euclidean distance from the centroid of a category to its corresponding maximum Euclidean distance, the greater the probability of belonging to that category;

[0071] like Figure 2 As shown, the word vector of the user’s question is located at the junction of categories m and n, where d m,max >d n,max , the distances from the user question to the centroid of class m and class n are d m and d n , but d m >d n , so it can be judged that the user's question should be classified into category n instead of category m.

[0072] The expression of the attribution model is:

[0073]

[0074] Where P(i) is the probability that the user's question belongs to the i-th category, d i,max is the maximum Euclidean distance of the i-th class, d i is the distance between the user question word vector and the centroid of the i-th category, that is, 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 category 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 Greater than the maximum Euclidean distance d of the category i,max When , 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 , the word vector of the user's question is on the boundary of this category and is also judged not to belong to this category, so P(i) is still 0.

[0076] If in some cases, i =d i,max / 2, the probability that the problem belongs to this category is 0.8, so β=4.5 can be calculated. If in the same case, the probability of belonging is 0.75, then β=4. This method 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 i, use the formula to calculate the probability of the user question belonging to each category. Among all categories, select the category with the largest belonging probability as the classification result of the user question. If the calculated probabilities of all categories are 0, it means that the user question is not related to any known category and should be classified as other categories.

[0078] S4, calculates the similarity between the word vector of the user question and all standard questions in the final belonging category, selects the standard question with the highest similarity, and outputs the answer corresponding to the standard question as the result, giving the user 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] Where A is the word vector of the user input question, A i is the word vector in the current element, A·A i Represents vectors A and A i The dot product of ||A|| and ||A i || are vectors A and A respectively i The Euclidean norm of , which is the square root of the sum of the squares of its elements;

[0083] A similarity threshold is preset, and the maximum similarity value is obtained according to the similarity values ​​corresponding to the standard questions, 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 with the standard question and the answer 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 the user answer is given.

[0084] It should be noted that by calculating the similarity and setting the threshold, it can be ensured that the answer to a standard question is only given when the user's question is similar enough to a standard question; this helps reduce misjudgments and improve the accuracy of answers. 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 user needs and promote the accumulation of knowledge.

[0085] This embodiment clusters the standard questions, first calculates the distance between the user questions and the centroid of each category, and then calculates the similarity only in specific categories; especially when dealing with a large number of standard questions, this method significantly reduces the workload of similarity calculation, while the amount of calculation required for the increased 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] Embodiment 1

[0087] The method includes two parts: pre-calculation and retrieval calculation, where:

[0088] The pre-calculation includes classifying the standard problems first, and calculating the centroid of each class and the maximum Euclidean distance between the centroid and all elements in the class, when the standard problems are known. This process is a one-time process and does not need to be recalculated unless the standard problems are added or modified.

[0089] The retrieval calculation includes: when the user enters a question, first make a classification judgment, then calculate the similarity in a specific category, and select the standard question with the greatest similarity; then compare the similarity with a preset threshold; if the similarity exceeds the threshold, output the answer to the standard question; otherwise, submit the user question to the large language model for answer.

[0090] This approach can significantly reduce the workload of similarity calculation when processing a large number of standard questions while maintaining retrieval speed and accuracy of results.

[0091] like Figure 3 As shown in the figure, the pre-calculation is to classify a large number of standard questions, calculate the centroid of each category, and the maximum distance between each element in each category 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 a company introduction or an introduction to a system, which are usually difficult for large language models to answer accurately. After completing this step, proceed to step 2.

[0093] Step 2: Vectorize standard questions; use BERT or other models to vectorize standard questions; in this embodiment, the vectorization dimension is 768 dimensions; if other models are used, there may be different dimensions, but it is necessary to ensure that the model and dimensions used for subsequent user question vectorization are consistent; after completing this step, proceed to step 3.

[0094] Step 3: Standard question classification and centroid calculation; You can use the K-Means algorithm or other classification algorithms to automatically classify all standard questions and calculate the centroid of each category; if you choose manual classification, you need to manually classify the standard questions, and then calculate the mean of each dimension through the word vector to form the centroid vector; after classification, you need to check whether there is a category containing too many elements. If so, you need to further classify the category until the elements of each category do not exceed 10% of the total. After completing this step, go to step 4.

[0095] Step 4: Initialize an empty set T; this set is used to store the results of the previous calculation; 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 for storing the above structure; after completing this step, go to step 5.

[0096] Step 5: Initialize i=1. Initialize the category number i to 1 to record the category serial number; after completing this step, proceed to step 6.

[0097] Step 6: Select a category; select a category from the general category; if it is the first time, select the first category; otherwise, select the next category of the current category; after completing this step, go to step 7.

[0098] Step 7: Set the variable V i Set it to the centroid of the current category. Each category has only one centroid. After completing this step, go to step 8.

[0099] Step 8: Initialize variable d i,max is zero, and 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 it is the first time to select, select the first word vector; otherwise, select the next word vector of the current word vector. After completing this step, go to step 10.

[0101] Step 10: Calculate V i The distance tempd from the current vector; V is calculated using the Euclidean distance formula i The distance tempd between the current word vector and the current word vector, and the result is stored in the variable d i,max After completing this step, proceed to step 11.

[0102] Step 11: If d i,max <tempd, go to step 12; otherwise, go to step 13.

[0103] Step 12: Assign the value of tempd to d i,max To ensure that i,max is always the maximum Euclidean distance from the centroid in the current category. After completing this step, proceed to step 13.

[0104] Step 13: Determine whether all elements of the current category have completed the distance calculation with the centroid; if so, proceed to step 14; if not, continue to calculate the distance of the remaining elements and return to step 9.

[0105] Step 14: Set the current classification number i and centroid V i and the maximum distance d i,max Combine into one element and add it to the set T; after completing this step, go to step 15.

[0106] Step 15: Determine whether the elements of all categories have completed the distance calculation with the centroid; if so, proceed to step 17; if not, continue to process the remaining categories and proceed to step 16.

[0107] Step 16: After completing the calculation of the current category and obtaining its maximum distance, add 1 to the category number i, update the category number i to prepare for the calculation of the next category, and then return to step 6.

[0108] Step 17: Output the result set T of the previous calculation for subsequent calculation.

[0109] like Figure 4 As shown in the figure, the retrieval calculation uses the data generated in the first step to classify the user's questions and then decide 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, he or she can input the question by voice or text; the system will collect the user's question, and if the input is voice, it needs to be converted into text form; after completing this step, proceed to step 2.

[0111] Step 2: Vectorize the user question into A; convert the text question obtained in step 1 into a word vector through the vectorization model and record it as A, 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 question entered by the user and the 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 to the standard question can be used directly to answer the user. Usually, the value of thresh is set to above 0.9 and is read from the configuration file for setting. After completing this step, proceed to step 4.

[0113] Step 4: Initialize variables tmpi and tp; initialize the variable tmpi to -1 to store the category to which the user question belongs. The initial value -1 indicates that it belongs to other categories; initialize the variable tp to 0 to store the probability that the user question belongs to a certain category; after completing this step, proceed to step 5.

[0114] Step 5: Select an element from the set T; select an element from the previous calculation result set T for processing. If it is the first selection, select the first element; otherwise, select the next element of the current element; after completing this step, go to step 6.

[0115] Step 6: Calculate the centroid V of the user question vector A and the current element i The Euclidean distance d between 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 question belongs to the category represented by the current element, d i is the result of the previous step, and d i,max is the maximum Euclidean distance value corresponding to the current element; after completing this step, go to step 8.

[0117] Step 8: P(i)>tp; determine whether the probability P(i) that the user question belongs to the current category is greater than the currently stored maximum probability tp; if so, proceed to step 9; otherwise, proceed to step 10.

[0118] Step 9: Update tmpi and tp; assign the category number i of the current element to tmpi, and assign the currently calculated probability P(i) to tp; at this time, tp stores the maximum probability that the user question belongs to a certain category, and tmpi stores the category number corresponding to the maximum probability; after completing this step, go to step 10.

[0119] Step 10: Whether the set T has been traversed; determine whether all elements in the set T have completed the probability calculation for the user's question; if so, proceed to step 11; otherwise, return to step 5 and continue calculation and judgment.

[0120] Step 11: tmpi>0; determine whether tmpi is greater than 0; if tmpi is greater than 0, it means that the user question belongs to a certain category and needs to be further judged for similarity, and then proceed to step 12; otherwise, it means that the user question does not belong to any category and needs to be processed using a large language model, and then proceed to step 20.

[0121] Step 12: Obtain classification information through tmpi; use the category number stored in tmpi to obtain the classification information corresponding to the 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 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 obtained classification information for processing; if it is the first selection, select the first element; otherwise, select the next element of the current element; after completing this step, go 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, and go to step 17; otherwise, go 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 of the current element to tmpk so that tmpk stores the answer corresponding to the maximum similarity. After completing this step, go to step 18.

[0127] Step 18: Whether the classification set has been traversed; determine whether all elements in the classification set have been traversed and similarities have been calculated. If yes, proceed to step 19; otherwise, return to step 14 and continue to select the next element for calculation.

[0128] Step 19: Determine whether the maximum similarity tmps is greater than or equal to a preset threshold thresh. If so, it means that the user question is very similar to a standard question, and go to step 21; otherwise, it means that the user question has no obvious similarity with any question in the category, and go to step 20.

[0129] Step 20: Get 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: Get the answer through tmpk; output the answer stored in tmpk to the Digital Human system, and the Digital Human system converts it into voice for answering.

[0131] Step 22: Output the result generated by the large language model to the digital human system, which converts it into speech for answering.

[0132] In this embodiment, similarity is calculated to determine whether the question input by the user is similar to the word vector of the standard question; the traditional method needs to calculate the similarity of all 1,000 standard questions one by one, that is, 1,000 calculations. By classifying the questions first, this step has been completed in advance and does not occupy the response time, and the number of elements in each classification is controlled within 10% of the total. Only about 100 similarity calculations and distance calculations between the user question vector and the centroid of each category are required; when there are a large number of standard questions and answers, this method greatly reduces the amount of calculation and improves the response speed of the digital human.

[0133] In a second aspect, the present invention also provides an electronic device comprising 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 via the bus; the memory stores a program for a method for retrieving standard questions in a digital human system that can be executed by the processor, and the program for a method for retrieving standard questions in a digital human system is configured to implement a method for retrieving standard questions in a digital human system as described above.

[0134] In a third aspect, the present invention also provides a computer-readable storage medium, characterized in that a program for a method for retrieving standard questions in a digital human system is stored on the storage medium, and when the program for a method for retrieving standard questions in a digital human system is executed, a method for retrieving standard questions in a digital human system as described above is implemented.

[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 in the protection scope of the present invention.

Claims

1. A method for retrieving standard questions in a digital human system, characterized in that: It includes the following sub-steps: S1, cluster all standard problems in the system to obtain the centroid of each category and the maximum Euclidean distance within the category; 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 a similarity set; S3, comparing each similarity distance in the similarity set with the maximum distance in the corresponding category, and constructing an attribution probability model to calculate and determine the final attribution category of the user question; S4, calculates the similarity between the word vector of the user question and all standard questions in the final belonging category, selects the standard question with the highest similarity, and outputs the answer corresponding to the standard question as the result, giving the user answer.

2. The method for retrieving standard questions in a digital human system according to claim 1, characterized in that: In step S1, all standard questions in the system are clustered to obtain the centroid of each category, wherein all standard questions in the system are clustered using a clustering algorithm or manual participation; Clustering using a clustering algorithm includes converting all standard questions in the system into word vectors based on the BERT model, clustering the converted word vectors using the K-Means clustering algorithm, and obtaining the centroid of each category; Clustering using manual participation includes converting all standard questions in the system into word vectors based on the BERT model, calculating the average value of all vectors in each dimension in the corresponding category, and obtaining the centroid of each category.

3. The method for retrieving standard questions in a digital human system as claimed in claim 2, characterized in that: After clustering all standard questions in the system in step S1, determine whether the number of standard questions contained 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, further classify the category until the number of standard questions contained in the category is less than 10% of the number of all standard questions.

4. The method for retrieving standard questions in a digital human system as claimed in claim 3, characterized in that: The step S1 obtains the maximum Euclidean distance in each category, including 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.

5. The method for retrieving standard questions in a digital human system as claimed in claim 4, characterized in that: Step S2 includes inputting a user question, calculating the distance between the word vector of the user question and the centroid of each category, obtaining a similarity distance, and constructing a similarity set; wherein the user question is converted into a word vector through a BERT model, and 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 a similarity distance, construct a similarity set, and each similarity distance is added to the similarity set to obtain a similarity set.

6. The method for retrieving standard questions in a digital human system according to claim 5, characterized in that: The step S3 of comparing each similarity distance in the similarity set with the maximum distance in the corresponding category, building an attribution probability model, and calculating and determining the final attribution category of the user question includes the following steps: S31, comparing each similarity distance 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 the corresponding category, the user question is input into the large language model for answering, and the user question is taken as a standard question and the answer result of the large language model is taken as a standard answer, and stored in the digital human system in association; S32, if there is a category whose similarity distance is smaller than the maximum Euclidean distance of its corresponding category, the user question is classified into this category as the final category; S33, if there are multiple categories whose similarity distances are all smaller than the maximum Euclidean distance of their corresponding categories, establish an attribution model, and calculate and determine the final attribution category of the user question according to the attribution model.

7. The method for retrieving standard questions in a digital human system according to claim 6, characterized in that: In step S33, if there are multiple categories whose similarity distances are all smaller than the maximum Euclidean distance of their corresponding categories, an attribution model is established, and the final attribution category of the user question is calculated and determined according to the attribution model, wherein the attribution model is constructed according to the set principle, and the set principle is: The smaller the Euclidean distance from the user question to the centroid of a category, the greater the probability of belonging to that category; if there are the same distances in multiple categories, the smaller the Euclidean distance from the centroid of a category to its corresponding maximum Euclidean distance, the greater the probability of belonging to that category; The expression of the attribution model is: Where P(i) is the probability that the user's question belongs to the i-th category, d i,max is the maximum Euclidean distance of the i-th class, d i is the distance between the user question word vector and the centroid of the i-th category, that is, 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 category is 0.

8. The method for retrieving standard questions in a digital human system according to claim 7, characterized in that: Step S4 calculates the similarity between the word vector of the user question and all standard questions in the final belonging category, selects the standard question with the highest similarity, and outputs the answer corresponding to the standard question as a result to give the user answer, which includes the following sub-steps: 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: Where A is the word vector of the user input question, A i is the word vector in the current element, A·A i Represents vectors A and A i The dot product of ||A|| and ||A i || are vectors A and A respectively i The Euclidean norm of , which is the square root of the sum of the squares of its elements; A similarity threshold is preset, and the maximum similarity value is obtained according to the similarity values ​​corresponding to the standard questions, 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 with the standard question and the answer 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 the user answer is given.

9. An electronic device, characterized in that: It 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 program of a method for retrieving standard questions in a digital human system that can be executed by the processor, and the program of a method for retrieving standard questions in a digital human system is configured to implement a method for retrieving standard questions in a digital human system as claimed in any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that: The storage medium stores a program for a method for retrieving standard questions in a digital human system. When the program for a method for retrieving standard questions in a digital human system is executed, a method for retrieving standard questions in a digital human system as claimed in any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Method and system for determining standard problem based on similarity

    CN112131876A

  • A problem warehousing method and device

    CN109918498A

  • Bert-based intelligent question-answering system for dynamic threshold adjustment

    CN113961667A

  • Data processing method and device, electronic equipment and storage medium

    CN114817483A

  • Text classification method and system

    CN115345243A