Method for training knowledge base selection model, method and device for processing user problems

By training the knowledge base to select models, using users' historical query problems and reference replies, the loss value is optimized to improve model performance, and the problem of inaccurate selection of knowledge bases in the existing technology is solved, and more efficient and accurate knowledge base retrieval is achieved.

CN119377359BActive Publication Date: 2025-04-22ZHONGKE YUNGU TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411934613.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-04-22
Estimated Expiration
2044-12-26

AI Technical Summary

Technical Problem

The knowledge base required by users cannot be accurately selected in the prior art, resulting in inaccurate Q&A, high computing resources, and cumbersome search process.

Method used

By obtaining the user's historical query questions and reference reply, using the knowledge base selection model training, generating historical selection probability vectors and expected selection vectors, and calculating the loss value to optimize model performance.

Benefits of technology

It improves the performance and accuracy of the knowledge base selection model, reduces the consumption of computing resources, simplifies the retrieval process, and improves the accuracy of question and answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119377359B_ABST
    Figure CN119377359B_ABST
Patent Text Reader

Abstract

The present application relates to the field of artificial intelligence technology, in particular to a method for training a knowledge base selection model, a method and device for processing user questions. The method includes: obtaining multiple historical query questions of users, reference replies to multiple historical query questions, and expected selection vectors of knowledge bases used to characterize the sources of multiple historical query questions and their corresponding reference replies; determining the historical embedding vector of each historical query question, and the historical selection probability vector of each knowledge base under each historical query question; determining the first loss value of each historical query question based on the historical selection probability vector and the expected selection vector of each historical query question; determining the total loss value of the knowledge base selection model based on all the first loss values; determining the completion of the knowledge base selection model training when the total loss value is less than a preset value, improving the model performance of the knowledge base selection model and the selection accuracy and efficiency of the knowledge base, and providing more accurate replies for subsequent user queries.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and specifically to a method for training a knowledge base selection model, a method for processing user questions, a device and a storage medium. Background Art

[0002] Existing knowledge base retrieval generally uses a large model to retrieve the corresponding knowledge base according to the knowledge base description or directly traverses all knowledge bases to obtain the corresponding knowledge base. On the one hand, the existing knowledge base retrieval method relies too much on the accuracy of the large model's understanding of the knowledge base description, and the existing knowledge base description is often not comprehensive and accurate, but rather one-sided, redundant, and ambiguous, which leads to errors and inaccuracies in the knowledge base retrieved by the large model. On the other hand, the method of directly searching all knowledge bases will lead to a large consumption of computing resources, and often cannot break the information barriers between different knowledge bases, making the retrieval process very cumbersome and the retrieval results inaccurate. The above-mentioned knowledge base retrieval methods are unable to retrieve the corresponding knowledge base in a timely and accurate manner, resulting in the inability to provide good responses to subsequent user inquiries and effectively solve user problems. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a method for training a knowledge base selection model, a method for processing user questions, an apparatus and a storage medium, so as to solve the problem in the prior art that the knowledge base required by the user cannot be accurately selected, resulting in inaccurate questions and answers.

[0004] In order to achieve the above-mentioned object, the first aspect of the present application provides a method for training a knowledge base selection model, the method comprising:

[0005] Acquire multiple historical query questions of the user, reference answers to the multiple historical query questions, and an expected selection vector of a knowledge base used to characterize the multiple historical query questions and the sources of their corresponding reference answers;

[0006] Preprocess each of the multiple historical query questions to obtain a historical embedding vector for each historical query question;

[0007] Input the historical embedding vector of each historical query question into the knowledge base selection model in turn to obtain the historical selection probability vector of each knowledge base under each historical query question;

[0008] Determine a first loss value for each historical query question according to a historical selection probability vector and an expected selection vector for each historical query question;

[0009] Determine the total loss value of the knowledge base selection model based on all the first loss values;

[0010] When the total loss value is less than the preset value, it is determined that the knowledge base selection model training is completed.

[0011] In an embodiment of the present application, determining the total loss value of the knowledge base selection model based on all first loss values ​​includes: determining a reference context for each historical query question; inputting each historical query question and the reference context of each historical query question into a large language model to output a predicted response for each historical query question; determining a second loss value for each historical query question based on the predicted response for each historical query question and the reference response for each historical query question; and determining the total loss value of the knowledge base selection model based on all the first loss values ​​and the second loss values.

[0012] In an embodiment of the present application, determining the reference context of each historical query question includes: for each historical query question, processing the historical selection probability vector of the historical query question based on a preset selection logic to obtain a historical selection vector of the knowledge base used to characterize whether each knowledge base is the source of the reference context corresponding to the historical query question; determining the source knowledge base of the reference context of the historical query question based on the historical selection vector corresponding to the historical query question; and extracting the reference context corresponding to the historical query question from the source knowledge base.

[0013] In an embodiment of the present application, determining the total loss value of the knowledge base selection model according to all the first loss values ​​and the second loss values ​​includes determining the total loss value according to formula (1):

[0014] (1)

[0015] in, is the total loss value, is the reference answer to the i-th historical query question, is the predicted answer to the i-th historical query question, is the history selection probability vector of the i-th history query question, is the expected selection vector of the i-th historical query question, Si is the historical selection vector of the i-th historical query question, and m is the m-th historical query question.

[0016] In an embodiment of the present application, the knowledge base is trained through the following steps: determining multiple participants corresponding to the target vertical domain, and the multiple participants have local text data of the target vertical domain; distributing the initial large model of the target vertical domain to the multiple participants, so that the multiple participants iteratively train the initial large model based on the local text data of the target vertical domain they each own; obtaining the temporary large models returned by the multiple participants obtained by the iterative training, and aggregating the temporary large models that have been verified to be compliant to obtain the current latest aggregated large model; when the termination conditions of the iterative training are met, the current latest aggregated large model is determined as the knowledge base corresponding to the target vertical domain.

[0017] In an embodiment of the present application, preprocessing each of the multiple historical query questions includes: inputting each of the multiple historical query questions into an embedding model to output a historical embedding vector corresponding to each historical query question through the embedding model.

[0018] In an embodiment of the present application, the method also includes: when the total loss value is greater than or equal to a preset value, determining that the number of training times for the knowledge base selection model is increased, adjusting the model parameters of the knowledge base selection model, and returning to the step of obtaining the user's multiple historical query questions, reference responses to multiple historical query questions, and expected selection vectors of the knowledge base used to characterize the multiple historical query questions and their corresponding reference response sources until the training conditions are met.

[0019] A second aspect of the present application provides a method for handling user problems, the method comprising:

[0020] Get the user's current query question;

[0021] Input the current query question into the embedding model to output the embedding vector of the current query question through the embedding model;

[0022] Inputting the embedding vector into a knowledge base selection model to obtain a selection probability vector output by the knowledge base selection model, wherein the knowledge base selection model is trained using the above-mentioned method for training the knowledge base selection model;

[0023] Determine, according to the selection probability vector, a current selection vector representing whether each knowledge base is the source of the current reference context corresponding to the current query question;

[0024] Determine a target knowledge base that is a source of a current reference context of a current query question based on all currently selected vectors;

[0025] Extracting the current reference context for the current query question from the target knowledge base;

[0026] Determine a response to the current query question based on the current query question and the current reference context.

[0027] In an embodiment of the present application, extracting the current reference context for the current query question from the target knowledge base includes: searching the target knowledge base based on the embedded vector to determine a target vector in the target knowledge base whose similarity with the embedded vector is within a preset range; and using the context text corresponding to the target vector as the current reference context for the current query question.

[0028] In an embodiment of the present application, extracting a current reference context for a current query question from a target knowledge base includes: inputting the current query question into the target knowledge base to generate the current reference context through a generation model in the target knowledge base.

[0029] In an embodiment of the present application, determining a reply to a current query question based on a current query question and a current reference context includes: when there are multiple target knowledge bases, determining the semantic similarity between a current reference context extracted from each target knowledge base and the query question; arranging all current reference contexts in descending order based on the semantic similarity; and inputting all arranged current reference contexts and the current query question into a large language model to output a reply through the large language model.

[0030] In an embodiment of the present application, determining a reply to a current query question based on a current query question and a current reference context includes: determining a current reference context having a semantic similarity greater than a preset value as a target reference context; and inputting the target reference context and the current query question into a large language model to output a reply through the large language model.

[0031] The third aspect of the present application provides a device for training a knowledge base selection model, comprising:

[0032] a memory configured to store instructions;

[0033] The processor is configured to call instructions from the memory and implement the above-mentioned method for training the knowledge base selection model or the above-mentioned method for processing user problems when executing the instructions.

[0034] A fourth aspect of the present application provides a machine-readable storage medium having instructions stored thereon, the instructions being used to enable a machine to execute the above-mentioned method for training a knowledge base selection model or to execute the above-mentioned method for processing user questions.

[0035] Through the above technical scheme, the historical embedding vector of each historical query question can be determined, and the historical embedding vector of each historical query question can be input into the knowledge base selection model in turn to obtain the historical selection probability vector of each knowledge base under each historical query question, and then the first loss value of each historical query question is determined according to the historical selection probability vector and the expected selection vector of each historical query question, and the total loss value of the knowledge base selection model is determined according to all the first loss values; finally, when the total loss value is less than the preset value, it is determined that the training of the knowledge base selection model is completed, so as to improve the model performance of the knowledge base selection model, improve the selection accuracy and efficiency of the knowledge base, and provide more accurate responses for subsequent user queries.

[0036] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present application, but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:

[0038] Figure 1 A schematic diagram of a process for training a knowledge base selection model according to an embodiment of the present application is shown;

[0039] Figure 2 Another flow chart of a method for training a knowledge base selection model according to an embodiment of the present application is schematically shown;

[0040] Figure 3 A schematic diagram of a process for handling a user problem according to an embodiment of the present application is shown;

[0041] Figure 4 The internal structure diagram of a computer device according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0042] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application, and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0043] It should be noted that if the embodiments of the present application involve directional indications (such as up, down, left, right, front, back...), such directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.

[0044] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0045] Figure 1 A schematic diagram of a process flow of a method for training a knowledge base selection model according to an embodiment of the present application is shown. Figure 1 As shown, an embodiment of the present application provides a method for training a knowledge base selection model, which may include the following steps.

[0046] Step 101: Acquire multiple historical query questions of the user, multiple reference answers to the historical query questions, and an expected selection vector of a knowledge base used to characterize the multiple historical query questions and the sources of their corresponding reference answers.

[0047] Step 102: pre-process each of the multiple historical query questions to obtain a historical embedding vector for each historical query question.

[0048] The processor can obtain multiple historical query questions of the user, multiple reference answers to the historical query questions, and an expected selection vector of a knowledge base used to characterize the multiple historical query questions and the sources of the corresponding reference answers. After obtaining the multiple historical query questions, the processor can pre-process each of the multiple historical query questions to obtain a historical embedding vector for each historical query question.

[0049] In an embodiment of the present application, preprocessing each of the multiple historical query questions includes: inputting each of the multiple historical query questions into an embedding model to output a historical embedding vector corresponding to each historical query question through the embedding model.

[0050] The processor may pre-process each of the multiple historical query questions to obtain a historical embedding vector for each historical query question. Specifically, the processor may input each of the multiple historical query questions into the embedding model to output a historical embedding vector corresponding to each historical query question through the embedding model.

[0051] Step 103: Input the history embedding vector of each history query question into the knowledge base selection model in sequence to obtain the history selection probability vector of each knowledge base under each history query question.

[0052] Step 104: Determine a first loss value for each historical query question according to the historical selection probability vector and the expected selection vector of each historical query question.

[0053] Step 105: Determine the total loss value of the knowledge base selection model based on all the first loss values.

[0054] Step 106: When the total loss value is less than a preset value, it is determined that the knowledge base selection model training is completed.

[0055] After obtaining the historical embedding vector of each historical query question, the processor can input the historical embedding vector of each historical query question into the knowledge base selection model in sequence to obtain the historical selection probability vector of each knowledge base under each historical query question. After obtaining the historical selection probability vector of each knowledge base under each historical query question, the processor can determine the first loss value of each historical query question based on the historical selection probability vector and the expected selection vector of each historical query question. After obtaining the first loss value of each historical query question, the processor can determine the total loss value of the knowledge base selection model based on the first loss values ​​of all historical query questions. After obtaining the total loss value of the knowledge base selection model, the processor can determine whether the total loss value of the knowledge base selection model is less than a preset value. The preset value can be set according to the actual situation. When the total loss value of the knowledge base selection model is less than the preset value, the processor can determine that the training of the knowledge base selection model is completed.

[0056] In an embodiment of the present application, determining the total loss value of the knowledge base selection model based on all first loss values ​​includes: determining a reference context for each historical query question; inputting each historical query question and the reference context of each historical query question into a large language model to output a predicted response for each historical query question; determining a second loss value for each historical query question based on the predicted response for each historical query question and the reference response for each historical query question; and determining the total loss value of the knowledge base selection model based on all the first loss values ​​and the second loss values.

[0057] The processor may determine the total loss value of the knowledge base selection model based on all the first loss values. Specifically, the processor may determine the reference context of each historical query question. After obtaining the reference context of each historical query question, the processor may input each historical query question and the reference context of each historical query question into the large language model to output a predicted response for each historical query question through the large language model. After obtaining the predicted response for each historical query question, the processor may determine the second loss value for each historical query question based on the predicted response for each historical query question and the reference response for each historical query question. After determining the second loss value for each historical query question, the processor may determine the total loss value of the knowledge base selection model based on all the first loss values ​​and the second loss values. In an embodiment of the present application, determining the total loss value of the knowledge base selection model based on all the first loss values ​​and the second loss values ​​includes determining the total loss value according to formula (1):

[0058] (1)

[0059] in, is the total loss value, is the reference answer to the i-th historical query question, is the predicted answer to the i-th historical query question, is the history selection probability vector of the i-th history query question, is the expected selection vector of the i-th historical query question, Si is the historical selection vector of the i-th historical query question, and m is the m-th historical query question.

[0060] In an embodiment of the present application, determining the reference context of each historical query question includes: for each historical query question, processing the historical selection probability vector of the historical query question based on a preset selection logic to obtain a historical selection vector of the knowledge base used to characterize whether each knowledge base is the source of the reference context corresponding to the historical query question; determining the source knowledge base of the reference context of the historical query question based on the historical selection vector corresponding to the historical query question; and extracting the reference context corresponding to the historical query question from the source knowledge base.

[0061] The processor can determine the reference context of each historical query question. Specifically, for each historical query question, the processor can process the historical selection probability vector of the historical query question based on the preset selection logic to obtain a historical selection vector of the knowledge base used to characterize whether each knowledge base is the source of the reference context corresponding to the historical query question. After obtaining the historical selection vector corresponding to the historical query question, the processor can determine the source knowledge base of the reference context of the historical query question determined by the historical selection vector corresponding to the historical query question. And extract the reference context corresponding to the historical query question from the source knowledge base. In a specific embodiment, the preset selection logic can be a threshold-based knowledge base selection logic, that is, a threshold is set. When the historical selection probability of a certain knowledge base under the historical query question is greater than the threshold, it is determined that the knowledge base is selected, and the historical selection vector corresponding to the knowledge base is set to the first preset vector, such as 1; when the historical selection probability of a certain knowledge base under the historical query question is less than or equal to the threshold, it is determined that the knowledge base is not selected, and the historical selection vector corresponding to the knowledge base is set to the second preset vector, such as 0. In a specific embodiment, the preset selection logic can also be a Topk-based knowledge base selection logic, that is, the knowledge base corresponding to the largest top K (positive integer) or Kth historical selection probability under the historical query question is selected as the knowledge base, and the historical selection vector of the selected knowledge base is set to 1, and the historical selection vectors of other unselected knowledge bases are set to 0.

[0062] In an embodiment of the present application, the method also includes: when the total loss value is greater than or equal to a preset value, determining that the number of training times for the knowledge base selection model is increased, adjusting the model parameters of the knowledge base selection model, and returning to the step of obtaining the user's multiple historical query questions, reference responses to multiple historical query questions, and expected selection vectors of the knowledge base used to characterize the multiple historical query questions and their corresponding reference response sources until the training conditions are met.

[0063] When the total loss value is greater than or equal to a preset value, the processor can determine that the number of training times for the knowledge base selection model is increased, adjust the model parameters of the knowledge base selection model, and return to the step of obtaining multiple historical query questions of the user, multiple reference answers to historical query questions, and the expected selection vector of the knowledge base used to characterize the multiple historical query questions and their corresponding reference answer sources until the training condition is met. The training condition may refer to the number of training times reaching a preset number or the model performance reaching the best performance, and the preset number may be set according to actual conditions.

[0064] In an embodiment of the present application, the knowledge base is trained through the following steps: determining multiple participants corresponding to the target vertical domain, and the multiple participants have local text data of the target vertical domain; distributing the initial large model of the target vertical domain to the multiple participants, so that the multiple participants iteratively train the initial large model based on the local text data of the target vertical domain they each own; obtaining the temporary large models returned by the multiple participants obtained by the iterative training, and aggregating the temporary large models that have been verified to be compliant to obtain the current latest aggregated large model; when the termination conditions of the iterative training are met, the current latest aggregated large model is determined as the knowledge base corresponding to the target vertical domain.

[0065] The knowledge base in the embodiment of the present application can be obtained by training through the following steps. The processor can determine multiple participants corresponding to the target vertical domain, and the multiple participants have local text data of the target vertical domain. The processor can distribute the initial large model of the target vertical domain to multiple participants, so that the multiple participants can iteratively train the initial large model based on the local text data of the target vertical domain they each own. The processor can obtain the temporary large models returned by the multiple participants and obtain the latest aggregated large model by aggregating the temporary large models that have been verified to be compliant. After obtaining the latest aggregated large model, the processor can determine whether the termination condition of the iterative training is met. The termination condition may be that the number of iterations reaches a preset number or the model performance reaches the optimal level. The preset number may be determined based on the actual situation of the model. When the termination condition of the iterative training is met, the processor may determine the latest aggregated large model as the knowledge base corresponding to the target vertical domain.

[0066] In an optional embodiment, the knowledge base may also be a non-parameterized raw reference context data set stored in a specific format.

[0067] In one embodiment, the knowledge base selection model can be a gated network, which is composed of one or more ffn (linear transformation layers), plus a softmax layer (classification layer) to map features to the probability value of each knowledge base being selected. Therefore, the value of each vector is between 0 and 1, and the sum of the vector components is 1. The processor can initialize a set of network parameters for the gated network. And construct m triplets (Q, K, A) as training samples, where Q represents the user query, K represents the expected selection vector of the n knowledge bases from which the user query and its corresponding reference reply are sourced, and K is an n-dimensional vector. A component value of 1 indicates that the corresponding knowledge base is the source of the reference reply, and a component value of 0 indicates that the corresponding knowledge base is not the source of the reference reply, and A represents the reference reply. For example Figure 2As shown, the processor can use the embedding model to process the user query Q in each triple to obtain the embedding vector E. Then the embedding vector E is input into the gating network to obtain the selection probability vector G of the domain knowledge base 1, domain knowledge base 2, domain knowledge base 3...domain knowledge base n under the user query Q. The selection probability vector G corresponding to the user query Q is processed by the knowledge base selection logic to obtain the historical selection vector S used to characterize whether the domain knowledge base 1, domain knowledge base 2, domain knowledge base 3...domain knowledge base n is the knowledge base of the reference context source corresponding to the user query Q. The processor can determine the first loss value of each training sample according to the historical selection vector S, the selection probability vector G and K corresponding to each training sample. The processor can also determine the source knowledge base of the user query Q in the mixture of experts domain knowledge base 1, domain knowledge base 2, domain knowledge base 3...domain knowledge base n based on the historical selection vector S, and extract the reference context from the source knowledge base. The processor can generate prompt words according to the reference context and the user query, and input the prompt words into the large model to obtain a reply to the user query. The processor can determine the final loss of the gated network based on the response to the user query and the reference response A (ground truth). After obtaining the loss of the gated network, the processor can iteratively train the gated network based on the loss until the iteration condition is met to obtain a trained gated network, improve the model performance of the gated network, and improve the selection accuracy and efficiency of the knowledge base.

[0068] Figure 3 The following schematically shows a flow chart of a method for training a knowledge base selection model according to an embodiment of the present application. Figure 3 As shown, an embodiment of the present application provides a method for training a knowledge base selection model, which may include the following steps.

[0069] Step 301: Obtain the user's current query question.

[0070] Step 302: Input the current query question into the embedding model to output the embedding vector of the current query question through the embedding model.

[0071] Step 303: Input the embedding vector into the knowledge base selection model to obtain a selection probability vector output by the knowledge base selection model, wherein the knowledge base selection model is trained using the above-mentioned method for training the knowledge base selection model.

[0072] Step 304: Determine, based on the selection probability vector, a current selection vector that characterizes whether each knowledge base is the source of the current reference context corresponding to the current query question.

[0073] Step 305: Determine the target knowledge base that is the source of the current reference context of the current query question based on all current selection vectors.

[0074] Step 306: extract the current reference context for the current query question from the target knowledge base.

[0075] The processor can obtain the user's current query question. After obtaining the user's current query question, the processor can input the current query question into the embedding model to output the embedding vector of the current query question through the embedding model. After obtaining the embedding vector of the current query question, the processor can input the embedding vector into the knowledge base selection model to obtain the selection probability vector output by the knowledge base selection model. Among them, the knowledge base selection model is trained using the above-mentioned method for training the knowledge base selection model. After obtaining the selection probability vector output by the knowledge base selection model, the processor can determine the current selection vector that characterizes whether each knowledge base is the source of the current reference context corresponding to the current query question based on the selection probability vector, and determine the target knowledge base that is the source of the current reference context of the current query question based on all the current selection vectors. After obtaining the target knowledge base, the processor can extract the current reference context for the current query question from the target knowledge base.

[0076] In an embodiment of the present application, extracting the current reference context for the current query question from the target knowledge base includes: searching the target knowledge base based on the embedded vector to determine a target vector in the target knowledge base whose similarity with the embedded vector is within a preset range; and using the context text corresponding to the target vector as the current reference context for the current query question.

[0077] The processor can extract the current reference context for the current query question from the target knowledge base. Specifically, the processor can search the target knowledge base based on the embedded vector to determine the target vector in the target knowledge base whose similarity with the embedded vector is within a preset range. The preset range can be determined based on user needs. After obtaining the target vector, the processor can use the context text corresponding to the target vector as the current reference context for the current query question.

[0078] In an embodiment of the present application, extracting a current reference context for a current query question from a target knowledge base includes: inputting the current query question into the target knowledge base to generate the current reference context through a generation model in the target knowledge base.

[0079] The processor may extract the current reference context for the current query question from the target knowledge base. Specifically, the processor may input the current query question into the target knowledge base to generate the current reference context through the generation model in the target knowledge base.

[0080] Step 307: Determine a response to the current query question based on the current query question and the current reference context.

[0081] After obtaining the current reference context, the processor may determine a response to the current query question based on the current query question and the current reference context.

[0082] In an embodiment of the present application, determining a reply to a current query question based on a current query question and a current reference context includes: when there are multiple target knowledge bases, determining the semantic similarity between a current reference context extracted from each target knowledge base and the query question; arranging all current reference contexts in descending order based on the semantic similarity; and inputting all arranged current reference contexts and the current query question into a large language model to output a reply through the large language model.

[0083] After obtaining the current reference context, the processor can determine the reply to the current query question based on the current query question and the current reference context. The processor can determine whether there are multiple target knowledge bases. In the case where there are multiple target knowledge bases, the processor can determine the semantic similarity between a current reference context extracted from each target knowledge base and the query question. After determining the semantic similarity between a current reference context extracted from each target knowledge base and the query question, the processor can arrange all current reference contexts in descending order based on the semantic similarity, and input all arranged current reference contexts and the current query question into the large language model to output a reply through the large language model to improve the accuracy of the reply.

[0084] In an embodiment of the present application, determining a reply to a current query question based on a current query question and a current reference context includes: determining a current reference context having a semantic similarity greater than a preset value as a target reference context; and inputting the target reference context and the current query question into a large language model to output a reply through the large language model.

[0085] The processor may determine the current reference context whose semantic similarity is greater than a preset value as the target reference context. The preset value may be determined based on user needs. After obtaining the target reference context, the processor may input the target reference context and the current query question into the large language model to output a reply through the large language model to improve the accuracy of the reply.

[0086] Through the above technical solution, it is possible to determine the target knowledge base related to the user's query question, determine the reference context in the target knowledge base, improve the pertinence and accuracy of question retrieval, avoid searching in each knowledge base, save computing resources, and improve the accuracy of question and answer.

[0087] Figure 1 and2 A method for selecting a model for training a knowledge base in one embodiment, Figure 3 FIG. 1 is a flow chart of a method for handling user problems in one embodiment. It should be understood that although Figure 1 and 2 A method for selecting a model for training a knowledge base in one embodiment, Figure 3 The steps in the flowchart of the method for handling user problems in one embodiment are shown in sequence according to the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 and 2 A method for selecting a model for training a knowledge base in one embodiment, Figure 3 In one embodiment, at least part of the steps in the method for handling user problems may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0088] The present application also provides a device for training a knowledge base selection model, including:

[0089] a memory configured to store instructions;

[0090] The processor is configured to call instructions from the memory and implement the above-mentioned method for training the knowledge base selection model or the above-mentioned method for processing user problems when executing the instructions.

[0091] An embodiment of the present application also provides a machine-readable storage medium having instructions stored thereon, the instructions being used to enable a machine to execute the above-mentioned method for training a knowledge base selection model or to execute the above-mentioned method for processing user questions.

[0092] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4As shown. The computer device includes a processor A01, a network interface A02, a memory (not shown in the figure) and a database (not shown in the figure) connected through a system bus. Among them, the processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes an internal memory A03 and a non-volatile storage medium A04. The non-volatile storage medium A04 stores an operating system B01, a computer program B02 and a database (not shown in the figure). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non-volatile storage medium A04. The database of the computer device is used to store historical query questions, reference replies, expected selection vectors, historical embedding vectors, historical selection probability vectors, first loss values, total loss values, current query questions, embedding vectors, selection probability vectors, current selection vectors, current reference contexts and replies. The network interface A02 of the computer device is used to communicate with an external terminal through a network connection. When the computer program B02 is executed by the processor A01, a method for training a knowledge base selection model or a method for processing user problems is implemented.

[0093] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0094] An embodiment of the present application provides a device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the following steps are implemented: obtaining multiple historical query questions of a user, reference answers to the multiple historical query questions, and expected selection vectors of a knowledge base used to characterize the sources of the multiple historical query questions and their corresponding reference answers; preprocessing each of the multiple historical query questions to obtain a historical embedding vector for each historical query question; inputting the historical embedding vector of each historical query question into a knowledge base selection model in sequence to obtain a historical selection probability vector of each knowledge base under each historical query question; determining a first loss value for each historical query question based on the historical selection probability vector and the expected selection vector of each historical query question; determining a total loss value of the knowledge base selection model based on all the first loss values; and determining that the training of the knowledge base selection model is completed when the total loss value is less than a preset value.

[0095] In one embodiment, determining the total loss value of the knowledge base selection model based on all first loss values ​​includes: determining a reference context for each historical query question; inputting each historical query question and the reference context of each historical query question into a large language model to output a predicted response for each historical query question; determining a second loss value for each historical query question based on the predicted response for each historical query question and the reference response for each historical query question; and determining the total loss value of the knowledge base selection model based on all first loss values ​​and second loss values.

[0096] In one embodiment, determining the reference context of each historical query question includes: for each historical query question, processing the historical selection probability vector of the historical query question based on a preset selection logic to obtain a historical selection vector of the knowledge base used to characterize whether each knowledge base is the source of the reference context corresponding to the historical query question; determining the source knowledge base of the reference context of the historical query question based on the historical selection vector corresponding to the historical query question; and extracting the reference context corresponding to the historical query question from the source knowledge base.

[0097] In one embodiment, determining the total loss value of the knowledge base selection model according to all the first loss values ​​and the second loss values ​​includes determining the total loss value according to formula (1):

[0098] (1)

[0099] in, is the total loss value, is the reference answer to the i-th historical query question, is the predicted answer to the i-th historical query question, is the history selection probability vector of the i-th history query question, is the expected selection vector of the i-th historical query question, Si is the historical selection vector of the i-th historical query question, and m is the m-th historical query question.

[0100] In one embodiment, the knowledge base is trained through the following steps: determining multiple participants corresponding to the target vertical domain, and the multiple participants own local text data of the target vertical domain; distributing the initial large model of the target vertical domain to the multiple participants, so that the multiple participants iteratively train the initial large model based on the local text data of the target vertical domain owned by each of them; obtaining the temporary large models returned by the multiple participants after iterative training, and aggregating the temporary large models verified to be compliant to obtain the current latest aggregated large model; when the termination conditions of the iterative training are met, the current latest aggregated large model is determined as the knowledge base corresponding to the target vertical domain.

[0101] In one embodiment, preprocessing each of the multiple historical query questions includes: inputting each of the multiple historical query questions into an embedding model to output a historical embedding vector corresponding to each historical query question through the embedding model.

[0102] In one embodiment, the method also includes: when the total loss value is greater than or equal to a preset value, determining that the number of training times for the knowledge base selection model is increased, adjusting the model parameters of the knowledge base selection model, and returning to the step of obtaining the user's multiple historical query questions, multiple reference responses to historical query questions, and an expected selection vector of the knowledge base used to characterize the multiple historical query questions and their corresponding reference response sources until the training conditions are met.

[0103] An embodiment of the present application provides a device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the following steps are implemented: obtaining a user's current query question; inputting the current query question into an embedding model to output an embedding vector of the current query question through the embedding model; inputting the embedding vector into a knowledge base selection model to obtain a selection probability vector output by the knowledge base selection model, wherein the knowledge base selection model is trained using the above-mentioned method for training the knowledge base selection model; determining a current selection vector representing whether each knowledge base is the source of a current reference context corresponding to the current query question based on the selection probability vector; determining a target knowledge base that is the source of the current reference context of the current query question based on all the current selection vectors; extracting the current reference context for the current query question from the target knowledge base; and determining a reply to the current query question based on the current query question and the current reference context.

[0104] In one embodiment, extracting the current reference context for the current query question from the target knowledge base includes: searching the target knowledge base based on the embedded vector to determine a target vector in the target knowledge base whose similarity with the embedded vector is within a preset range; and using the context text corresponding to the target vector as the current reference context for the current query question.

[0105] In one embodiment, extracting the current reference context for the current query question from the target knowledge base includes: inputting the current query question into the target knowledge base to generate the current reference context through a generation model in the target knowledge base.

[0106] In one embodiment, determining a reply to a current query question based on a current query question and a current reference context includes: when there are multiple target knowledge bases, determining the semantic similarity between a current reference context extracted from each target knowledge base and the query question; arranging all current reference contexts in descending order based on the semantic similarity; and inputting all arranged current reference contexts and the current query question into a large language model to output a reply through the large language model.

[0107] In one embodiment, determining a response to a current query question based on a current query question and a current reference context includes: determining a current reference context having a semantic similarity greater than a preset value as a target reference context; and inputting the target reference context and the current query question into a large language model to output a response through the large language model.

[0108] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program for initializing the method steps for training a knowledge base selection model.

[0109] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing the program of the method steps of initiating processing of a user question.

[0110] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0111] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0112] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0113] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0114] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0115] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0116] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0117] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0118] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A method for training a knowledge base selection model, characterized in that: The method comprises: Acquire multiple historical query questions of the user, reference answers to the multiple historical query questions, and expected selection vectors of a knowledge base used to characterize sources of the multiple historical query questions and their corresponding reference answers; Preprocessing each of the multiple historical query questions to obtain a historical embedding vector for each historical query question; Input the historical embedding vector of each historical query question into the knowledge base selection model in turn to obtain the historical selection probability vector of each knowledge base under each historical query question; Determine a first loss value for each historical query question according to a historical selection probability vector and an expected selection vector for each historical query question; Determine the total loss value of the knowledge base selection model according to all the first loss values; When the total loss value is less than a preset value, determining that the knowledge base selection model training is completed; Wherein, determining the total loss value of the knowledge base selection model according to all the first loss values ​​includes: Identify the reference context for each historical inquiry question; Input each historical query question and a reference context of each historical query question into a large language model to output a predicted response for each historical query question; Determine a second loss value for each historical query question according to the predicted answer to each historical query question and the reference answer to each historical query question; Determine a total loss value of the knowledge base selection model according to all the first loss values ​​and the second loss values; Wherein, determining the reference context of each historical query question includes: For each historical query question, the historical selection probability vector of the historical query question is processed based on a preset selection logic to obtain a historical selection vector for characterizing whether each knowledge base is a knowledge base of a reference context source corresponding to the historical query question; Determine a source knowledge base of a reference context of the historical query question according to the historical selection vector corresponding to the historical query question; A reference context corresponding to the historical query question is extracted from the source knowledge base.

2. The method for training a knowledge base selection model according to claim 1, characterized in that: Determining the total loss value of the knowledge base selection model according to all the first loss values ​​and the second loss values ​​includes determining the total loss value according to formula (1): (1) in, is the total loss value, is the reference answer to the i-th historical query question, is the predicted answer to the i-th historical query question, is the history selection probability vector of the i-th history query question, is the expected selection vector of the i-th historical query question, Si is the historical selection vector of the i-th historical query question, and m is the m-th historical query question.

3. The method for training a knowledge base selection model according to claim 1, characterized in that: The knowledge base is trained by the following steps: Determine multiple participants corresponding to the target vertical domain, wherein the multiple participants have local text data of the target vertical domain; Distributing the initial large model of the target vertical domain to the multiple participants, so that the multiple participants iteratively train the initial large model based on the local text data of the target vertical domain owned by each of them; Obtaining the temporary large models returned by the multiple participants through iterative training, and aggregating the temporary large models that have been verified to be compliant to obtain the latest aggregated large model; When the termination condition of the iterative training is met, the current latest aggregated large model is determined as the knowledge base corresponding to the target vertical domain.

4. The method for training a knowledge base selection model according to claim 1, characterized in that: Preprocessing each of the plurality of historical query questions includes: Each of the plurality of historical query questions is input into an embedding model, so that a historical embedding vector corresponding to each historical query question is output through the embedding model.

5. The method for training a knowledge base selection model according to claim 1, characterized in that: The method further comprises: When the total loss value is greater than or equal to the preset value, the number of training times for the knowledge base selection model is determined to increase, the model parameters of the knowledge base selection model are adjusted, and the process of obtaining the user's multiple historical query questions, the reference answers to the multiple historical query questions, and the expected selection vector of the knowledge base used to characterize the multiple historical query questions and their corresponding reference answer sources is returned to until the training conditions are met.

6. A method for handling user problems, characterized in that: The method comprises: Get the user's current query question; Inputting the current query question into an embedding model to output an embedding vector of the current query question through the embedding model; Inputting the embedding vector into a knowledge base selection model to obtain a selection probability vector output by the knowledge base selection model, wherein the knowledge base selection model is trained using the method for training a knowledge base selection model according to any one of claims 1 to 5; Determine, according to the selection probability vector, a current selection vector representing whether each knowledge base is the source of the current reference context corresponding to the current query question; Determine a target knowledge base that is a source of a current reference context of the current query question based on all current selection vectors; Extracting a current reference context for the current query question from the target knowledge base; A reply to the current query question is determined according to the current query question and the current reference context.

7. The method for handling user problems according to claim 6, characterized in that: Extracting the current reference context for the current query question from the target knowledge base includes: Searching the target knowledge base based on the embedding vector to determine a target vector in the target knowledge base whose similarity to the embedding vector is within a preset range; The context text corresponding to the target vector is used as the current reference context of the current query question.

8. The method for handling user problems according to claim 6, characterized in that: Extracting the current reference context for the current query question from the target knowledge base includes: The current query question is input into the target knowledge base to generate the current reference context through a generation model in the target knowledge base.

9. The method for handling user problems according to claim 6, characterized in that: Determining a response to the current query question according to the current query question and the current reference context includes: In the case where there are multiple target knowledge bases, determining the semantic similarity between a current reference context extracted from each target knowledge base and the query question; Arrange all current reference contexts in descending order based on the semantic similarity; All the arranged current reference contexts and the current query question are input into a large language model to output the reply through the large language model.

10. The method for handling user problems according to claim 9, characterized in that: Determining a response to the current query question according to the current query question and the current reference context includes: Determine the current reference context whose semantic similarity is greater than a preset value as the target reference context; The target reference context and the current query question are input into the large language model to output the response through the large language model.

11. A device for training a knowledge base selection model, characterized in that: include: a memory configured to store instructions; A processor is configured to call the instructions from the memory and, when executing the instructions, can implement the method for training a knowledge base selection model according to any one of claims 1 to 5 or the method for processing user problems according to any one of claims 6 to 10.

12. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores instructions for causing a machine to execute a method for training a knowledge base selection model according to any one of claims 1 to 5 or a method for processing user questions according to any one of claims 6 to 10.

Citation Information

Patent Citations

  • Emotion dialogue generation method based on multi-resolution emotion and multi-type knowledge

    CN114372135A

  • Physical layer semantics-based action perception model construction system and method, and server

    CN117273122A

  • Method and device for training answer scoring model and storage medium

    CN118606660A