Response processing method and device, equipment and storage medium
By determining the sample contribution of the sample example to and selecting the target example, the shortcomings of the selection of task examples in the prior art to improve the accuracy of the language model response results are solved, and the accuracy of the response results are improved.
Patent Information
- Application Number
- CN202411517885.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-03-28
AI Technical Summary
In the prior art, it is difficult to ensure that the accuracy of the response results to the language model is improved when selecting task examples, resulting in poor model performance.
By obtaining the sample data set, a sample sample pair is composed, and a question-and-answer model is used to determine the sample contribution degree of the sample pair. The selection model selects the target example from multiple candidate examples based on these contribution degrees to generate the corresponding response result.
The accuracy of the response results of the question and answer model for input information is improved, ensuring that the selected target example can significantly improve the accuracy of the response results.
Smart Images

Figure CN119720997A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a response processing method, device, equipment and storage medium. Background Art
[0002] The model learning method of in-context learning needs to provide high-quality task examples in the context to guide the large language model (LLM) to better capture the task pattern and generate the expected response output. Therefore, choosing appropriate task examples is crucial to model performance. Summary of the invention
[0003] The present disclosure provides a response processing method, device, equipment and storage medium to at least solve the above technical problems existing in the prior art.
[0004] According to a first aspect of the present disclosure, a response processing method is provided, including: obtaining input information; selecting a target example whose contribution to the input information satisfies a first threshold from multiple candidate examples based on a selection model, the contribution representing the degree to which the candidate example improves the accuracy of the response result of the question-answering model to the input information; based on the target example and the input information, using the question-answering model, generating a response result corresponding to the input information; wherein the selection model is trained on a pre-prepared initial model based on multiple sample example pairs and the sample contribution between the sample examples in each of the sample example pairs.
[0005] In one possible implementation, the sample contribution of the sample example pair is determined based on the following method: a sample data set is obtained, the sample data set includes a plurality of sample examples; each of the sample examples is combined with other sample examples to form a sample example pair, the sample example pair including a first sample example and a second sample example in a fixed order; based on the sample data set and the sample example pair, the sample contribution of the sample example pair is determined using the question-answering model, the sample contribution characterizing the degree to which the first sample example improves the accuracy of the answer result of the question-answering model for the second sample example.
[0006] In one possible implementation, the method of determining the sample contribution of the sample example pair based on the sample data set and the sample example pair using the question-answering model includes: inputting the sample data set into the question-answering model to determine a first accuracy of the question-answering model in generating an answer for each of the sample examples in a zero-sample learning scenario; inputting the sample example pair into the question-answering model to determine a second accuracy of the question-answering model in generating an answer for each of the second sample examples based on the first sample example in a single-sample learning scenario; and determining the sample contribution of the sample example pair based on the second accuracy and the first accuracy.
[0007] In one possible implementation, determining the sample contribution of the sample example pair based on the second accuracy and the first accuracy includes: determining the sample contribution as a difference or ratio between the second accuracy and the first accuracy corresponding to the second sample example.
[0008] In one possible implementation, determining the first accuracy of the answer generated by the question and answer model for each sample example in a zero-sample learning scenario includes: for each participle in the first standard answer of the sample example, determining the probability that the question and answer model generates the participle based on the sample example and other participles before the participle in the first standard answer; and obtaining the first accuracy corresponding to the sample example based on the probabilities of all participles in the first standard answer and the total number of participles in the first standard answer.
[0009] In one possible implementation, determining the second accuracy of the question-answering model in generating an answer to each of the second sample examples based on the first sample example in a single-sample learning scenario includes: for each participle in the second standard answer of the second sample example, determining the probability that the question-answering model generates the participle based on the sample example pair and other participles before the participle in the second standard answer; and obtaining the second accuracy based on the probabilities of all participles in the second standard answer and the total number of participles in the second standard answer.
[0010] In one possible implementation, a response processing method further includes: if the feedback information of the response result to the input information shows that the satisfaction level meets a second threshold, then adding the input information and the response result corresponding to the input information to the candidate examples.
[0011] According to a second aspect of the present disclosure, a response processing device is provided, including: an acquisition module for acquiring input information; a selection module for selecting a target example whose contribution to the input information satisfies a first threshold from multiple candidate examples based on a selection model, the contribution representing the degree to which the candidate example improves the accuracy of the response result of the question-answering model to the input information; a generation module for generating a response result corresponding to the input information based on the target example and the input information and using the question-answering model; wherein the selection model is trained on a pre-prepared initial model based on a plurality of sample example pairs and the sample contribution between the sample examples in each of the sample example pairs.
[0012] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0013] at least one processor; and
[0014] a memory communicatively connected to the at least one processor; wherein,
[0015] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the present disclosure.
[0016] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method described in the present disclosure.
[0017] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, in which:
[0019] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.
[0020] Figure 1 A schematic diagram showing a process of a response processing method according to an embodiment of the present disclosure Figure 1 ;
[0021] Figure 2 A schematic diagram showing a process of a response processing method according to an embodiment of the present disclosure Figure 2 ;
[0022] Figure 3 A schematic diagram showing a process of a response processing method according to an embodiment of the present disclosure Figure 3 ;
[0023] Figure 4 A schematic diagram showing a process of a response processing method according to an embodiment of the present disclosure Figure 4 ;
[0024] Figure 5 A schematic diagram showing a process of a response processing method according to an embodiment of the present disclosure Figure 5 ;
[0025] Figure 6 A schematic diagram of the structure of a response processing device according to an embodiment of the present disclosure is shown;
[0026] Figure 7 A schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0027] In order to make the purpose, features, and advantages of the present disclosure more obvious and easy to understand, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0028] Figure 1 A schematic diagram showing a process of a response processing method according to an embodiment of the present disclosure Figure 1 ,like Figure 1 As shown, a response processing method includes:
[0029] Step S101, obtaining input information.
[0030] In this embodiment, the input information represents the questions or requests input by the user. The input information can be text, such as asking about the weather or consulting information; the input information can also be a picture for image recognition, classification or processing; the input information can also be audio, such as voice commands or music clips; the input information can also include information in various forms, for example, the user inputs a picture A and the text "Please change the puppy in picture A to a kitten."
[0031] Step S102: Select a target example whose contribution to the input information meets a first threshold from multiple candidate examples based on the selection model.
[0032] In this embodiment, the contribution degree represents the degree to which the candidate example improves the accuracy of the question-answering model's response results for the input information, wherein the question-answering model may be various analytical models or generative models, such as LLM; the candidate examples may include candidate questions and standard answers corresponding to the candidate questions, and the question-answering model may affect the accuracy of the question-answering model's response results for the input information by learning the relationship between the candidate questions and their standard answers. Therefore, after obtaining the input information, the degree to which multiple candidate examples improve the accuracy of the question-answering model's response results for the input information can be determined, and the candidate examples with a larger degree of improvement can be determined as target examples, that is, the target examples whose contribution to the input information meets the first threshold are selected from multiple candidate examples.
[0033] In this embodiment, a target example can be selected from multiple candidate examples through a selection model, and the selection model is trained based on a pre-prepared initial model based on multiple sample example pairs and sample contributions between sample examples in each sample example pair, and the sample contribution is the contribution of one sample example in the sample example pair to another sample example. Therefore, the selection model trained based on sample example pairs and sample contributions has the ability to determine the contribution of candidate examples to input information.
[0034] Step S103, based on the target example and the input information, using the question-answering model, generates a response result corresponding to the input information.
[0035] In this embodiment, after determining a target example whose contribution to the input information meets a first threshold, the target example and the input information are input into a question-answering model. The question-answering model learns the target relationship between the target question in the target example and the standard answer to the target question, as well as the output format of the standard answer, and generates a response result corresponding to the input information based on the target relationship and the output format.
[0036] In the related art, in order to select a suitable target example, the target example is usually randomly selected from the candidate examples, but the task example selected by this scheme may contain noise or irrelevant data, which will further affect the accuracy of the model's response results, or the target example is selected based on the semantic similarity between the candidate example and the model input. Although this scheme can select a target example with relatively similar semantics, it cannot guarantee that the selected task example will improve the current response task of the model, and will also result in the accuracy of the model's response results being low. The present disclosure first selects a target example from multiple candidate examples that greatly improves the accuracy of the question-answering model's response results for the input information, and then generates a response result for the input information based on the target example through the question-answering model. Compared with the random selection of target examples or the selection of target examples with semantic similarity to the input information in the related art, the present disclosure can ensure that the selected target example will have a significant improvement in the accuracy of the response result for the input information, thereby further improving the accuracy of the response result for the input information.
[0037] Figure 2 A schematic diagram showing a process of a response processing method according to an embodiment of the present disclosure Figure 2 ,like Figure 2 As shown, a response processing method includes:
[0038] Step S201, obtaining a sample data set.
[0039] In this embodiment, in order to select a target example whose contribution to the input information meets a first threshold from multiple candidate examples, it is necessary to train a selection model. First, a sample data set required for training the selection model is obtained. The sample data set includes multiple sample examples, and each sample example includes a sample question and a standard answer to the sample question.
[0040] Step S202: Each sample example is combined with other sample examples to form a sample example pair.
[0041] In this embodiment, in order to determine the contribution of each sample example to other sample examples, it is necessary to form a sample example pair with each other sample example, and the sample example pair includes a first sample example and a second sample example in a fixed order. For example, if the sample example pair A is (Case1, Case2) and the sample example pair B is (Case2, Case1), then the sample example pair A and the sample example pair B are two different sample example pairs, wherein Case1 and Case2 are different sample examples.
[0042] Step S203, based on the sample data set and the sample example pair, using the question-answering model, determine the sample contribution of the sample example pair.
[0043] In this embodiment, the sample contribution of a sample example pair represents the degree to which the first sample example in the sample example pair improves the accuracy of the response result of the question and answer model for the second sample example. For example, if the sample example pair A is (Case1, Case2), then the sample contribution of the sample example pair A is the degree to which Case1 improves the accuracy of the response result of the question and answer model for Case2; if the sample example pair B is (Case2, Case1), then the sample contribution of the sample example pair B is the degree to which Case2 improves the accuracy of the response result of the question and answer model for Case1.
[0044] In this embodiment, the sample data set and the sample example pair are input into the question-answering model, and the question-answering model can determine the accuracy of the answer result of each sample example in the sample data set, as well as the accuracy of the answer results of other sample examples to the sample example, thereby determining the degree of improvement of the accuracy of the answer results of other sample examples to the sample example. For example, if the accuracy of the answer result of the question-answering model to Case2 is S2, and the accuracy of the answer result of the question-answering model to Case2 based on Case1 is S12, then the degree of improvement of the accuracy of the answer result of Case1 to Case2 can be S12-S2.
[0045] Step S204: training the pre-prepared initial model based on the sample example pairs and the sample contribution to obtain a selection model.
[0046] In this embodiment, after determining the sample example pairs and the sample contributions of the sample example pairs, the sample example pairs and the sample contribution of the sample example pairs can be input into the initial model for training to obtain a selection model. The accuracy of the response results of the target examples selected based on the selection model to the input information will be greatly improved, thereby further improving the accuracy of the response results of the input information.
[0047] It should be emphasized that steps S201 to S204 only need to be completed before step S206, but do not have to be completed before step S205.
[0048] Step S205, obtaining input information.
[0049] Step S206: Select a target example whose contribution to the input information meets a first threshold from multiple candidate examples based on the selection model.
[0050] Step S207: Based on the target example and the input information, a question-answering model is used to generate a response result corresponding to the input information.
[0051] The specific implementation details of step S205 to step S207 are similar to those of step S101 to step S103 and are not repeated here.
[0052] Figure 3 A schematic diagram showing a process of a response processing method according to an embodiment of the present disclosure Figure 3 ,like Figure 3 As shown, a response processing method includes:
[0053] Step S301, obtaining a sample data set.
[0054] Step S302: Each sample example is combined with other sample examples to form a sample example pair.
[0055] The specific implementation details of step S301-step S302 are similar to those of step S201-step S202 and will not be repeated here.
[0056] Step S303: input the sample data set into the question-answering model to determine the first accuracy of the answer generated by the question-answering model for each sample example in a zero-sample learning scenario.
[0057] In this embodiment, the machine learning method of zero-shot learning allows the question-answering model to identify or describe categories that have never appeared before. Therefore, the sample data set is input into the question-answering model. For each sample example in the sample data set, the question-answering model generates an answer corresponding to the sample question based on the sample question in the sample example, and then compares the answer generated by the question-answering model with the standard answer to the sample question in the sample example, and determines the first accuracy based on the comparison result. For example, the first accuracy corresponding to the sample data set (Case1, Case2, Case3, Case4...) is (Zero-Shot Score1, Zero-Shot Score2, Zero-Shot Score3, Zero-ShotScore4...), where the first accuracy corresponding to Case1 is Zero-Shot Score1, the first accuracy corresponding to Case2 is Zero-Shot Score2, and so on.
[0058] In one embodiment, the first accuracy can be determined based on evaluation indicators such as exact match (EM) and F1 score, where EM is recorded as 1 when the answer generated by the question-answering model is completely consistent with the standard answer to the sample question, otherwise it is recorded as 0. The EM score can be determined as the first accuracy. EM is suitable for question-answering tasks that require completely consistent answers, such as factual question-answering; the F1 score comprehensively considers the precision and recall rate. When the answer generated by the question-answering model contains part of the standard answer to the sample question, the F1 score can better reflect the performance of the question-answering model. The higher the F1 score, the better the model performs in balancing precision and recall. The F1 score is suitable for tasks that allow partial matching, such as extractive question-answering or open domain question-answering.
[0059] Step S304: input the sample example pair into the question-answering model to determine the second accuracy of the question-answering model in generating an answer to each second sample example based on the first sample example in a single-sample learning scenario.
[0060] In this embodiment, the machine learning method of one-shot learning allows the question-answering model to identify or describe new categories when there is only one known category. Therefore, the sample example pair is input into the question-answering model. For each sample example pair, the question-answering model will generate an answer to the second sample example based on the first sample example, and then compare the answer to the second sample example generated by the question-answering model with the standard answer to the second sample example, and determine the second accuracy of the question-answering model generating the answer to the second sample example based on the first sample example based on the comparison result. For example, if the sample example pair A is (Case1, Case2), the second accuracy is One-shot Score12, which represents the accuracy of Case1 to the answer result of the question-answering model for Case2; if the sample example pair B is (Case2, Case1), the second accuracy is One-shot Score21, which represents the accuracy of Case2 to the answer result of the question-answering model for Case1. In one example, the second accuracy can also be determined based on evaluation indicators such as exact matching and F1 score.
[0061] Step S305: Determine the sample contribution of the sample example pair based on the second accuracy and the first accuracy.
[0062] In this embodiment, since the sample contribution represents the degree of improvement of the accuracy of the answer result of the question and answer model for the second sample example by the first sample example in the sample example pair, the difference or ratio between the second accuracy of the answer result of the question and answer model for the second sample example based on the first sample example and the first accuracy of the answer result of the question and answer model for the second sample example can be determined as the sample contribution of the sample example pair. The larger the difference or ratio, the greater the degree of improvement of the accuracy of the answer result of the question and answer model for the second sample example by the first sample example. In this way, the degree of improvement of the accuracy of the answer result of the question and answer model for the second sample example by the first sample example in the sample example pair can be accurately determined, further improving the accuracy of the answer result of the input information.
[0063] For example, if the first accuracy corresponding to the sample data set (Case1, Case2, Case3, Case4...) is (Zero-Shot Score1, Zero-Shot Score2, Zero-Shot Score3, Zero-Shot Score4...); the second accuracy of the sample example pair A (Case1, Case2) is One-shot Score12; the second accuracy of the sample example pair B (Case2, Case1) is One-shot Score21, then the degree of improvement in the accuracy of Case1 to Case2 in the sample example pair A is the difference or ratio between One-shot Score12 and Zero-Shot Score2; the degree of improvement in the accuracy of Case2 to Case1 in the sample example pair B is the difference or ratio between One-shot Score21 and Zero-Shot Score1.
[0064] Step S306: training the pre-prepared initial model based on the sample example pairs and the sample contribution to obtain a selection model.
[0065] The specific implementation details of step S306 are similar to those of step S204 and will not be repeated here.
[0066] Step S307, obtaining input information.
[0067] Step S308: Select a target example whose contribution to the input information meets a first threshold from multiple candidate examples based on the selection model.
[0068] Step S309: Based on the target example and the input information, the question-answering model is used to generate a response result corresponding to the input information.
[0069] The specific implementation details of step S307 to step S309 are similar to those of step S101 to step S103 and are not repeated here.
[0070] In another embodiment, the step S303 of “determining a first accuracy of the question-answering model generating an answer for each sample example in a zero-shot learning scenario” includes:
[0071] For each word segmentation in the first standard answer of the sample example, determine the probability of the question-answering model generating the word segmentation based on the sample example and other word segmentations before the word segmentation in the first standard answer; based on the probabilities of all word segmentations in the first standard answer and the total number of word segmentations in the first standard answer, obtain the first accuracy corresponding to the sample example.
[0072] In this embodiment, in order to ensure the accuracy of the first accuracy corresponding to the sample example, when determining the first accuracy, for each word segment in the first standard answer of the sample example, the probability that the question-answering model generates the word segment based on the sample question in the sample example and other word segments before the word segment in the first standard answer is determined, and then the first accuracy is determined based on the probabilities corresponding to all word segments and the total number of word segments in the first standard answer. Thus, when calculating the first accuracy, the local context information in the text can be captured, and the similarity between the answer generated by the question-answering model and the standard answer can be more comprehensively evaluated, thereby determining a more accurate first accuracy.
[0073] In one possible implementation, the first accuracy may be calculated based on the following formula (1):
[0074]
[0075] Among them, S zs (A|Case n ) Characterizes the question-answering model to generate cases in the Zero-Shot Learning scenario n The first accuracy of the answer A is S zs ,L represents Case n The length of the first standard answer A, that is, the total number of participles, w i Represents the i-th word in the first standard answer A, P(w i |Case n ,w1,w2,…,w i-1 ) Characterize the question answering model based on sample examples Case n The sample question and the first standard answer in the word segmentation w i The other participles before (w1,w2,…,w i-1 ) Generate word w i probability.
[0076] In another embodiment, the step S304 of “determining a second accuracy of the question-answering model generating an answer to each second sample example based on the first sample example in a single-sample learning scenario” includes:
[0077] For each word segmentation in the second standard answer of the second sample example, determine the probability of the question-answering model generating the word segmentation based on the sample example pair and other word segmentations before the word segmentation in the second standard answer; based on the probabilities of all word segmentations in the second standard answer and the total number of word segmentations in the second standard answer, obtain the second accuracy.
[0078] In this embodiment, in order to ensure the accuracy of the second accuracy of the answer generated for each second sample example based on the first sample example, when determining the second accuracy, for each word segment in the second standard answer of the second sample example in the sample example pair, the probability that the question-answering model generates the word segment based on the sample question in the second sample example and other word segments before the word segment in the second standard answer is determined, and then the second accuracy is determined based on the probability of all word segments in the second standard answer and the total number of word segments in the second standard answer. Thus, when calculating the second accuracy, local context information in the text can be captured, and the similarity between the answer generated by the question-answering model and the standard answer can be more comprehensively evaluated, thereby determining a more accurate second accuracy.
[0079] In one possible implementation, the second accuracy may be calculated based on the following formula (II):
[0080]
[0081] Among them, S os (A|Case m,n ) Characterize the question answering model in the scenario of One-Shot Learning based on Case m Generate Case n The second accuracy of answer A is S os ,L represents Case n The length of the second standard answer A, that is, the total number of participles, w i Represents the i-th participle in the second standard answer A, P(w i |Case m,n ,w1,w2,…,w i-1 ) Characterize the question answering model based on sample examples Case m 、Case n The sample question in the second standard answer is the word segmentation w i The other participles before (w1,w2,…,w i-1 ) Generate word w i probability.
[0082] Figure 4 A schematic diagram showing a process of a response processing method according to an embodiment of the present disclosure Figure 4 ,like Figure 4 As shown, a response processing method includes:
[0083] Step S401, obtaining input information.
[0084] Step S402: Select a target example whose contribution to the input information meets a first threshold from multiple candidate examples based on the selection model.
[0085] Step S403: Based on the target example and the input information, a question-answering model is used to generate a response result corresponding to the input information.
[0086] The specific implementation details of step S401 to step S403 are similar to those of step S101 to step S103 and are not repeated here.
[0087] Step S404: If the feedback information of the response result to the input information shows that the satisfaction level meets the second threshold, the input information and the response result corresponding to the input information are added to the candidate examples.
[0088] In this embodiment, the feedback information may be the user's evaluation of the answer result or the next input information input by the user. For example, if the user likes the feedback information, or the next input information input does not have the intention to correct the input information or the answer result, then the feedback information of the answer result is determined to show that the satisfaction meets the second threshold, and the input information and the answer result corresponding to the input information can be added to the candidate examples, so that after the user enters other input information, the target example whose contribution to the input information meets the first threshold can be selected from the multiple added candidate examples based on the selection model, that is, the input information and the answer result corresponding to the input information can be used as candidate examples to guide the question and answer model to better generate answer results for other input information, thereby continuously improving the accuracy of the question and answer model in generating answer results.
[0089] In order to facilitate the understanding of the present disclosure, the following Figure 5 A response processing method disclosed in the present invention is described as follows:
[0090] Figure 5 A schematic diagram showing a process of a response processing method according to an embodiment of the present disclosure Figure 5 ,like Figure 5 As shown, after obtaining the input information, the input information is input into the trained selection model. The selection model selects a target example whose contribution to the input information meets a first threshold from multiple candidate examples. The target examples include Case 1, Case 3 and other possible examples. The target example and the input information are then input into the question-answering model. The question-answering model learns the target relationship between the target question in the target example and the standard answer to the target question, as well as the output format of the standard answer, and generates and outputs a response result corresponding to the input information.
[0091] Figure 6A schematic diagram of the structure of a response processing device according to an embodiment of the present disclosure is shown. Figure 6 As shown, a response processing device includes:
[0092] An acquisition module 10 is used to acquire input information; a selection module 11 is used to select a target example whose contribution to the input information meets a first threshold from multiple candidate examples based on a selection model, wherein the contribution represents the degree to which the candidate example improves the accuracy of the answer result of the question-answering model to the input information; a generation module 12 is used to generate an answer result corresponding to the input information based on the target example and the input information and using the question-answering model; wherein the selection model is obtained by training a pre-prepared initial model based on multiple sample example pairs and the sample contribution between the sample examples in each sample example pair.
[0093] In one possible implementation, a response processing device also includes: a training module, used to obtain a sample data set, the sample data set including multiple sample examples; each sample example is combined with other sample examples to form a sample example pair, the sample example pair including a first sample example and a second sample example in a fixed order; based on the sample data set and the sample example pair, using a question-answering model, the sample contribution of the sample example pair is determined, the sample contribution represents the degree of improvement of the accuracy of the first sample example's response result to the question-answering model for the second sample example.
[0094] In one embodiment, the training module is also used to: input the sample data set into the question-answering model to determine the first accuracy of the question-answering model in generating the answer for each sample example in a zero-sample learning scenario; input the sample example pair into the question-answering model to determine the second accuracy of the question-answering model in generating the answer for each second sample example based on the first sample example in a single-sample learning scenario; and determine the sample contribution of the sample example pair based on the second accuracy and the first accuracy.
[0095] In one possible implementation, the training module is further used to: determine the difference or ratio between the second accuracy and the first accuracy corresponding to the second sample example as the sample contribution.
[0096] In one embodiment, the training module is also used to: for each participle in the first standard answer of the sample example, determine the probability of the question-answering model generating a participle based on the sample example and other participles before the participle in the first standard answer; and obtain the first accuracy corresponding to the sample example based on the probabilities of all participles in the first standard answer and the total number of participles in the first standard answer.
[0097] In one embodiment, the training module is also used to: for each word segment in the second standard answer of the second sample example, determine the probability of the question-answering model generating a word segment based on the sample example pair and other word segmentations before the word segment in the second standard answer; and obtain a second accuracy based on the probabilities of all word segmentations in the second standard answer and the total number of word segmentations in the second standard answer.
[0098] In one possible implementation, a response processing device further includes: an adding module, which is used to add the input information and the response result corresponding to the input information to the candidate examples if the feedback information of the response result to the input information shows that the satisfaction meets the second threshold.
[0099] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0100] Figure 7 A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0101] like Figure 7 As shown, the device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0102] A number of components in the device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0103] The computing unit 801 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 801 performs the various methods and processes described above, such as a response processing method. For example, in some embodiments, a response processing method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of a response processing method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform a response processing method in any other appropriate manner (e.g., by means of firmware).
[0104] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0105] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0106] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0107] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0108] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0109] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0110] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0111] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0112] The above is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A response processing method, comprising: Get input information; Selecting a target example whose contribution to the input information satisfies a first threshold from multiple candidate examples based on the selection model, wherein the contribution represents the degree to which the candidate example improves the accuracy of the answer result of the question-answering model to the input information; Based on the target example and the input information, using the question-answering model, generating a response result corresponding to the input information; The selection model is obtained by training a pre-prepared initial model based on a plurality of sample example pairs and the sample contribution between the sample examples in each of the sample example pairs.
2. The method according to claim 1, wherein the sample contribution of the sample example pair is determined based on the following method: Acquire a sample data set, wherein the sample data set includes a plurality of sample examples; Combine each of the sample examples with other sample examples to form a sample example pair, wherein the sample example pair includes a first sample example and a second sample example with a fixed order; Based on the sample data set and the sample example pair, the question-answering model is used to determine the sample contribution of the sample example pair, wherein the sample contribution represents the degree to which the first sample example improves the accuracy of the answer result of the question-answering model for the second sample example.
3. The method according to claim 2, wherein determining the sample contribution of the sample example pair based on the sample data set and the sample example pair using the question-answering model comprises: Inputting the sample data set into the question-answering model, and determining a first accuracy of the question-answering model in generating an answer to each of the sample examples in a zero-shot learning scenario; Inputting the sample example pair into the question-answering model, and determining a second accuracy of the question-answering model generating an answer to each of the second sample examples based on the first sample example in a single-sample learning scenario; Based on the second accuracy and the first accuracy, a sample contribution of the sample example pair is determined.
4. The method according to claim 3, wherein determining the sample contribution of the sample example pair based on the second accuracy and the first accuracy comprises: The sample contribution is determined as a difference or a ratio between the second accuracy and a first accuracy corresponding to the second sample example.
5. The method according to claim 3, wherein determining a first accuracy of the answer generated by the question-answering model for each sample example in a zero-shot learning scenario comprises: For each participle in the first standard answer of the sample example, determining a probability that the question-answering model generates the participle based on the sample example and other participles preceding the participle in the first standard answer; Based on the probabilities of all the segmentations in the first standard answer and the total number of segmentations in the first standard answer, a first accuracy corresponding to the sample example is obtained.
6. The method according to claim 3, wherein determining a second accuracy of the question-answering model generating an answer to each second sample example based on the first sample example in a single-sample learning scenario comprises: For each participle in the second standard answer of the second sample example, determining a probability that the question-answering model generates the participle based on the sample example pair and other participles preceding the participle in the second standard answer; The second accuracy is obtained based on the probabilities of all the segmentations in the second standard answer and the total number of segmentations in the second standard answer.
7. The method according to any one of claims 1 to 6, further comprising: If the feedback information of the response result to the input information shows that the satisfaction level meets the second threshold, the input information and the response result corresponding to the input information are added to the candidate examples.
8. A response processing device, comprising: An acquisition module is used to obtain input information; A selection module, configured to select a target example whose contribution to the input information satisfies a first threshold from multiple candidate examples based on the selection model, wherein the contribution represents the degree to which the candidate example improves the accuracy of the answer result of the question-answering model to the input information; A generation module, configured to generate a response result corresponding to the input information by using the question-answering model based on the target example and the input information; The selection model is obtained by training a pre-prepared initial model based on a plurality of sample example pairs and the sample contribution between the sample examples in each of the sample example pairs.
9. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the method according to any one of claims 1 to 7.