A method, device and storage medium for training a question and answer model

By training the question-answering model using online reinforcement learning, and filtering and iterating inference responses of varying lengths, the problem of cumbersome and complex output of question-answering models is solved, resulting in improved stability and accuracy, and adaptability to various application scenarios.

CN123178530APending Publication Date: 2026-11-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510686299.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-26
Publication Date
2026-11-27

Smart Images

  • Figure CN123178530A_ABST
    Figure CN123178530A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of data processing and artificial intelligence, and provides a training method and device of a question and answer model, equipment and a storage medium, so as to ensure effective control of content length and improve model performance. The method comprises the following steps: reasoning a sample question through a question and answer model to obtain a reasoning reply set, wherein the reasoning reply set comprises a plurality of positive reasoning replies and negative reasoning replies with different content lengths; at least one batch of reasoning replies is selected from the reasoning reply set based on the content length; the content length of the positive reasoning reply in each batch of reasoning replies is smaller than that of other positive reasoning replies except the at least one batch of reasoning replies in the reasoning reply set; the content length of the negative reasoning reply in each batch of reasoning replies is greater than that of other negative reasoning replies except the at least one batch of reasoning replies in the reasoning reply set; and model training is performed based on the at least one batch of reasoning replies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and more particularly to the field of artificial intelligence technology, providing a training method, apparatus, device, and storage medium for a question-answering model. Background Technology

[0002] With the continuous development of artificial intelligence, question-answering models are now widely used in daily life. However, the cumbersome and complex reasoning responses output by these models limit their application scenarios. Therefore, to enable question-answering models to be widely used in various daily life scenarios, it is necessary to control the length of the reasoning responses they output.

[0003] Currently, methods such as prompting engineering, decoding intervention, model merging, and parameter optimization are commonly used to control content length.

[0004] The cue engineering approach primarily controls content length by designing cue words, guiding the model to reduce the length of its inference responses and focus on key information. However, this approach heavily relies on few-sample examples in the cue words and is highly correlated with the model's intrinsic characteristics, which can affect the stability of the model's control performance.

[0005] The decoding intervention method forcibly inserts an end marker, directly modifying the inference trajectory to control content length. This method disrupts the model's inference coherence and affects its accuracy.

[0006] The model merging method involves combining models with similar performance and controlling the length of the inference response through the fused model. However, this method is affected by the performance of the initial model, making the control effect of the fused model unstable.

[0007] Parameter optimization methods include offline and online optimization. Offline optimization uses a concise inference trajectory for supervised fine-tuning or preference learning; while online optimization directly optimizes the content inference response length during training by pre-designing rules or training data. This approach is susceptible to subjective factors, which in turn affects the model's accuracy.

[0008] In summary, how to improve model performance while effectively controlling the length of the question-answering model's output is a problem that urgently needs to be solved. Summary of the Invention

[0009] This application provides a training method, apparatus, device, and storage medium for a question-answering model, which improves model performance while ensuring effective control over the length of the content output by the question-answering model.

[0010] This application provides a method for training a question-answering model, comprising:

[0011] The question-answering model is used to reason about the sample questions to obtain the first inference response set. The first inference response set contains: multiple positive inference responses with different content lengths and multiple negative inference responses with different content lengths.

[0012] Based on the content length, at least one first batch of reasoning responses is selected from the first set of reasoning responses. Each first batch of reasoning responses contains at least one positive reasoning response and at least one negative reasoning response.

[0013] In each first batch of reasoning responses, the length of the positive reasoning responses is less than that of the other positive reasoning responses in the first reasoning response set, excluding at least one first batch of reasoning responses.

[0014] The length of the negative reasoning responses in each first batch of reasoning responses is greater than that of the other negative reasoning responses in the first batch of reasoning responses, excluding at least one first batch of reasoning responses.

[0015] The question-answering model is trained based on at least one initial inference response.

[0016] This application provides a training device for a question-answering model, comprising:

[0017] The obtaining unit is used to reason about the sample question through the question-answering model to obtain the first reasoning response set. The first reasoning response set contains: multiple positive reasoning responses with different content lengths and multiple negative reasoning responses with different content lengths.

[0018] A filtering unit is used to filter at least one batch of reasoning responses from the first set of reasoning responses based on the content length. Each batch of reasoning responses includes at least one positive reasoning response and at least one negative reasoning response.

[0019] In each first batch of reasoning responses, the length of the positive reasoning responses is less than that of the other positive reasoning responses in the first reasoning response set, excluding at least one first batch of reasoning responses.

[0020] The length of the negative reasoning responses in each first batch of reasoning responses is greater than that of the other negative reasoning responses in the first batch of reasoning responses, excluding at least one first batch of reasoning responses.

[0021] Training units are used to train the question-answering model based on at least one initial batch of inference responses.

[0022] In one possible implementation, there are multiple sample questions; the first inference response set includes: multiple positive inference responses of different content lengths and multiple negative inference responses of different content lengths corresponding to each sample question; the filtering unit is specifically used for:

[0023] Select a set of positive reasoning responses whose content length is less than the positive length threshold from the first set of reasoning responses, and select a set of negative reasoning responses whose content length is greater than the negative length threshold from the first set of reasoning responses;

[0024] Based on the input order of multiple sample questions, a set of positive reasoning responses and a set of negative reasoning responses are selected and divided into at least one first batch of reasoning responses.

[0025] In one possible implementation, the filtering unit is specifically used for:

[0026] Based on the input order of multiple sample questions, all reasoning responses in a set of positive reasoning responses and a set of negative reasoning responses are uniformly sorted to obtain an initial reasoning response sequence;

[0027] Based on the quantity threshold set for batch training, the initial inference response sequence is divided into at least one batch of inference responses; the number of inference responses in each batch is consistent with the quantity threshold.

[0028] In one possible implementation, the forward length threshold is determined as follows:

[0029] Pre-defined; or, defined based on a forward sorting sequence; the forward sorting sequence is: a sequence obtained by sorting all forward inference responses in the first inference response set according to their content length from shortest to longest;

[0030] The negative length threshold is determined as follows:

[0031] Pre-defined; or, based on a negative sorting sequence; the negative sorting sequence is: a sequence obtained by sorting all negative reasoning responses in the first reasoning response set according to their content length from longest to shortest.

[0032] In one possible implementation, the first batch has N units, where N is a positive integer greater than 1; the training units are specifically used for:

[0033] Based on N initial inference responses, the question-answering model undergoes N rounds of iterative training; where each round of iterative training involves:

[0034] Select one first batch of reasoning responses from N first batches of reasoning responses;

[0035] The initial loss function is determined based on the difference between each inference response in a first batch of inference responses and the inference result label of the corresponding sample question;

[0036] Based on the initial loss function, the parameters of the current question answering model are tuned.

[0037] In one possible implementation, the filtering unit is further configured to: filter at least one second batch of inference responses from the second inference response set, each second batch of inference responses comprising: at least one positive inference response and at least one negative inference response; the second inference response set comprises at least: the remaining inference responses in the first inference response set; wherein the remaining inference responses are those remaining in the first inference response set after filtering at least one first batch of inference responses;

[0038] The training unit is also used to: train the question answering model based on at least one second batch of inference responses after training the question answering model based on at least one first batch of inference responses.

[0039] In one possible implementation, the filtering unit is specifically used for:

[0040] If the number of remaining inference responses in the first inference response set is not less than the number threshold set for batch training, then the remaining inference responses are used as the second inference response set, and at least one inference response for the second batch is selected from the second inference response set.

[0041] Among them, the length of the positive reasoning response in each second batch of reasoning responses is greater than the length of the positive reasoning responses in all first batches of reasoning responses;

[0042] The length of the negative reasoning responses in each second batch of reasoning responses is shorter than the length of the negative reasoning responses in all first batches of reasoning responses.

[0043] In one possible implementation, the filtering unit is specifically used for:

[0044] If the number of remaining inference responses in the first inference response set is less than the number threshold set for batch training, then the remaining inference responses are stored in the second inference response set.

[0045] Store other inference responses corresponding to other sample questions into a second inference response set until the number of inference responses stored in the second inference response set is not less than the number threshold set for batch training. Then, select at least one second batch of inference responses from the second inference response set.

[0046] In one possible implementation, there are multiple sample problems; the filtering unit is specifically used for:

[0047] Based on the input order of multiple sample questions, the reasoning responses in the second reasoning response set are sorted to obtain the compensated reasoning response sequence;

[0048] Based on the quantity threshold set in batch training, the compensated inference response sequence is divided into at least one second batch of inference responses; the number of inference responses in each second batch is consistent with the quantity threshold.

[0049] In one possible implementation, after selecting at least one second batch of reasoning responses from the second set of reasoning responses, and before training the question-answering model based on at least one second batch of reasoning responses, the selection unit is further configured to:

[0050] Identify the current state information of the question-answering model; wherein, the state information includes at least one of the following: number of training iterations, model accuracy;

[0051] Based on state information, the question-answering model is trained based on at least one second batch of reasoning responses.

[0052] In one possible implementation, the filtering unit is specifically used for:

[0053] Based on the state information, determine the current compensatory training probability;

[0054] Based on the compensated training probability, determine the training of the question answering model based on at least one second batch of inference responses;

[0055] Among them, the probability of compensation training is negatively correlated with state information.

[0056] In one possible implementation, at least one second batch has M units, where M is a positive integer greater than 1; the training unit is specifically used for:

[0057] Based on M second-batch inference responses, the question-answering model is trained through M rounds of iterations; where each round of iterations involves:

[0058] Select one second-batch reasoning response from M second-batch reasoning responses;

[0059] The compensation loss function is determined based on the difference between each inference response in a second batch of inference responses and the inference result label of the corresponding sample question.

[0060] Based on the compensation loss function, the parameters of the current question answering model are tuned.

[0061] An electronic device provided in this application includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of any of the above-described question-answering model training methods.

[0062] In one possible implementation, when a computer program is executed by a processor, the processor performs the following process:

[0063] The question-answering model is used to reason about the sample questions to obtain the first inference response set. The first inference response set contains: multiple positive inference responses with different content lengths and multiple negative inference responses with different content lengths.

[0064] Based on the content length, at least one first batch of reasoning responses is selected from the first set of reasoning responses. Each first batch of reasoning responses contains at least one positive reasoning response and at least one negative reasoning response.

[0065] In each first batch of reasoning responses, the length of the positive reasoning responses is less than that of the other positive reasoning responses in the first reasoning response set, excluding at least one first batch of reasoning responses.

[0066] The length of the negative reasoning responses in each first batch of reasoning responses is greater than that of the other negative reasoning responses in the first batch of reasoning responses, excluding at least one first batch of reasoning responses.

[0067] The question-answering model is trained based on at least one initial inference response.

[0068] This application provides a computer-readable storage medium including a computer program. When the computer program is run on an electronic device, the computer program is used to cause the electronic device to perform the steps of any of the above-described question-answering model training methods.

[0069] This application provides a computer program product, which includes a computer program stored in a computer-readable storage medium. When the processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the steps of any of the above-described question-answering model training methods.

[0070] The beneficial effects of this application are as follows:

[0071] This application provides a training method, apparatus, device, and storage medium for a question-answering model, relating to the field of data processing technology, and particularly to the field of artificial intelligence technology. The implementation of the question-answering model provided in this application includes:

[0072] First, sample questions are input into the question-answering model. The model then performs reasoning to obtain inferred responses for each sample question. Based on all inferred responses, a first inferred response set is constructed, containing multiple positive inferred responses of varying lengths and multiple negative inferred responses of varying lengths. Next, at least one batch of inferred responses is selected from this first batch, each batch containing at least one positive and at least one negative inferred response. Finally, the question-answering model is trained based on at least one batch of inferred responses. During training, the training data consists of inferred responses obtained by the question-answering model in reasoning about the sample questions, not manually selected data. This avoids the problem of poor accuracy caused by subjective factors in training data. Furthermore, using positive and negative inferred responses of varying lengths increases the diversity of training data, enabling the model to better identify positive inferred responses, suppress negative inferred responses, and understand and generate inferred responses of diverse lengths. This allows the model to provide more diverse inferred responses according to needs, enabling it to meet complex and varied requirements and be applied to multiple scenarios. Furthermore, the training process focuses solely on the question-answering model, without any model parameter fusion, thus avoiding the problem of poor accuracy caused by the influence of other models' parameters on the question-answering model.

[0073] In this application, to effectively control the content length of the question-answering model's output, in addition to ensuring the diversity of training data, the content length of the training data must also meet the following length conditions: the content length of positive inference responses in each batch of inference responses is less than that of other positive inference responses in the first batch of inference responses, excluding at least one in the first batch; and the content length of negative inference responses in each batch of inference responses is greater than that of other negative inference responses in the first batch of inference responses, excluding at least one in the first batch. Further limiting the content length of the filtered inference responses allows the model to encourage concise and positive inference responses and suppress redundant and negative inference responses during training, thereby effectively controlling the content length of the inference responses output by the question-answering model. Furthermore, the inference responses output during training are not affected by prompt words and inference end markers, ensuring the stability and accuracy of the question-answering model.

[0074] In summary, this application can improve the accuracy and stability of the question-answering model while effectively controlling the length of the output content.

[0075] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description

[0076] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0077] Figure 1 This is a schematic diagram of an application scenario in an embodiment of this application;

[0078] Figure 2 This application provides a schematic diagram of driving route planning based on a question-answering model;

[0079] Figure 3 This is a schematic diagram of the structure of a question-answering model provided in an embodiment of this application;

[0080] Figure 4 A flowchart illustrating a training method for a question-answering model provided in an embodiment of this application;

[0081] Figure 5 A schematic diagram illustrating the construction of a first inference response set provided in an embodiment of this application;

[0082] Figure 6 A flowchart illustrating a method for filtering at least one first batch of reasoning responses provided in this application embodiment;

[0083] Figure 7 A schematic diagram illustrating the selection of at least one batch of inference responses from a first inference response set, provided as an embodiment of this application;

[0084] Figure 8 A schematic diagram illustrating the training of a reasoning response question-answering model based on the first batch, provided for an embodiment of this application;

[0085] Figure 9 A schematic diagram illustrating the first method of constructing a second inference response set and filtering at least one second batch of inference responses provided in this application embodiment;

[0086] Figure 10 A schematic diagram illustrating a second method for constructing a second inference response set and filtering at least one second batch of inference responses, as provided in an embodiment of this application;

[0087] Figure 11A flowchart illustrating a method for identifying training based on at least one second batch of inference responses, provided in an embodiment of this application;

[0088] Figure 12 A flowchart illustrating a method for model training based on a second batch of inference responses, provided in an embodiment of this application;

[0089] Figure 13 This is a schematic diagram illustrating how a question-answering model is trained based on the first batch of inference responses and the second batch of inference responses, as provided in an embodiment of this application.

[0090] Figure 14 A structural diagram of a training device for a question-answering model provided in an embodiment of this application;

[0091] Figure 15 This is a structural diagram of a computing device provided in an embodiment of this application. Detailed Implementation

[0092] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments of this application. Obviously, the described embodiments are only some embodiments of the technical solutions of this application, and not all embodiments. Based on the embodiments recorded in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the technical solutions of this application.

[0093] The following describes some of the concepts involved in the embodiments of this application.

[0094] 1. Question-Answering Model: A model that reasones about a given question and outputs a corresponding reasoned response. Question-answering models include, but are not limited to, strategy-based models and thought-based models. Strategy-based models generate multiple different reasoned responses for a single question, known as diverse reasoning responses. Thought-based models generate multiple detailed thought chains for a single question, each thought chain representing the entire reasoning process for a reasoned response to the input question. In this embodiment, the question-answering model is trained using a reinforcement learning strategy to reduce the length of the reasoned responses while maintaining model accuracy and stability. Question-answering models are widely used in fields involving data reasoning, such as game analysis, robot control, healthcare, education, and autonomous driving.

[0095] 2. Reinforcement Learning (RL):

[0096] Reinforcement learning is a machine learning paradigm whose basic framework is the Markov decision process. Reinforcement learning enables an agent to learn through trial and error how to make a series of decisions to maximize some form of cumulative reward while interacting with its environment. In reinforcement learning, the agent is not given explicit operational steps but must learn the optimal policy by exploring the environment. Here, "agent" refers to an entity capable of autonomous decision-making and interacting with its environment; in the embodiments of this application, the agent is an entity deployed with a question-answering model.

[0097] In the embodiments of this application, when using reinforcement learning strategies to train the question-answering model, the reinforcement learning strategies include, but are not limited to, Proximal Policy Optimization (PPO) and Group Relative Policy Optimization (GRPO). PPO is designed to be more reliable and efficient, enabling its practical application to complex problems during training. GRPO is an improvement upon PPO, making the training process more streamlined and faster, especially in complex inference tasks.

[0098] Taking the proximal optimization strategy as an example, the training of the question-answering model is explained as follows: First, the question-answering model infers the sample question and obtains multiple different inference responses; second, the reward model is used to evaluate each inference response and obtain the corresponding reward value; then, the generalized advantage estimation (GAE) is used to estimate the advantage function based on all the reward values ​​output by the reward model; then, a loss function is constructed based on the advantage function, and the parameters of the question-answering model are updated based on the loss function.

[0099] 3. Reward Model:

[0100] The reward model is used to evaluate the output of the model, avoiding manual evaluation of each output and reducing labor costs. In this embodiment, the reward model is used to evaluate the reasoning response output by the question-answering model for a given question to determine whether the reasoning response is positive or negative. The reward model can be a pre-trained model or a predefined rule.

[0101] 4. Positive reasoning response and negative reasoning response:

[0102] A positive reasoning response is a reasoning response that is consistent with, close to, or related to the reference reasoning response of the corresponding question; a negative reasoning response is a reasoning response that is inconsistent with, significantly deviates from, or is irrelevant to the reference reasoning response of the corresponding question; the reference reasoning response is the answer information to the question, which can be a single result or include the reasoning process.

[0103] 5. Batch:

[0104] In model training, a batch refers to a set of training data used to calculate gradients and update model parameters in each iteration. In this embodiment, using batches of inference responses for model training allows the model to complete an iteration faster and find the optimal solution more quickly compared to processing the entire inference response set at once. Furthermore, using batches effectively controls memory usage for the entire inference response set, making the model training process more stable and improving the model's generalization ability.

[0105] The word “exemplary” as used below means “serving as an example, embodiment, or illustration.” Any embodiment illustrated as an “exemplary” need not be construed as superior to or better than other embodiments.

[0106] The terms "first" and "second" used in this document are for descriptive purposes only and should not be construed as indicating relative importance or implying the number of technical features indicated. Therefore, features defined with "first" and "second" may explicitly or implicitly include one or more features; for example, in the embodiments of this application, "first inference response information set" and "second inference response information set" are used to represent two different inference response information sets, and these two inference response information sets include multiple positive inference responses and multiple negative inference responses, and there is overlapping inference response information in these two inference response information sets.

[0107] In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more. For example, if there are multiple sample questions in the embodiments of this application, it means that there are two or more sample questions in the input question-answering model of this application.

[0108] The design concept of the embodiments of this application is briefly introduced below:

[0109] With the continuous development of artificial intelligence, question-answering models have been widely used in daily life. However, because the training batch of data used in question-answering model training consists of multiple different inference responses generated by the model for a single question, current question-answering models primarily focus on the accuracy of the output inference responses, rather than their conciseness, and cannot effectively control the content length.

[0110] However, if the reasoning responses output by the question-answering model are cumbersome and complex, it will limit the application scenarios of the question-answering model, meaning its application scenarios are limited. Therefore, in order to make the question-answering model widely applicable to various scenarios in daily life, it is necessary to control the length of the reasoning responses output by the question-answering model.

[0111] Currently, methods such as prompting engineering, decoding intervention, model merging, and parameter optimization are commonly used to control content length.

[0112] The cue engineering approach primarily controls content length by designing cue words, guiding the model to reduce redundancy—that is, to shorten the length of inference responses and focus on key information. However, this approach heavily relies on few-sample examples in the cue words and is highly correlated with the model's intrinsic characteristics, which can affect the stability of the model's control performance.

[0113] The decoding intervention method forcibly inserts an end marker, directly modifying the inference trajectory to control content length. This method disrupts the model's inference coherence and affects its accuracy.

[0114] The model merging method combines models with similar performance and controls the content length by merging the models. Under the model merging method, even simple average merging can significantly reduce the content length. However, this method is affected by the performance of the initial models, making the control effect of the merged models unstable.

[0115] Parameter optimization methods include offline and online optimization. Offline optimization involves collecting training data and performing supervised fine-tuning or preference learning; the training data consists of concise inference trajectories. For example, important tokens are selected based on semantic importance to form training data; training data is collected by combining question difficulty and the length of the inference response content; and a two-layer trajectory selection strategy is designed to obtain appropriate and concise training data. Online optimization, on the other hand, directly optimizes the content length during training; for example, a length penalty is introduced into the reward function, and the reward is related to the content length. It is evident that parameter optimization methods, which rely on pre-designed rules or pre-designed training data, are influenced by subjective factors, thus affecting the model's accuracy.

[0116] In summary, how to improve model performance while effectively controlling the length of the question-answering model's output is a problem that urgently needs to be solved.

[0117] In view of this, embodiments of this application provide a training method, apparatus, device, and storage medium for a question-answering model, relating to the field of data processing technology, and particularly to the field of artificial intelligence technology; wherein, the training method for the question-answering model is online reinforcement learning training, and the implementation of training the question-answering model includes:

[0118] First, the sample questions are input into the question-answering model. The model then performs reasoning to obtain the reasoned response for each sample question. Based on all the reasoned responses, a first reasoned response set is constructed, which includes multiple positive reasoned responses of different lengths and multiple negative reasoned responses of different lengths. Next, at least one first batch of reasoned responses is selected from the first batch of reasoned responses. Finally, the question-answering model is trained based on at least one first batch of reasoned responses.

[0119] During training, the training data consists of inference responses obtained by the question-answering model in response to sample questions, not manually selected data. This avoids the problem of poor accuracy caused by subjective factors influencing the training data. Furthermore, training with positive and negative inference responses of varying lengths allows the model to better identify positive responses, suppress negative responses, and understand and generate inference responses of diverse lengths. This enables the model to provide more diverse inference responses according to needs, allowing it to meet complex and varied requirements and be applied to multiple scenarios. Finally, training focuses solely on the question-answering model, without any model parameter fusion, thus avoiding the problem of poor accuracy caused by the influence of other models' parameters.

[0120] In this application, when selecting at least one batch of reasoning responses from the first set of reasoning responses, it is ensured that each batch of reasoning responses includes at least one positive reasoning response and at least one negative reasoning response. Furthermore, the content length of the positive reasoning responses in each batch is shorter than that of other positive reasoning responses in the first set excluding at least one batch; the content length of the negative reasoning responses in each batch is longer than that of other negative reasoning responses in the first set excluding at least one batch. Further limiting the content length of the selected reasoning responses allows the model to encourage concise and positive reasoning responses and suppress redundant and negative reasoning responses during training, thereby effectively controlling the content length of the reasoning responses output by the question-answering model. Moreover, the reasoning responses output during training are unaffected by prompts and reasoning end markers, ensuring the stability and accuracy of the question-answering model.

[0121] In addition, to prevent overfitting of the question-answering model during training, this application proposes a second batch of inference responses. The second batch of inference responses does not overlap with the first batch of inference responses, thereby increasing the diversity of training data.

[0122] In summary, the embodiments of this application employ an online reinforcement learning training method. During training, the inference responses output by the question-answering model for sample questions are recombined in real time. When optimizing the parameters of the question-answering model using these inference responses, the model encourages concise and positive inference responses and suppresses lengthy and negative ones, achieving more robust, efficient, and stable content length control. During training, the inference responses are divided into a first batch and a second batch, and trained sequentially, optimizing the gradient direction towards concise inference responses. Furthermore, the training process does not require human intervention in the model's inference process, resulting in smoother output from the question-answering model and ensuring accuracy; and the training process does not require prior collection of training data, improving training efficiency.

[0123] The preferred embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit this application. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.

[0124] See Figure 1 , Figure 1 This is a schematic diagram of an application scenario in an embodiment of this application. The application scenario diagram includes a terminal device 110 and a server 120.

[0125] In one alternative implementation, the terminal device 110 and the server 120 can communicate via a communication network. The communication network can be a wired network or a wireless network.

[0126] Therefore, terminal device 110 and server 120 can be connected directly or indirectly via wired or wireless communication. For example, terminal device 110 can be indirectly connected to server 120 via a wireless access point, or terminal device 110 can be directly connected to server 120 via the Internet; this application does not impose any restrictions on this.

[0127] In this embodiment, the terminal device 110 includes, but is not limited to, mobile phones, tablets, laptops, desktop computers, e-book readers, smart voice interaction devices, smart home appliances, in-vehicle terminals, and other devices. The terminal device may have a client related to question-and-answer functions installed. The client may be software, such as a browser with question-and-answer functions, a short video software with question-and-answer functions, an artificial intelligence (AI) tool with question-and-answer functions, or a webpage, a mini-program, etc.

[0128] In this embodiment, server 120 is a backend server corresponding to software, web pages, mini-programs, etc., or a server specifically used for question-and-answer functions; this application does not impose specific limitations. Server 120 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.

[0129] It should be noted that the training method of the question-answering model in each embodiment of this application can be executed by an electronic device, which can be a terminal device 110 or a server 120. That is, the method can be executed by the terminal device 110 or the server 120 alone, or by the terminal device 110 and the server 120 together.

[0130] For example, when executed jointly by terminal device 110 and server 120, the user can input a sample question through the client installed on terminal device 110. After receiving the input, server 120 first infers the sample question through the question-answering model to obtain a first inference response set. Then, based on the content length, it selects at least one first batch of inference responses from the first inference response set. Finally, based on at least one first batch of inference responses, it iteratively trains the question-answering model. When the question-answering model meets the training conditions, it stops training and deploys the trained question-answering model.

[0131] It should be noted that, Figure 1 The examples shown are merely illustrative; in reality, the number of terminal devices and servers is unlimited and is not specifically limited in the embodiments of this application.

[0132] In this embodiment of the application, when there are multiple servers, the multiple servers can form a blockchain, and the servers are nodes on the blockchain; as in the question-answering model training method disclosed in this embodiment of the application, the data involved can be stored on the blockchain, such as sample questions, inference responses, model parameters, etc.

[0133] Furthermore, the embodiments of this application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, medical, gaming, and education. Specifically, they can be applied to question-and-answer interaction-related application scenarios in these fields; a few examples are listed below:

[0134] (I) Intelligent transportation and assisted driving scenarios.

[0135] In intelligent transportation and driver assistance systems, question-answering models are widely used for tasks such as autonomous driving simulation, intelligent traffic management, and driving route prediction. See also Figure 2 , Figure 2 This is a schematic diagram illustrating a driving route planning method based on a question-answering model, as provided in an embodiment of this application. Figure 2 As shown, driving route planning is achieved by interacting with the server through in-vehicle devices (such as smart central control screens); among them, the question-answering model is the inference model used for route planning, and the question-answering model can be deployed on a backend server, with AI software corresponding to the backend server installed on the in-vehicle devices.

[0136] In this scenario, users can use AI software to input their desired destination, such as location A. The in-vehicle device then sends this input to the backend server. Upon receiving the input, the backend server combines it with real-time traffic information and uses a question-and-answer model to perform route planning. This generates at least one route planning diagram and inference information associated with the driving path in each diagram. The inference information includes estimated arrival time, congestion levels, driving distance, number of traffic lights, etc. The backend server then feeds back the route planning diagram and the corresponding inference information to the in-vehicle device, which then presents it to the user through the AI ​​software on the device.

[0137] When planning routes, users can input not only their destination but also other planning requirements to quickly obtain suitable routes. These requirements include, but are not limited to, travel time, travel distance, and the number of traffic lights along the route. When other planning requirements are included, the backend server can first plan routes based on the destination, then filter the planned routes based on the additional requirements to determine suitable route maps and corresponding route reasoning information. This information is then fed back to the in-vehicle device for presentation to the user via AI software.

[0138] (II) Medical Scenarios.

[0139] In the medical field, question-answering models are widely used in tasks such as surgical planning and case report analysis. For example, taking a question-answering model as an inference model for case report analysis, the scan results of computed tomography (CT) scans and magnetic resonance imaging (MRI) scans are input into the question-answering model. The model will perform inference analysis on the input scan results to determine the probability of the presence of a certain disease and provide corresponding inference steps so that medical staff can further determine whether a certain disease exists based on these inference steps.

[0140] (III) Game Scene.

[0141] In gaming scenarios, question-answering models are widely used for tasks such as game reasoning and analysis. Taking strategy games, such as Go, as an example, users can send the current game board image to the backend server via their terminal device. The backend server then infers the subsequent moves based on the current game board image, obtaining multiple reasoning responses. Each reasoning response includes: the response to the opponent under different opening situations, and the final result. The backend server then feeds back these multiple reasoning responses to the terminal device, which then presents them to the user.

[0142] The question-answering model provided in this application can be widely applied in various fields, such as intelligent computing, autonomous driving, healthcare, gaming, and education. By optimizing computational efficiency and inference speed, this application effectively reduces computational costs and improves the capabilities of the question-answering model, making it more efficient, convenient, and accurate for inference in various application scenarios.

[0143] It should be noted that the application scenarios listed above are just simple examples, and other application scenarios are also applicable to the embodiments of this application, which will not be elaborated here.

[0144] It should be emphasized that the specific embodiments of this application involve user-related data, such as sample questions input into the question-answering model during training. When the above embodiments of this application are applied to specific products or technologies, permission or consent from the target user is required, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.

[0145] Model training is a process of repeatedly training a model to be trained, which may include a model design phase and an iterative training phase. The following describes a training method for a question-answering model provided by an exemplary embodiment of this application, in conjunction with the application scenarios described above and with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of this application, and the embodiments of this application are not limited in any way in this respect.

[0146] Model design phase:

[0147] Question answering models can be large language models (LLMs), whose architectures are typically based on deep neural networks, especially models based on transformer architectures.

[0148] Taking a large language model based on Transformer as an example of a question-answering model, see [link / reference]. Figure 3 , Figure 3This is a schematic diagram of a question-answering model provided in an embodiment of this application. The question-answering model includes: an input embedding layer, a Transformer network layer, and an output layer; wherein:

[0149] Input embedding layer: Used to convert each word in the input sample question into a fixed-dimensional vector representation, i.e., a feature vector.

[0150] In one possible implementation, the input embedding layer also includes positional encoding to preserve the positional information of words in the input sample question.

[0151] Transformer network layer: also known as encoder-decoder structure layer, contains multiple encoders and decoders to encode and decode the input sample question to obtain at least one inference response corresponding to the input sample question.

[0152] In one possible implementation, multiple encoders are cascaded; however, this embodiment may employ only a single encoder layer. Figure 3 The encoder structure shown includes: a multi-attention layer, a feedforward layer, and a residual & normalization layer. The multi-attention layer is used to calculate the correlation between each position in the input feature vector and all other positions, allowing the model to focus on relevant information within the sample problem. The feedforward layer is used to apply the same linear transformation to each position, followed by increasing the expressive power through a non-linear activation function (such as ReLU). The residual & normalization layer helps to accelerate the training process and stabilize gradient propagation.

[0153] In one possible implementation, multiple decoders are cascaded; however, this embodiment may employ only a single-layer decoder structure. Figure 3 The decoder structure shown has an encoder-like structure, but it also includes a masked multi-head self-attention layer. The masked multi-head self-attention layer is used to prevent the current position from seeing future information and ensure that the prediction depends on the previous context.

[0154] Output layer: Used to output at least one inference response corresponding to the sample question.

[0155] It should be noted that the question-answering model in this application may include 3 to 12 layers of Transformer network.

[0156] Model training phase:

[0157] See Figure 4 , Figure 4A flowchart of a question-answering model training method provided in this application embodiment includes the following steps:

[0158] Step S41: Reason about the sample questions using the question-answering model to obtain the first reasoning response set. The first reasoning response set includes: multiple positive reasoning responses with different content lengths and multiple negative reasoning responses with different content lengths.

[0159] In this embodiment, during the training of the question-answering model, the model parameters of the question model are mainly adjusted in reverse based on the inference responses output by the question-answering model. Therefore, the training data used in the training process is selected from the first inference response set constructed based on the inference responses output by the question-answering model for sample questions. Furthermore, to ensure the accuracy of model training, the sample questions input to the question-answering model cannot be a single sample question; that is, there are multiple sample questions input to the question-answering model.

[0160] Since the purpose of training the question-answering model proposed in this application embodiment is to control the length of the content output by the question-answering model and ensure its accuracy, the training data selected from the first inference response set must at least include: a short positive inference response and a long negative inference response corresponding to a sample question. This encourages concise and positive inference responses and suppresses lengthy and negative inference responses during model training, thereby effectively controlling the length of the content output by the question-answering model. Based on the training data containing at least: a short positive inference response and a long negative inference response corresponding to a sample question, the first inference response set must at least include: multiple positive inference responses and multiple negative inference responses of different lengths corresponding to a sample question.

[0161] Considering that the reasoning responses output by the question-answering model for a sample question are diverse, and that these diverse responses include at least one of the following: multiple positive reasoning responses of varying lengths and multiple negative reasoning responses of varying lengths—that is, the reasoning responses output for a sample question can be all positive, all negative, or a combination of both—constructing a first reasoning response set based on the reasoning responses for all sample questions would lead to inaccurate training data selected from the first reasoning response set, thereby affecting the accuracy of the question-answering model training. Therefore, to ensure the accuracy of training data selection and thus the accuracy of model training, this application provides a method for constructing a first reasoning response set.

[0162] See Figure 5 , Figure 5 A schematic diagram illustrating the construction of a first inference response set provided in an embodiment of this application; from Figure 5 From this, we can know that:

[0163] After inputting multiple sample questions into the question answering model, the model performs reasoning for each sample question and outputs a subset of reasoned responses; the subset of reasoned responses contains multiple reasoned responses of different lengths.

[0164] For each sample question, the output of the reasoning response subset is judged separately. It is determined whether all reasoning responses in the reasoning response subset contain both positive and negative reasoning responses, and the corresponding judgment results are obtained.

[0165] Based on the judgment results, all reasoning response subsets are filtered to select the reasoning response subsets that contain both positive and negative reasoning responses;

[0166] Based on the filtered subset of reasoning responses, a first set of reasoning responses is constructed.

[0167] When determining a subset of inference responses, a pre-defined determination model or pre-defined determination rule can be used, based on a set inference response label. The inference response label can be a single result corresponding to the sample question, or it can be a reasoning step containing that single result. For example, if the sample question is a math problem, the single result can be the final answer to the math problem, and the reasoning step can be the solution steps for solving that math problem.

[0168] For example, the inference response label represents the inference step. When using a decision model for judgment, each inference response in the inference response subset is matched with its inference response label to obtain a similarity value. Based on the similarity value, it is determined whether the inference response is a positive or negative inference response. Based on the determination result of each inference response, the judgment result of the inference response subset is determined. For example, inference responses with a similarity value greater than or equal to 70% are considered positive inference responses, and inference responses with a similarity value less than 70% are considered negative inference responses.

[0169] For example, if the inference response label is a single result, when using a decision model for judgment, each inference response in the subset of inference responses is matched with the inference response label to obtain a matching result. The matching result indicates whether the result in the inference response is consistent with the inference response label. Based on the matching result, it is determined whether the inference response is a positive or negative inference response. Based on the determination result of each inference response, the judgment result of the inference response subset is determined. For example, inference responses whose results are consistent with the inference response label are positive inference responses, and those whose results are inconsistent are negative inference responses.

[0170] In one possible implementation, the judgment result can be represented by "0" and "1". When all inference responses are either positive or negative, the judgment result of the subset of inference responses is set to "0", which means that the subset of inference responses is filtered out. When all inference responses contain both positive and negative inference responses, the judgment result of the subset of inference responses is set to "1", which means that the subset of inference responses is selected.

[0171] When constructing the first inference response set based on the filtered inference response subset, a specified number of positive inference responses and a specified number of negative inference responses can be randomly selected from each filtered inference response subset.

[0172] It should be noted that, Figure 5 The example only uses the decision model, while the implementation of decision rules is similar to that based on the decision model, and will not be repeated here.

[0173] The above implementation method determines whether all inference responses corresponding to a sample question are either positive or negative by judging the subset of inference responses. Based on this judgment, all subsets of inference responses are filtered to select those containing both positive and negative inference responses. A first inference response set is then constructed based on this filtered subset, ensuring that it contains at least: multiple positive inference responses of varying lengths and multiple negative inference responses of varying lengths corresponding to a single sample question. This ensures the accuracy of selecting training data from the first inference response set and achieves accurate question-answering model training.

[0174] In this embodiment, the question-answering model can be an initial question-answering model or an intermediate question-answering model; wherein, the initial question-answering model is an initially constructed question-answering model that has not yet been trained, and the model accuracy is extremely low; the intermediate question-answering model can be derived from a variety of existing high-precision models, such as: (1) a pre-trained large language model. (2) a pre-trained model on a public dataset: a question-answering model obtained by pre-training on a public dataset. (3) a model optimized for a specific task: a model designed and optimized for a question-answering task in a specific application scenario.

[0175] It should be noted that the sources of the intermediate question-answering models listed above are just simple examples. Other question-answering models with question-answering capabilities are also applicable to the embodiments of this application, and will not be described in detail here.

[0176] After obtaining the first inference response set in step S41, training data will be selected from the first inference response set. See step S42 for details.

[0177] Step S42: Based on the content length, at least one first batch of reasoning responses is selected from the first reasoning response set. Each first batch of reasoning responses includes: at least one positive reasoning response and at least one negative reasoning response. The content length of the positive reasoning responses in each first batch of reasoning responses is less than that of other positive reasoning responses in the first reasoning response set except for at least one first batch of reasoning responses. The content length of the negative reasoning responses in each first batch of reasoning responses is greater than that of other negative reasoning responses in the first reasoning response set except for at least one first batch of reasoning responses.

[0178] To effectively control the content length of the question-answering model's output and ensure model performance, each batch of inference responses selected from the first inference response set for model training includes: at least one positive inference response and at least one negative inference response; and the content length of the positive inference response is less than that of other positive inference responses in the first inference response set excluding at least one batch of inference responses; the content length of the negative inference response is greater than that of other negative inference responses in the first inference response set excluding at least one batch of inference responses. In other words, when constructing at least one batch of inference responses, the content length of the first batch of inference responses must first meet the condition. Based on this, this application proposes a possible implementation method: based on the content length, select a set of positive inference responses and a set of negative inference responses from the first inference response set, and construct the first batch of inference responses based on the set of positive inference responses and the set of negative inference responses.

[0179] The following section details the process of selecting at least one initial set of reasoning responses from the first set of reasoning responses. See also... Figure 6 , Figure 6 A flowchart of a method for screening at least one batch of reasoning responses provided in this application embodiment includes the following steps:

[0180] Step S421: Select a set of positive inference responses with a content length less than the positive length threshold from the first inference response set, and select a set of negative inference responses with a content length greater than the negative length threshold from the first inference response set.

[0181] In one possible implementation, when selecting a set of positive inference responses and a set of negative inference responses from the first set of inference responses, each inference response is determined to be either a positive or negative inference response. If it is determined to be a positive inference response, its content length is compared with a positive length threshold. If it is less than the positive length threshold, the response is selected and used to construct at least one batch of inference responses; otherwise, it is not selected. Similarly, if it is determined to be a negative inference response, its content length is compared with a negative length threshold. If it is greater than the negative length threshold, the response is selected and used to construct at least one batch of inference responses; otherwise, it is not selected. The content length includes, but is not limited to, the number of words and the number of inference steps.

[0182] In another possible implementation, when selecting a set of positive reasoning responses and a set of negative reasoning responses from the first set of reasoning responses, all reasoning responses in the first set of reasoning responses are categorized, that is, the first set of reasoning responses is divided into a set of positive reasoning responses and a set of negative reasoning responses. Positive reasoning responses with a content length less than the positive length threshold are selected from the positive reasoning response set, and negative reasoning responses with a content length greater than the negative length threshold are selected from the negative reasoning response set. The content length includes, but is not limited to, the number of words and the reasoning steps.

[0183] In this embodiment, the forward length threshold is determined as follows:

[0184] Method 1: Based on the forward sorting sequence; the forward sorting sequence is the sequence obtained by sorting all forward inference responses in the first inference response set according to the content length from shortest to longest.

[0185] For example, after sorting all positive reasoning responses by content length from shortest to longest, the content length of the top percentage of positive reasoning responses is determined, and a positive length threshold is established based on this. For instance, if there are 10 positive reasoning responses, after sorting these 10 responses by content length from shortest to longest, the content length of the top 80% of positive reasoning responses is determined, and the content length of the positive reasoning responses matching this 80% threshold is used as the positive length threshold.

[0186] Another example involves sorting all positive reasoning responses by content length from shortest to longest, determining the content length of the top-Kth positive reasoning response, and using this positive length threshold as a basis. For instance, if there are 10 positive reasoning responses, after sorting them by content length from shortest to longest, the content length of the 6th positive reasoning response is determined, and this content length is used as the positive length threshold.

[0187] Method 2: Pre-set; for example, if the inference steps are pre-set to 4, then the forward length threshold is 4.

[0188] Method 3: Determined based on the length of all positive reasoning responses.

[0189] For example, the content length of all positive reasoning responses is determined, and all content lengths are weighted and summed. The weighted sum is used as the positive length threshold. For instance, if there are 10 positive reasoning responses and the total content length of the 10 positive reasoning responses is 60, then the positive length threshold is 6.

[0190] In this embodiment of the application, the negative length threshold is determined as follows:

[0191] Method 1: Based on the negative sorting sequence; the negative sorting sequence is: the sequence obtained by sorting all negative reasoning responses in the first reasoning response set from longest to shortest content length;

[0192] Method 2: Pre-set;

[0193] Method 3: Determined based on the length of all negative reasoning responses.

[0194] The above implementation method, by pre-setting or setting a length threshold based on the content length of the inference response, can ensure the accuracy of a set of positive inference responses and a set of negative inference responses, thereby ensuring the accuracy of the first batch of inference responses used during training and improving model performance.

[0195] It should be noted that the above method for determining the positive length threshold is only an example. Any method that can be used to determine the length threshold can be applied to this application, and will not be listed one by one here. The method for determining the negative length threshold can be found in the method for determining the positive length threshold, and will not be repeated here.

[0196] Step S422: According to the input order of multiple sample questions, sort all the reasoning responses in a set of positive reasoning responses and a set of negative reasoning responses to obtain the initial reasoning response sequence.

[0197] Step S423: Based on the quantity threshold set in batch training, the initial inference response sequence is divided into at least one first batch of inference responses; the number of inference responses in each first batch is consistent with the quantity threshold, and the inference responses of two first batches do not overlap.

[0198] In this embodiment of the application, when selecting at least one batch of reasoning responses from the first reasoning response set, the following steps can be taken: First, the first reasoning response set is divided into a positive reasoning response set and a negative reasoning response set; second, the positive reasoning responses in the positive reasoning response set are sorted in ascending order of content length to obtain a positive sorting sequence, and the negative reasoning responses in the negative reasoning response set are sorted in descending order of content length to obtain a negative sorting sequence. Whether each reasoning response in the first reasoning response set is a positive or negative reasoning response is determined by... Figure 5 The judgment model shown is determined during the judgment process, so it can be directly divided. Since the content length is the attribute information of the inference response itself, it can be directly sorted. Then, the top TOP-P positive inference responses are selected from the positive sorting sequence, and the top TOP-Q negative inference responses are selected from the negative sorting sequence. Next, according to the input order of multiple sample questions, the top TOP-P positive inference responses and the top TOP-Q negative inference responses are uniformly sorted to obtain the initial inference response sequence. Finally, based on the quantity threshold set by batch training, the initial inference response sequence is divided into at least one batch of inference responses. The number of inference responses in each batch is consistent with the quantity threshold, and the inference responses of two batches do not overlap. TOP-P and TOP-Q can be pre-set or determined according to proportions, for example, selecting the top 80% of positive inference responses and the top 80% of negative inference responses. For example, see [link to example]. Figure 7 , Figure 7 This is a schematic diagram illustrating the process of selecting at least one batch of inference responses from a first inference response set, as provided in an embodiment of this application.

[0199] The above implementation generates an initial inference response sequence through screening and sorting, and divides the first batch of inference responses based on a quantity threshold. This ensures that the inference responses within each batch are diverse and representative, while the non-overlapping inference responses from two batches ensures effective utilization of the inference responses and reduces redundancy. Furthermore, when training the model based on the first batch of inference responses, the efficiency and stability of model training can be improved, the ability to understand responses of different lengths can be enhanced, and a balanced distribution of training data can be guaranteed, which is beneficial for improving the model's generalization ability and convergence speed.

[0200] After obtaining at least one initial inference response, the question-answering model is trained based on at least one initial inference response, as detailed in step S43.

[0201] Step S43: Train the question-answering model based on at least one initial inference response.

[0202] In this embodiment, there are N first batches, where N is a positive integer greater than or equal to 1. When training the question-answering model based on the inference responses of at least one first batch, if N equals 1, the question-answering model is trained in one round, and the question-answering model is the model used when obtaining the first inference response set. If N is greater than or equal to 2, the question-answering model is trained in two rounds of iterative training, and except for the first round, the question-answering model trained in each round is the one obtained in the previous round of training. For example, using the inference responses of the first batch for the second round of training is to update the parameters of the question-answering model obtained by using the inference responses of the first batch for the first round of training.

[0203] Since the implementation method is consistent for each round of training, the following will take one round of iterative training as an example to explain in detail how to train the question answering model based on the first batch of inference responses.

[0204] See Figure 8 This is a schematic diagram illustrating a question-answering model training method based on the first batch of reasoning responses provided in this application embodiment; from Figure 8 The process involves several steps: First, a first batch of inference responses is randomly selected from N initial batches. Second, based on a reward model, a reward value is determined for each inference response within that first batch. This reward value represents the difference between the inference response and the label of the corresponding sample question's inference result. Next, all reward values ​​are normalized to obtain the advantage function, and an initial loss function is determined based on this advantage function. Finally, the current question-answering model is tuned based on the gradient of the initial loss function relative to the current question-answering model parameters. The gradient indicates the direction and rate of change of the initial loss function with respect to the question-answering model parameters. Generally, inference responses with a positive advantage function are encouraged, while those with a negative advantage function are penalized.

[0205] The above implementation method achieves efficient and stable parameter tuning by training the model using the first batch of inference responses. Randomly selecting the first batch of inference responses ensures training diversity. Constructing the loss function based on the advantage function obtained by normalizing the reward value improves the accuracy of gradient estimation. This gradient effectively guides the model optimization direction, improving the inference quality and stability of the question-answering model.

[0206] In this embodiment, the training method based on steps S41-S43 can effectively control the length of the content output by the question-answering model, and compared to the control method proposed in the background art, it can guarantee the model performance of the question-answering model. However, the training data used in the training method of steps S41-S43 does not cover the first inference response set, but uses a portion of the inference responses in the first inference response set for training, and the quality of the partial inference responses used for training is higher than that of the remaining inference responses in the first inference response set. If high-quality training data is used continuously for question-answering model training, overfitting will occur.

[0207] Therefore, in order to further improve the performance of the question-answering model by effectively controlling the length of the output content while preventing overfitting, the diversity of training data is increased. In this embodiment, after training the question-answering model based on at least one first batch of inference responses, the model is trained again based on at least one second batch of inference responses. Each second batch of inference responses is selected from a second inference response set, and each second batch includes at least one positive inference response and at least one negative inference response. The second inference response set includes at least the remaining inference responses in the first inference response set. That is, the second inference response set is determined based on the remaining inference responses in the first inference response set, which are the remaining responses after selecting at least one first batch of inference responses. The question-answering model trained based on the second batch of inference responses is obtained after training based on the first batch of inference responses.

[0208] In this embodiment of the application, since the question-answering model needs to be trained based on at least one second batch of inference responses, it is necessary to determine at least one second batch of inference responses.

[0209] In one possible implementation, a second inference response set is constructed based on the number of remaining inference responses in the first inference response set; at least one second batch of inference responses is selected from the second inference response set; each second batch of inference responses contains at least one positive inference response and at least one negative inference response for a sample question.

[0210] For example, based on the comparison between the number of remaining inference responses in the first inference response set and the batch-defined quantity threshold, it is determined how to construct a second inference response set, and then at least one second batch of inference responses is selected from the constructed inference response set.

[0211] The following section details the construction of the second inference response set and the selection of at least one second batch of inference responses from the second inference response set, based on different comparison results.

[0212] Scenario 1: The number of remaining inference responses in the first inference response set is not less than the batch set threshold.

[0213] If the number of remaining inference responses is not less than the batch threshold, it means that the remaining inference responses in the first inference response set can be used for at least one more question-answering model training, so that at least one second batch of inference responses can be selected from the remaining inference responses.

[0214] Therefore, in this embodiment of the application, if the number of remaining inference responses in the first inference response set is not less than the number threshold set for batch training, then the remaining inference responses are used as the second inference response set, and at least one second batch of inference responses is selected from the second inference response set.

[0215] In this case, since the remaining inference responses can still be used for at least one more question-answering model training, in this embodiment of the application, the selection of at least one second batch of inference responses can be performed under at least one of the following circumstances:

[0216] (1) Performed concurrently with screening at least one first batch of inference responses; (2) Performed after screening at least one first batch of inference responses and before training the model based on at least one first batch of inference responses; (3) Performed after training the model based on at least one first batch of inference responses and before training the model based on at least one second batch of inference responses.

[0217] The specific timing for selecting at least one second batch of reasoning responses can be set according to the actual situation, and no specific limit is set here.

[0218] Since at least one second batch of inference responses is selected from the remaining inference responses in the first batch of inference responses, and each second batch of inference responses contains at least one positive inference response and at least one negative inference response; therefore, the content length of the positive inference responses in each second batch of inference responses is greater than that of all positive inference responses in the first batch of inference responses; and the content length of the negative inference responses in each second batch of inference responses is less than that of all negative inference responses in the first batch of inference responses.

[0219] When selecting at least one second batch of reasoning responses from the second reasoning response set, the reasoning responses in the second reasoning response set are sorted according to the input order of multiple sample questions to obtain a compensated reasoning response sequence; based on the quantity threshold set by batch training, the compensated reasoning response sequence is divided into at least one second batch of reasoning responses; the number of reasoning responses in each second batch is consistent with the quantity threshold.

[0220] See Figure 9This is a schematic diagram illustrating the first method of constructing a second inference response set and filtering at least one second batch of inference responses provided in this application embodiment; from Figure 9 It can be seen that: when the number of remaining inference responses in the first inference response set is not less than the number threshold set by batch training, the remaining inference responses are used as the second inference response set; then, according to the input order of multiple sample questions, the positive and negative inference responses in the second inference response set are uniformly sorted to obtain the compensation inference response sequence; finally, based on the number threshold set by batch training, the compensation inference response sequence is divided into at least one second batch of inference responses; the number of inference responses in each second batch is consistent with the number threshold, and the inference responses in two second batches do not overlap.

[0221] In the above implementation, when dividing the remaining inference responses in the first inference response into at least one second batch of inference responses, the remaining inference responses ensure sufficient training data for subsequent compensation training of the question-answering model trained based on the inference responses of the first batch. By sorting and generating a compensation inference response sequence, and dividing the second batch of inference responses based on the quantity threshold set by the batch training, the number of inference responses in the second batch is consistent with that of the first batch. The second batch of inference responses includes at least one positive inference response and at least one negative inference response, ensuring that the second batch of inference responses can be used for one compensation training of the question-answering model. Furthermore, each second batch of inference responses is diverse and representative, thereby ensuring continuous optimization of the question-answering model during the compensation training process, enhancing the model's generalization ability and convergence effect.

[0222] Scenario 2: The number of remaining inference responses in the first inference response set is less than the batch-defined threshold.

[0223] If the number of remaining inference responses is less than the batch threshold, it means that the remaining inference responses in the first inference response set cannot be used for at least one question-answering model training. In other words, at least one second batch of inference responses cannot be selected from the remaining inference responses. At this time, the remaining inference responses are stored in the second inference response set. When the number of inference responses stored in the second inference response set is not less than the batch training threshold, at least one second batch of inference responses is selected from the second inference response set.

[0224] In this embodiment of the application, when the number of remaining inference responses in the first inference response set is not less than the number threshold set for batch training, the remaining inference responses are stored in the second inference response set; and other inference responses corresponding to other sample questions are stored in the second inference response set until the number of inference responses stored in the second inference response set is not less than the number threshold set for batch training, at least one second batch of inference responses is selected from the second inference response set.

[0225] In this case, since the remaining inference responses cannot be used for at least one question-answering model training, in this embodiment of the application, the selection of at least one second batch of inference responses can be performed under at least one of the following circumstances:

[0226] (1) After screening at least one first batch of inference responses, and before training the model based on at least one first batch of inference responses; (2) After training the model based on at least one first batch of inference responses, and before training the model based on at least one second batch of inference responses.

[0227] The specific timing for selecting at least one second batch of reasoning responses can be set according to the actual situation, and no specific limit is set here.

[0228] In one possible implementation, other sample questions can correspond to other inference responses as follows: (1) inference responses obtained after reasoning about other sample questions through a question-answering model; (2) inference responses obtained after reasoning about other sample questions through a question-answering model, and the remaining inference responses after selecting at least one first batch of inference responses from the other inference response set based on content length; (3) inference responses after filtering the inference responses obtained after reasoning about other sample questions through a question-answering model. The question-answering model used to reason about other sample questions can be a question-answering model trained based on the first batch of inference responses, or a question-answering model used when reasoning about sample questions.

[0229] When selecting at least one second batch of reasoning responses from the second reasoning response set, the reasoning responses in the second reasoning response set are sorted according to the input order of multiple sample questions to obtain a compensated reasoning response sequence; based on the quantity threshold set by batch training, the compensated reasoning response sequence is divided into at least one second batch of reasoning responses; the number of reasoning responses in each second batch is consistent with the quantity threshold.

[0230] Taking other sample questions as examples, this section explains how to construct a second set of inference responses and how to select at least one second batch of inference responses after training a question-answering model based on the first batch of inference responses. (See also...) Figure 10 This is a schematic diagram illustrating the second method of constructing a second inference response set and filtering at least one second batch of inference responses provided in this application embodiment; from Figure 10It can be seen that: when the number of remaining inference responses in the first inference response set is less than the number threshold set for batch training, the remaining inference responses are stored in the second inference response set. Additionally, other sample questions are input into the question-answering model trained based on the first batch of inference responses. The corresponding inference responses obtained by the question-answering model for other sample questions are stored in the second inference response set. It is then determined whether the number of inference responses in the second inference response set is less than the number threshold set for batch training. If it is less, the steps of inferring the sample questions through the question-answering model and storing the obtained inference responses in the second inference response set continue until the number of inference responses stored in the second inference response set is not less than the number threshold set for batch training. Then, according to the input order of multiple sample questions, the positive and negative inference responses in the second inference response set are uniformly sorted to obtain a compensation inference response sequence. Finally, based on the number threshold set for batch training, the compensation inference response sequence is divided into at least one second batch of inference responses. The number of inference responses in each second batch is consistent with the number threshold, and the inference responses in two second batches do not overlap.

[0231] In the above implementation, when the remaining inference responses are insufficient for a single compensation training, new inference responses are dynamically added to ensure sufficient training data for subsequent compensation training of the question-answering model obtained from the first batch of inference responses. This ensures training continuity and diversity. The compensation inference response sequence is generated by sorting, and the second batch of inference responses is divided based on the quantity threshold set in the batch training. This ensures that the number of inference responses in the second batch is consistent with the first batch, and that the second batch of inference responses contains at least one positive inference response and at least one negative inference response. This ensures that the second batch of inference responses can be used for a single compensation training of the question-answering model, and that each second batch of inference responses is diverse and representative. This, in turn, ensures continuous optimization of the question-answering model during the compensation training process, enhancing the model's generalization ability and convergence effect.

[0232] When selecting at least one second batch of reasoning responses from the second reasoning response set using the implementation methods described in Case 1 and Case 2 above, it is also possible to select responses from the second reasoning response set based on content length. For details, please refer to the implementation method of selecting at least one first batch of reasoning responses from the first reasoning response set based on content length. The principle is similar and will not be repeated here.

[0233] In this embodiment of the application, the second inference response set can be a cache queue, that is, the remaining inference responses are stored in the cache queue. When the number of inference responses stored in the cache queue is not less than the number threshold set for batch training, the inference responses stored in the cache queue are removed from the cache queue and used for the division of inference responses in at least one second batch, and model training is performed based on the inference responses in at least one second batch.

[0234] Considering that the second inference response set may satisfy the condition of at least one second batch of inference responses multiple times, if at least one second batch of inference responses is performed each time the condition is met, and the model is trained based on at least one second batch of inference responses, the number of model training sessions will increase. Furthermore, training the model based on at least one second batch of inference responses is equivalent to compensating for the question-answering model trained based on the first batch of inference responses. Increasing the number of model compensation training sessions will reduce the model training efficiency.

[0235] Therefore, this application provides a training method based on course learning, which dynamically adjusts the compensatory training probability of training the question-answering model based on at least one second batch of inference responses, so as to determine whether to train the question-answering model based on at least one second batch of inference responses based on the compensatory training probability, thereby reducing the number of times the question-answering model is trained based on at least one second batch of inference responses and improving the model training efficiency.

[0236] In one possible implementation, after selecting at least one second batch of reasoning responses from the second inference response set, it is further determined whether to use at least one second batch of reasoning responses for model training based on the current state information of the question-answering model. If it is determined to train the model, then the model is trained based on at least one second batch of reasoning responses; otherwise, the at least one second batch of reasoning responses is discarded, that is, at least one second batch of reasoning responses is not used for model training.

[0237] See Figure 11 , Figure 11 A flowchart of a method for identifying training based on at least one second batch of inference responses provided in this application includes the following steps:

[0238] Step S111: Identify the current state information of the question-answering model; wherein, the state information includes at least one of the following: number of training iterations, model accuracy;

[0239] Step S112: Determine the current compensation training probability based on the state information; wherein the compensation training probability is negatively correlated with the state information.

[0240] Step S113: Based on the compensation training probability, determine whether to train the question answering model based on at least one second batch of reasoning responses. If yes, proceed to step S114; otherwise, proceed to step S115.

[0241] Then, based on the compensated training probability, it is determined whether to train the question answering model based on at least one second batch of inference responses. When training the question answering model, the compensated training probability can be compared with the preset training probability. When the compensated training probability is greater than the preset training probability, it is determined that the question answering model needs to be trained based on at least one second batch of inference responses; otherwise, it is not necessary to train the question answering model based on at least one second batch of inference responses.

[0242] S114, Train the question-answering model based on at least one second batch of reasoning responses;

[0243] S115, discard at least one second batch of reasoning responses.

[0244] Generally, in the early stages of training, the second batch of inference responses is rarely discarded to ensure that the reward function grows steadily; in the later stages of training, the reward function approaches saturation, increasing the probability that the second batch of inference responses will be discarded.

[0245] In this embodiment, the second batch has M items, where M is a positive integer greater than or equal to 1. When training the question-answering model based on at least one inference response from the second batch, if M equals 1, the question-answering model is trained once, and the question-answering model is obtained based on the inference responses from the first batch. If M is greater than or equal to 2, the question-answering model is trained in two rounds of iterative training, and except for the first round, the question-answering model trained in each round is obtained from the previous round of training. For example, using the inference responses from the second batch for the second round of training is equivalent to updating the parameters of the question-answering model obtained from the first round of training using the inference responses from the second batch.

[0246] Since the implementation method is the same for each round of training, the following will take one round of iterative training as an example to explain in detail how to train the question answering model based on the reasoning responses of the second batch.

[0247] See Figure 12 , Figure 12 A flowchart of a method for model training based on a second batch of inference responses, provided for embodiments of this application, includes the following steps:

[0248] Step S121: Select one second batch of reasoning responses from the M second batch of reasoning responses.

[0249] Optionally, a second batch of reasoning responses can be randomly selected from the M second batch of reasoning responses.

[0250] Step S122: Determine the compensation loss function based on the difference between each inference response in a second batch of inference responses and the inference result label of the corresponding sample question.

[0251] In one possible implementation, based on a reward model, a reward value is determined for each inference response in a second batch of inference responses. The reward value is used to characterize the difference information between the inference response and the inference result label of the corresponding sample question. All reward values ​​are normalized to obtain an advantage function, and a compensation loss function is determined based on the advantage function.

[0252] Step S123: Based on the compensation loss function, adjust the parameters of the current question-answering model.

[0253] In one possible implementation, the current question-answering model is tuned based on the gradient of the compensation loss function relative to the current question-answering model parameters; where the gradient is used to indicate the direction and rate of change of the compensation loss function with respect to the question-answering model parameters.

[0254] Generally, inference responses with a positive dominance function will be encouraged, while inference responses with a negative dominance function will be penalized.

[0255] The above implementation method, by training the model using a second batch of inference responses, achieves efficient and stable parameter tuning while preventing model overfitting. Randomly selecting the second batch of inference responses ensures training diversity. Constructing the loss function based on the advantage function obtained by normalizing the reward value improves the accuracy of gradient estimation, thereby effectively guiding the model optimization direction based on the gradient and improving the inference quality and stability of the question-answering model.

[0256] In this embodiment of the application, when training the question-answering model, the model is trained multiple times based on the first batch of reasoning responses and the second batch of reasoning responses until the stopping condition for the model to stop iterative updates is met.

[0257] In this application embodiment, the stopping conditions for model to stop iterative updates include, but are not limited to, some or all of the following:

[0258] (1) Reaching the preset maximum number of iterations: Set a maximum number of training rounds to prevent overfitting. (2) Loss value convergence or meeting the preset error range: When the overall loss value changes very little over several consecutive iterations, it indicates that the model has converged. When the overall loss value is below the preset threshold, it meets the preset error range. This ensures that the model achieves the expected accuracy and stability. (3) Validation set performance no longer improves: The error or accuracy on the validation set does not improve over several consecutive iterations to avoid overtraining. (4) Early stopping mechanism triggered: By monitoring the performance of the validation set, training is terminated early to obtain the best model state.

[0259] The aforementioned stopping conditions help ensure that the model is neither overtrained nor underfitted, thereby achieving optimal output performance. It should also be noted that these stopping conditions are merely examples; other stopping conditions also apply to the embodiments of this application, and will not be elaborated upon here.

[0260] See Figure 13 , Figure 13 This is a schematic diagram illustrating how a question-answering model is trained based on the first batch of inference responses and the second batch of inference responses, as provided in an embodiment of this application. Figure 13 Taking the case where the number of remaining inference responses in the first inference response set is less than the threshold set for batch training as an example, from Figure 13 From this, we can know that:

[0261] After inputting multiple sample questions into the question answering model, the model performs reasoning for each sample question and outputs a subset of reasoned responses; the subset of reasoned responses contains multiple reasoned responses of different lengths.

[0262] Filter all subsets of reasoning responses and construct the first set of reasoning responses based on the filtered subsets.

[0263] Based on the content length, at least one first batch of reasoning responses is selected from the first set of reasoning responses;

[0264] The remaining inference responses and other inference responses will be stored in the second inference response set. At least one second batch of inference responses will be selected from the second inference response set. The other inference responses are obtained by inferring other sample questions through the question-answering model trained based on the first batch of inference responses.

[0265] The question-answering model is trained to high optimization based on at least one initial inference response;

[0266] Based on at least one second batch of inference responses, the question-answering model trained based on the first batch of inference responses is compensated and trained.

[0267] In this embodiment, at least one batch of inference responses is constructed by recombining the selected positive and negative inference responses. The content length of the selected positive inference responses is shorter than that of other positive inference responses in the first batch, and the content length of the selected negative inference responses is longer than that of other negative inference responses in the first batch. Therefore, when training the model using the first batch of inference responses, the gradient direction is optimized, encouraging concise and positive inference responses and suppressing lengthy and negative inference responses. This achieves more robust and efficient control of the content length of the inference responses and provides better stability for model training. Simultaneously, a second batch of inference responses, in addition to the first batch, is used for model training to increase the diversity of training data, prevent overfitting, and effectively control the content length of the model output.

[0268] Furthermore, the training process does not require human intervention in the question-answering model's reasoning process, resulting in more stable and accurate output, thus ensuring model performance. Also, the training process does not require pre-collection of training data; instead, it uses the reasoning responses generated by the question-answering model based on sample questions for training, improving the efficiency and accuracy of the training method. In user experiments, on question-answering models of different sizes (such as two models of 1.5B and 7B respectively), the content length can be reduced by at least 50% without significantly affecting performance.

[0269] Based on the same inventive concept, embodiments of this application also provide a training device for a question-answering model. See also Figure 14 , Figure 14 This is a schematic diagram of the structure of the training device 1400 for the question-answering model, which may include:

[0270] Unit 1401 is used to reason about sample questions through a question-answering model to obtain a first reasoning response set. The first reasoning response set includes: multiple positive reasoning responses with different content lengths and multiple negative reasoning responses with different content lengths.

[0271] The filtering unit 1402 is used to filter at least one batch of reasoning responses from the first reasoning response set based on the content length, wherein each batch of reasoning responses includes at least one positive reasoning response and at least one negative reasoning response;

[0272] In each first batch of reasoning responses, the length of the positive reasoning responses is less than that of the other positive reasoning responses in the first reasoning response set, excluding at least one first batch of reasoning responses.

[0273] The length of the negative reasoning responses in each first batch of reasoning responses is greater than that of the other negative reasoning responses in the first batch of reasoning responses, excluding at least one first batch of reasoning responses.

[0274] Training unit 1403 is used to train the question-answering model based on at least one first batch of inference responses.

[0275] In one possible implementation, there are multiple sample questions; the first inference response set includes: multiple positive inference responses of different content lengths and multiple negative inference responses of different content lengths corresponding to each sample question; the filtering unit 1402 is specifically used for:

[0276] Select a set of positive reasoning responses whose content length is less than the positive length threshold from the first set of reasoning responses, and select a set of negative reasoning responses whose content length is greater than the negative length threshold from the first set of reasoning responses;

[0277] Based on the input order of multiple sample questions, a set of positive reasoning responses and a set of negative reasoning responses are selected and divided into at least one first batch of reasoning responses.

[0278] In one possible implementation, the filtering unit 1402 is specifically used for:

[0279] Based on the input order of multiple sample questions, all reasoning responses in a set of positive reasoning responses and a set of negative reasoning responses are uniformly sorted to obtain an initial reasoning response sequence;

[0280] Based on the quantity threshold set for batch training, the initial inference response sequence is divided into at least one batch of inference responses; the number of inference responses in each batch is consistent with the quantity threshold.

[0281] In one possible implementation, the forward length threshold is determined as follows:

[0282] Pre-defined; or, defined based on a forward sorting sequence; the forward sorting sequence is: a sequence obtained by sorting all forward inference responses in the first inference response set according to their content length from shortest to longest;

[0283] The negative length threshold is determined as follows:

[0284] Pre-defined; or, based on a negative sorting sequence; the negative sorting sequence is: a sequence obtained by sorting all negative reasoning responses in the first reasoning response set according to their content length from longest to shortest.

[0285] In one possible implementation, the first batch has N elements, where N is a positive integer greater than 1; training unit 1403 is specifically used for:

[0286] Based on N initial inference responses, the question-answering model undergoes N rounds of iterative training; where each round of iterative training involves:

[0287] Select one first batch of reasoning responses from N first batches of reasoning responses;

[0288] The initial loss function is determined based on the difference between each inference response in a first batch of inference responses and the inference result label of the corresponding sample question;

[0289] Based on the initial loss function, the parameters of the current question answering model are tuned.

[0290] In one possible implementation, the filtering unit 1402 is further configured to: filter at least one second batch of inference responses from the second inference response set, each second batch of inference responses comprising: at least one positive inference response and at least one negative inference response; the second inference response set comprises at least: the remaining inference responses in the first inference response set; wherein the remaining inference responses are those remaining in the first inference response set after filtering at least one first batch of inference responses;

[0291] The training unit 1403 is also used to: train the question answering model based on at least one second batch of inference responses after training the question answering model based on at least one first batch of inference responses.

[0292] In one possible implementation, the filtering unit 1402 is specifically used for:

[0293] If the number of remaining inference responses in the first inference response set is not less than the number threshold set for batch training, then the remaining inference responses are used as the second inference response set, and at least one inference response for the second batch is selected from the second inference response set.

[0294] Among them, the length of the positive reasoning response in each second batch of reasoning responses is greater than the length of the positive reasoning responses in all first batches of reasoning responses;

[0295] The length of the negative reasoning responses in each second batch of reasoning responses is shorter than the length of the negative reasoning responses in all first batches of reasoning responses.

[0296] In one possible implementation, the filtering unit 1402 is specifically used for:

[0297] If the number of remaining inference responses in the first inference response set is less than the number threshold set for batch training, then the remaining inference responses are stored in the second inference response set.

[0298] Store other inference responses corresponding to other sample questions into a second inference response set until the number of inference responses stored in the second inference response set is not less than the number threshold set for batch training. Then, select at least one second batch of inference responses from the second inference response set.

[0299] In one possible implementation, there are multiple sample problems; the screening unit 1402 is specifically used for:

[0300] Based on the input order of multiple sample questions, the reasoning responses in the second reasoning response set are sorted to obtain the compensated reasoning response sequence;

[0301] Based on the quantity threshold set for batch training, the compensated inference response sequence is divided into at least one second batch of inference responses; the number of inference responses in each second batch is consistent with the quantity threshold.

[0302] In one possible implementation, after selecting at least one second batch of reasoning responses from the second set of reasoning responses, and before training the question-answering model based on at least one second batch of reasoning responses, the selection unit 1402 is further configured to:

[0303] Identify the current state information of the question-answering model; wherein, the state information includes at least one of the following: number of training iterations, model accuracy;

[0304] Based on state information, the question-answering model is trained based on at least one second batch of reasoning responses.

[0305] In one possible implementation, the filtering unit 1402 is specifically used for:

[0306] Based on the state information, determine the current compensatory training probability;

[0307] Based on the compensation training probability, determine the training of the question answering model based on at least one second batch of inference responses;

[0308] Among them, the probability of compensation training is negatively correlated with state information.

[0309] In one possible implementation, at least one second batch has M units, where M is a positive integer greater than 1; training unit 1403 is specifically used for:

[0310] Based on M second-batch inference responses, the question-answering model is trained through M rounds of iterations; where each round of iterations involves:

[0311] Select one second-batch reasoning response from M second-batch reasoning responses;

[0312] The compensation loss function is determined based on the difference between each inference response in a second batch of inference responses and the inference result label of the corresponding sample question.

[0313] Based on the compensation loss function, the parameters of the current question answering model are tuned.

[0314] This application optimizes the gradient direction in reinforcement learning by recombining inference responses. During training, the vast majority of batches encourage concise and positive inference responses while suppressing lengthy and negative ones, effectively controlling the length of inference responses in the question-answering model. Furthermore, the training process does not require human intervention in the inference process, resulting in more stable and accurate output, thus ensuring model performance. Additionally, training does not require pre-collection of training data; instead, it uses the inference responses generated by the question-answering model based on sample questions for training, improving the efficiency and accuracy of the training method.

[0315] In summary, this application can improve the performance of the question-answering model while ensuring effective control over the length of the output content.

[0316] For ease of description, the above sections are divided into modules (or units) according to their functions and described separately. Of course, in implementing this application, the functions of each module (or unit) can be implemented in one or more software or hardware components.

[0317] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0318] Having introduced the training method and apparatus for the question-answering model according to an exemplary embodiment of this application, the electronic device according to another exemplary embodiment of this application will now be described.

[0319] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."

[0320] Based on the same inventive concept as the above-described method embodiments, this application also provides an electronic device. In one embodiment, the electronic device may be a server, such as... Figure 1 The server 120 is shown. In this embodiment, the structure of the electronic device can be as follows: Figure 15 As shown, it includes a memory 1501, a communication module 1503, and one or more processors 1502.

[0321] The memory 1501 is used to store computer programs executed by the processor 1502. The memory 1501 may mainly include a program storage area and a data storage area. The program storage area may store the operating system and programs required to run instant messaging functions, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.

[0322] Memory 1501 may be volatile memory, such as random-access memory (RAM); memory 1501 may also be non-volatile memory, such as read-only memory, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or memory 1501 may be any other medium capable of carrying or storing a desired computer program having the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 1501 may be a combination of the above-described memories.

[0323] The processor 1502 may include one or more central processing units (CPUs) or digital processing units, etc. The processor 1502 is used to implement the aforementioned training method for the 3D restoration model or the 3D mesh reconstruction method when calling the computer program stored in the memory 1501.

[0324] The communication module 1503 is used to communicate with terminal devices and other servers.

[0325] This application embodiment does not limit the specific connection medium between the memory 1501, communication module 1503, and processor 1502. This application embodiment... Figure 15 The memory 1501 and the processor 1502 are connected via a bus 1504, and the bus 1504 is in Figure 15 The diagram uses thick lines to describe the connections between other components; these are for illustrative purposes only and should not be considered limiting. The 1504 bus can be divided into address bus, data bus, control bus, etc. For ease of description, Figure 15It is described using only a thick line, but does not indicate that there is only one bus or one type of bus.

[0326] In some possible implementations, memory 1501 stores a computer storage medium containing computer-executable instructions for implementing the steps of the training methods for the various question-answering models in the embodiments of this application. Processor 1502 is used to execute the training methods for the various question-answering models described above.

[0327] In some possible implementations, various aspects of the question-answering model training method provided in this application can also be implemented in the form of a program product, which includes a computer program that, when the program product is run on an electronic device, causes the electronic device to perform the steps in the question-answering model training method according to various exemplary embodiments of this application described above.

[0328] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0329] The program product of the embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include a computer program, and may run on an electronic device. However, the program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with a command execution system, apparatus, or device.

[0330] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a readable computer program. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with a command execution system, apparatus, or device.

[0331] Computer programs contained on readable media may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0332] Computer programs for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The computer program can execute entirely on the user's electronic device, partially on the user's electronic device, as a standalone software package, partially on the user's electronic device and partially on a remote electronic device, or entirely on a remote electronic device or server. In cases involving remote electronic devices, the remote electronic device can be connected to the user's electronic device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external electronic device (e.g., via the Internet using an Internet service provider).

[0333] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.

[0334] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0335] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A training method for a question-answering model, characterized in that, The method includes: The question-answering model is used to reason about the sample questions to obtain the first reasoning response set, which includes: multiple positive reasoning responses with different content lengths and multiple negative reasoning responses with different content lengths; Based on the content length, at least one first batch of reasoning responses is selected from the first reasoning response set, and each first batch of reasoning responses includes: at least one positive reasoning response and at least one negative reasoning response; Wherein, the length of the positive reasoning response in each of the first batch of reasoning responses is less than that of the other positive reasoning responses in the first reasoning response set, excluding the at least one first batch of reasoning responses; The length of the negative reasoning response in each of the first batches of reasoning responses is greater than that of the other negative reasoning responses in the first batch of reasoning responses, excluding the at least one first batch of reasoning responses. The question-answering model is trained based on the at least one first batch of reasoning responses.

2. The method as described in claim 1, characterized in that, The sample questions are multiple; the first reasoning response set includes: multiple positive reasoning responses of different content lengths and multiple negative reasoning responses of different content lengths corresponding to each sample question; The step of selecting at least one batch of reasoning responses from the first reasoning response set based on the content length includes: Select a set of positive inference responses with a content length less than the positive length threshold from the first inference response set, and select a set of negative inference responses with a content length greater than the negative length threshold from the first inference response set; Based on the input order of multiple sample questions, a set of positive reasoning responses and a set of negative reasoning responses are selected and divided into at least one first batch of reasoning responses.

3. The method as described in claim 2, characterized in that, The process involves dividing a set of positive reasoning responses and a set of negative reasoning responses, selected according to the input order of multiple sample questions, into at least one first batch of reasoning responses, including: Based on the input order of multiple sample questions, all reasoning responses in the set of positive reasoning responses and the set of negative reasoning responses are uniformly sorted to obtain an initial reasoning response sequence; Based on the quantity threshold set for batch training, the initial inference response sequence is divided into at least one first batch of inference responses; the number of inference responses in each first batch is consistent with the quantity threshold.

4. The method as described in claim 2, characterized in that, The positive length threshold is determined as follows: Pre-set; or, set based on a forward sorting sequence; the forward sorting sequence is: a sequence obtained by sorting all forward inference responses in the first inference response set according to their content length from shortest to longest; The negative length threshold is determined as follows: Pre-set; or, set based on a negative sorting sequence; the negative sorting sequence is: a sequence obtained by sorting all negative reasoning responses in the first reasoning response set according to their content length from longest to shortest.

5. The method as described in claim 1, characterized in that, The first batch has N items, where N is a positive integer greater than 1; the step of training the question-answering model based on the reasoning responses of at least one first batch includes: Based on N initial inference responses, the question-answering model is trained through N rounds of iterative training; wherein, in each round of iterative training: Select one first batch of reasoning responses from the N first batch of reasoning responses; The initial loss function is determined based on the difference between each inference response in the first batch and the inference result label of the corresponding sample question; Based on the initial loss function, the parameters of the current question-answering model are tuned.

6. The method according to any one of claims 1 to 5, characterized in that, The method further includes: At least one second batch of reasoning responses is selected from the second reasoning response set, and each second batch of reasoning responses includes at least one positive reasoning response and at least one negative reasoning response; the second reasoning response set includes at least the remaining reasoning responses from the first reasoning response set; wherein the remaining reasoning responses are those remaining in the first reasoning response set after at least one first batch of reasoning responses has been selected. After training the question-answering model based on the at least one batch of reasoning responses, the method further includes: The question-answering model is trained based on the reasoning responses from at least one second batch.

7. The method as described in claim 6, characterized in that, The step of selecting at least one second batch of reasoning responses from the second reasoning response set includes: If the number of remaining inference responses in the first inference response set is not less than the number threshold set for batch training, then the remaining inference responses are used as the second inference response set, and at least one second batch of inference responses is selected from the second inference response set. In particular, the length of the positive reasoning response in each second batch of reasoning responses is greater than the length of the positive reasoning responses in all first batches of reasoning responses; The length of the negative reasoning responses in each second batch of reasoning responses is shorter than the length of the negative reasoning responses in all first batches of reasoning responses.

8. The method as described in claim 6, characterized in that, The step of selecting at least one second batch of reasoning responses from the second reasoning response set includes: If the number of remaining inference responses in the first inference response set is less than the number threshold set for batch training, then the remaining inference responses are stored in the second inference response set. Other inference responses corresponding to other sample questions are stored in the second inference response set until the number of inference responses stored in the second inference response set is not less than the number threshold set for batch training. At least one second batch of inference responses is then selected from the second inference response set.

9. The method as described in claim 7 or 8, characterized in that, The sample questions are multiple; the step of selecting at least one second batch of reasoning responses from the second reasoning response set includes: Based on the input order of multiple sample questions, the reasoning responses in the second reasoning response set are sorted to obtain the compensated reasoning response sequence; Based on the quantity threshold set in the batch training, the compensated inference response sequence is divided into at least one second batch of inference responses; the number of inference responses in each second batch is consistent with the quantity threshold.

10. The method as described in claim 6, characterized in that, After selecting at least one second batch of reasoning responses from the second reasoning response set, and before training the question-answering model based on the at least one second batch of reasoning responses, the method further includes: Identify the current state information of the question-answering model; wherein the state information includes at least one of the following: number of training iterations, model accuracy; Based on the state information, the question-answering model is trained based on the reasoning responses of at least one second batch.

11. The method as described in claim 10, characterized in that, The step of determining the reasoning responses based on the at least one second batch based on the state information and training the question-answering model includes: Based on the state information, determine the current compensatory training probability; Based on the compensation training probability, the question answering model is trained based on the reasoning responses of at least one second batch. The compensation training probability is negatively correlated with the state information.

12. The method as described in claim 6, characterized in that, The at least one second batch has M items, where M is a positive integer greater than 1; the training of the question-answering model based on the inference responses of the at least one second batch includes: Based on M second-batch inference responses, the question-answering model is trained through M rounds of iterations; wherein, in each round of iterations: Select one second batch of reasoning responses from the M second batches; Based on the difference between each inference response in the second batch of inference responses and the inference result label of the corresponding sample question, a compensation loss function is determined; Based on the aforementioned compensation loss function, the parameters of the current question-answering model are tuned.

13. A training device for a question-answering model, characterized in that, The device includes: The obtaining unit is used to reason about the sample question through the question-answering model to obtain a first reasoning response set, which includes: multiple positive reasoning responses with different content lengths and multiple negative reasoning responses with different content lengths; A filtering unit is configured to filter at least one batch of reasoning responses from the first reasoning response set based on the content length, wherein each first batch of reasoning responses includes at least one positive reasoning response and at least one negative reasoning response; Wherein, the length of the positive reasoning response in each of the first batch of reasoning responses is less than that of the other positive reasoning responses in the first reasoning response set, excluding the at least one first batch of reasoning responses; The length of the negative reasoning response in each of the first batches of reasoning responses is greater than that of the other negative reasoning responses in the first batch of reasoning responses, excluding the at least one first batch of reasoning responses. A training unit is used to train the question-answering model based on the at least one first batch of reasoning responses.

14. An electronic device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the steps of any of the methods described in claims 1 to 12.

15. A computer-readable storage medium, characterized in that, It includes a computer program that, when run on an electronic device, causes the electronic device to perform the steps of any of the methods described in claims 1 to 12.

16. A computer program product, characterized in that, The method includes a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the steps of any one of claims 1 to 12.