Distillation method and device of dialogue model, equipment, storage medium and program product
By updating the student model training samples with soft labels generated by the teacher model during the knowledge distillation process, and combining the token entropy dynamic threshold and loss function value for iterative training, the problem of error accumulation in the student model is solved, the reliability and logical coherence of the generated content are improved, and the computational overhead and training resource consumption are reduced.
Patent Information
- Application Number
- CN202611234313.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-14
- Publication Date
- 2026-11-20
AI Technical Summary
In existing technologies, student models suffer from error accumulation during knowledge distillation, resulting in poor distillation performance. How to avoid error accumulation and improve the performance of student models is a technical problem that urgently needs to be solved.
By acquiring initial dialogue training samples, the teacher model generates soft labels and updates the training samples of the student model. The token entropy dynamic threshold is used to determine the credibility of the predicted tokens. Iterative training is then performed in combination with the loss function value until the stopping condition is met, thereby optimizing the student model.
It effectively avoids the accumulation of errors, improves the reliability and logical coherence of the generated content of the student model, reduces the computational overhead during training, optimizes the overall training resource consumption, and obtains a student model with high-quality dialogue generation capabilities.
Smart Images

Figure CN123140147A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of artificial intelligence technology, and in particular relates to a distillation method, apparatus, device, storage medium and program product for a dialogue model. Background Technology
[0002] Knowledge distillation in neural networks actually involves the teacher model generating a complete classification probability distribution (i.e., soft labels), while the student model uses soft labels instead of real labels during training to approximate the distribution of the teacher model.
[0003] In online distillation, the student model generates its own outputs (SGOs) during distillation and performs further inference based on these outputs. Simultaneously, the teacher model takes the student outputs as input and provides its own distribution as a supervisory signal, serving as feedback to correct the student model's inference. However, this process can lead to error accumulation, resulting in poor distillation performance for the student model.
[0004] Therefore, how to avoid error accumulation and thus improve the performance of student models is a technical problem that urgently needs to be solved in this field. Summary of the Invention
[0005] This application provides a distillation method, apparatus, device, storage medium, and program product for a dialogue model, which can improve the performance of student models.
[0006] In a first aspect, embodiments of this application provide a distillation method for a dialogue model, comprising: acquiring an initial dialogue training sample and inputting the initial dialogue training sample into a teacher model, performing token prediction on the initial dialogue training sample through the teacher model to obtain a response soft label; inputting the initial dialogue training sample into a student model, performing token prediction on the initial dialogue training sample to obtain a predicted token and the token entropy corresponding to the predicted token; if it is determined that the token entropy does not meet a dynamic entropy threshold, updating the initial dialogue training sample based on the response soft label fragment and the initial dialogue training sample, and returning to the step of inputting the initial dialogue training sample into the student model, performing token prediction on the dialogue training sample to obtain a predicted token and the token entropy corresponding to the predicted token, until a predicted dialogue response is obtained, wherein the response soft label fragment is determined based on the position of the predicted token that does not meet the dynamic entropy threshold among multiple predicted tokens generated by the student model; calculating a loss function value based on the predicted token output by the student model and the response soft label; if it is determined that the loss function value does not meet a stopping condition, returning to the step of inputting the initial dialogue training sample into the teacher model, performing token prediction on the initial dialogue training sample through the teacher model to obtain a response soft label, until the loss function value meets the stopping condition, thereby obtaining a trained student model.
[0007] In one implementation, after inputting the initial dialogue training sample into the student model, and the student model performs token prediction based on the dialogue training sample to obtain the predicted token and the token entropy corresponding to the predicted token, the method further includes: if it is determined that the token entropy meets the dynamic entropy threshold, updating the initial dialogue training sample based on the predicted token and the dialogue training sample to obtain the updated initial dialogue sample, and returning to the step of inputting the initial dialogue training sample into the student model, and the student model performing token prediction based on the dialogue training sample to obtain the predicted token and the token entropy corresponding to the predicted token, until the predicted dialogue response is obtained.
[0008] In one implementation, before updating the initial dialogue training samples based on the response soft-label fragments and the initial dialogue training samples when it is determined that the token entropy does not meet the dynamic entropy threshold, the method further includes: determining a target entropy quantile factor based on the number of training steps corresponding to the student model, the total number of training steps, a preset scaling factor, and the initial entropy quantile factor; truncating multiple token entropies output by the student model according to the entropy value sliding window to obtain multiple candidate token entropies; and determining the dynamic entropy threshold from the multiple candidate token entropies based on the target entropy quantile factor.
[0009] In one implementation, the target entropy quantile factor is calculated using the following formula (1):
[0010] in, The initial entropy quantile factor; To train step count, The total number of training steps is, This is the preset scaling factor.
[0011] In one embodiment, determining a dynamic entropy threshold from multiple candidate token entropies based on a target entropy quantile factor includes: sequentially arranging the multiple candidate token entropies to obtain a candidate token entropy sequence; determining the target quantile position in the candidate token entropy sequence based on the target entropy quantile factor; and using the candidate token entropy at the target quantile position as the dynamic entropy threshold.
[0012] In one implementation, updating the initial dialogue training sample based on the response soft label fragment and the initial dialogue training sample includes: determining the target position of the target token among multiple predicted tokens generated by the student model, wherein the target token is a predicted token that does not meet the dynamic entropy threshold; extracting one or more tokens up to the target position from the token sequence corresponding to the response soft label as the response soft label fragment; and updating the initial dialogue training sample based on the response soft label fragment and the initial dialogue training sample.
[0013] In one embodiment, after determining the position of the target token among multiple tokens generated by the student model, the method further includes: storing token fragments, the token fragments including the target token and historical tokens generated before the target token; calculating loss function values based on the predicted tokens output by the student model and the response soft tags, including: for each token fragment, calculating the fragment loss function value between the token fragment and the response soft tag fragment according to a preset loss function calculation formula; and summing the fragment loss function values corresponding to multiple token fragments to obtain the loss function value.
[0014] Secondly, embodiments of this application provide a distillation apparatus for a dialogue model, the apparatus comprising: The acquisition module is used to acquire initial dialogue training samples and input them into the teacher model. The teacher model then performs token prediction on the initial dialogue training samples to obtain response soft labels. The prediction module is used to input the initial dialogue training samples into the student model. The student model performs token prediction based on the initial dialogue training samples to obtain the predicted token and the token entropy corresponding to the predicted token. The first judgment module is used to update the initial dialogue training sample based on the response soft label fragment and the initial dialogue training sample when it is determined that the token entropy does not meet the dynamic entropy threshold. The module then returns the steps of inputting the initial dialogue training sample into the student model, the student model predicting the token based on the dialogue training sample, obtaining the predicted token and the token entropy corresponding to the predicted token, until the predicted dialogue response is obtained. The position of the response soft label fragment is determined based on the position of the token that does not meet the dynamic entropy threshold among the multiple tokens generated by the student model. The calculation module is used to calculate the loss function value based on the predicted tokens and response soft labels output by the student model; The second judgment module is used to return to the step of inputting the initial dialogue training sample into the teacher model when the loss function value does not meet the stopping condition. The teacher model then performs token prediction on the initial dialogue training sample to obtain the response soft label, until the loss function value meets the stopping condition, and a trained student model is obtained.
[0015] Thirdly, embodiments of this application provide a distillation apparatus for a dialogue model, the apparatus including: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, it implements the distillation method for the dialogue model in the first aspect or any embodiment of the first aspect.
[0016] Fourthly, a computer-readable storage medium storing computer program instructions that, when executed by a processor, implement the distillation method of the dialogue model in the first aspect or any embodiment of the first aspect.
[0017] Fifthly, embodiments of this application provide a computer program product in which instructions, when executed by a processor of an electronic device, cause the electronic device to perform a distillation method for a dialogue model as described in the first aspect or any embodiment of the first aspect.
[0018] The distillation method, apparatus, device, storage medium, and program product of the dialogue model in this application rely on the dynamic discrimination of token entropy to achieve sample correction during the generation process. When it is detected that the token entropy corresponding to the predicted token does not meet the dynamic entropy threshold, the corresponding response soft label fragment is extracted according to the position of the abnormal predicted token, and the current dialogue training sample is updated. Based on the updated sample, the student model is continuously driven to iteratively generate predicted tokens until a complete predicted dialogue response is output. This can replace context fragments with uncertain risks in a timely manner within the generation chain, cut off the cumulative inference bias caused by the continuous transmission of erroneous information from the source, better maintain the logical coherence of the dialogue inference context, and improve the reliability of the content generated by the student model. At the same time, this application embodiment uses the response soft labels pre-generated by the teacher model as the correction basis, eliminating the need for the teacher model to continuously perform online real-time inference verification, reducing the computational overhead of the teacher model in the training process. Combined with the iterative loss constraint mechanism, the loss function is continuously calculated based on the predicted tokens and response soft labels of the student model, and the sample generation and model parameter update are iteratively executed until convergence. This can efficiently complete knowledge distillation, optimize the overall training resource consumption while ensuring the distillation effect, and obtain a student model with high-quality dialogue generation capabilities. Attached Figure Description
[0019] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This illustration shows one of the flowcharts of a distillation method for a dialogue model provided in an embodiment of this application; Figure 2 A schematic diagram of a process for determining a dynamic entropy threshold is shown in one embodiment of this application; Figure 3 This is a second schematic flowchart of a distillation method for a dialogue model provided in one embodiment of this application; Figure 4 The third schematic flowchart of a distillation method for a dialogue model provided in one embodiment of this application is shown. Figure 5 This illustration shows a schematic diagram of a distillation apparatus for a dialogue model provided in an embodiment of this application; Figure 6A schematic diagram of the hardware structure of the distillation apparatus for the dialogue model provided in this application embodiment is shown. Detailed Implementation
[0021] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.
[0022] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.
[0023] It should be noted that the acquisition, storage, use, and processing of data in this application embodiment all comply with the relevant provisions of national laws and regulations.
[0024] It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned. These should be regarded as exemplary and are only intended to illustrate the feasibility of implementing the technical solution of this application. However, it does not mean that the applicant has used or necessarily used the solution.
[0025] Knowledge distillation (KD) in neural networks involves a teacher model generating a complete classification probability distribution (i.e., soft labels). During training, the student model uses these soft labels instead of the true labels, approximating the teacher model's distribution to learn richer supervisory signals. This method is called white-box distillation. In large language model scenarios, the student model approximates the teacher model token-by-token using a specific distribution metric (e.g., forward KL divergence).
[0026] Another type of knowledge distillation method commonly used for large models is sequence knowledge distillation (SeqKD), also known as black-box distillation, in which the student model directly uses the output of the teacher model as training labels.
[0027] Due to the autoregressive generative nature of large language models, conventional fixed-label distillation techniques suffer from training-inference mismatch. The sample distribution seen by the student model during training deviates from the distribution it actually infers during inference; that is, the student never sees its own "error-prone state" during training. Once the student makes some early generation errors, these errors accumulate as generation continues. To address this training-inference mismatch, many studies have proposed on-policy KD techniques. During distillation, the student model generates its own outputs (SGOs) and performs further inference based on these outputs. Simultaneously, the teacher model uses the student outputs as input and provides its own distribution as a supervisory signal, thus providing error-correcting feedback to the student model's inference.
[0028] Understandably, in online distillation, the student model needs to generate training samples on its own. However, its ability is relatively weak in the early stages of training, making it prone to compounding errors. That is, the erroneous tokens output by the student model in the early stages accumulate and amplify along the generation trajectory, causing the quality of the student's output to deteriorate and gradually deviate from the teacher's distribution. This deviation will cause the supervision signal of the teacher model to degrade or even become noise, and the student model's ability will continue to decline as it distills on a large number of low-quality samples.
[0029] Speculative KD (SKD) borrows the idea from speculative decoding, introducing a top-level teacher model for each predicted token during the generation process. K-validation corrects tokens that are not within the teacher distribution, thereby improving the quality of student outputs, making them closer to the teacher distribution, and maintaining consistency between the generated sequence and the teacher distribution. However, SKD's token-level correction strategy is difficult to correct path-level errors because when the current token deviates from the teacher distribution, the root cause is often an earlier erroneous token; furthermore, frequent intervention by the teacher model significantly increases training time and computational cost, weakening the method's practicality. Top-K can refer to the model selecting the K highest-probability candidate tokens from the entire vocabulary at each step when predicting the next token.
[0030] Therefore, how to avoid error accumulation during the knowledge distillation process and improve the performance of student models is a technical problem that urgently needs to be solved in this field.
[0031] To address the problems of the prior art, embodiments of this application provide a distillation method, apparatus, device, storage medium, and program product for a dialogue model.
[0032] The distillation method for the dialogue model provided in the embodiments of this application will be introduced first below.
[0033] Figure 1 This illustration shows one of the flowcharts of a distillation method for a dialogue model provided in one embodiment of this application. Figure 1 As shown, the distillation method for this dialogue model may include the following steps: S110. Obtain the initial dialogue training samples and input them into the teacher model. The teacher model performs token prediction on the initial dialogue training samples to obtain the response soft labels.
[0034] S120. Input the initial dialogue training samples into the student model. The student model performs token prediction based on the initial dialogue training samples to obtain the predicted token and the token entropy corresponding to the predicted token.
[0035] S130. If it is determined that the token entropy does not meet the dynamic entropy threshold, update the initial dialogue training sample according to the response soft label fragment and the initial dialogue training sample, and return to S120.
[0036] S140, Receive the predicted dialogue response.
[0037] S150. Calculate the loss function value based on the predicted tokens and response soft labels output by the student model.
[0038] S160. Determine whether the loss function value meets the stopping condition. If the stopping condition is met, proceed to S170; otherwise, return to S110.
[0039] S170, Obtain the trained student model.
[0040] In some embodiments, in S110, the initial dialogue training samples can be input into the teacher model, so that the teacher model can perform token prediction on the initial dialogue training samples to obtain soft response labels.
[0041] For example, the initial dialogue training samples can be the raw dialogue data used for model distillation training. For instance, the initial dialogue samples can be token sequences consisting of multiple tokens.
[0042] For example, the teacher model can be a pre-trained large model with high accuracy, a large number of parameters, and excellent semantic generation capabilities. That is, the teacher model is a pre-trained model that can output content with high accuracy. Furthermore, the teacher model can perform inference on the initial dialogue training samples and use the output content as soft response labels to guide the training of the student model.
[0043] In one example, the teacher model could be a pre-trained Large Language Model (LLM), which can be deployed in scenarios such as intelligent question answering, smart devices, summarizing or translation services, so as to provide corresponding answers based on the questions raised by users.
[0044] In one example, the parameters in the teacher model can be frozen and the soft response labels of its output can be saved before the initial dialogue training samples are fed into the teacher model.
[0045] For example, the initial dialogue training samples are input into the teacher model, which then predicts the probability distribution of the next most likely token (word, sub-word, or character) based on the given input sequence, and uses the final generated token sequence as the label for the student model.
[0046] In some embodiments, in S120, the initial dialogue training samples can be input into the student model, and the student model performs token prediction based on the initial dialogue training samples to obtain the predicted token and the token entropy corresponding to the predicted token.
[0047] For example, the student model can be a trainable model with a small number of parameters and a simplified structure. It is understood that the student model can be the target of knowledge distillation, capable of mimicking the behavior of the teacher model while possessing faster inference speed and lower resource consumption.
[0048] For example, the predicted token output by the student model can be the output token with the highest probability calculated by the student model based on its own parameters under the input of the current initial dialogue training sample. Furthermore, the student model also simultaneously outputs the token entropy corresponding to this predicted token. The token entropy can be used to measure the uncertainty of the student model outputting this predicted token.
[0049] In one example, a higher token entropy value indicates that the student model is less certain and less confident in its prediction of the token; conversely, a lower token entropy value indicates that the student model is more confident in its prediction of the token.
[0050] S130. If it is determined that the token entropy does not meet the dynamic entropy threshold, update the initial dialogue training sample according to the response soft label fragment and the initial dialogue training sample, and return to S120.
[0051] The soft-label fragment of the response is determined based on the position of the predicted token that does not meet the dynamic entropy threshold among multiple tokens generated by the student model.
[0052] For example, the response soft-label fragment is a subset of the corresponding positions extracted from the full response soft labels provided by the teacher model, based on the specific position of the predicted token that does not meet the dynamic entropy threshold within the full response generated by the student model. It is understood that the response soft-label fragment is used to replace the corresponding predicted token from the student model.
[0053] In some optional embodiments, the target token is determined within a plurality of predicted tokens generated by the student model, at its target position. The target token is a predicted token that does not satisfy a dynamic entropy threshold. One or more tokens up to the target position are extracted from the token sequence corresponding to the response soft label as response soft label fragments. The initial dialogue training samples are updated based on the response soft label fragments and the initial dialogue training samples.
[0054] For example, the target position can be the position of the target token among multiple predicted tokens already generated by the student model. For instance, if the token entropy corresponding to the 5th predicted token output by the student model is greater than the dynamic entropy threshold, then that predicted token can be determined, and that position can be used as the target position.
[0055] For example, a soft tag segment consisting of the target token and the previous target token can be extracted from the complete response soft tag sequence provided by the teacher model, with the target position as the endpoint.
[0056] In one example, the student model generates the first student segment (i.e., student_span1) and detects that the entropy of the 10th token exceeds the dynamic entropy threshold 'a'. At this point, the student_span1 generated by the student model can be replaced with the 1-10 tokens output by the teacher model. Further, the input plus the 1-10 tokens corresponding to the teacher model are used as the new context input to the student model to continue generating the second student segment (student_span2). Here, the 15th token exceeds the dynamic entropy threshold 'a', and the student_span2 generated can be replaced with the 11-25 tokens output by the teacher. It can be understood that if the first segment does not need to be replaced (i.e., it never reaches the dynamic entropy threshold), it will continue to be generated indefinitely until the end, and this sample will no longer have a student_span2.
[0057] For example, if it is determined that the token entropy does not meet the dynamic entropy threshold, the response soft label fragment and the initial dialogue training sample can be used as the input for the next round of the student model, so that the student model can continue to predict the token based on the response soft label fragment and the initial dialogue training sample to obtain the predicted token.
[0058] In one example, when a question is input into the student model, the model performs multiple rounds of token prediction to generate `student_span1`. Upon encountering a high-entropy token, `student_span1` is completely replaced with `teacher_span1` of equal length (i.e., the soft-label fragment of the response). Further, the question and `teacher_span1` are input into the student model, causing it to continue performing multiple rounds of token prediction to generate `student_span2`. Upon encountering a high-entropy token, `student_span2` is replaced with `teacher_span2` of equal length.
[0059] In this embodiment, when the predicted token generated by the student model does not meet the dynamic entropy threshold, the position of the token can be accurately located. The token between the corresponding position and its preceding target token is extracted from the output of the teacher model as a soft-label fragment. This more reliable information is then used to update the original training samples. In this way, the student model can relearn within a locally corrected context, rather than simply memorizing an isolated correct token. Since the root cause of errors often lies in a local dependency, this fragment replacement with historical information effectively prevents a single mistake from causing a chain reaction of interference in subsequent generation, ensuring that subsequent predictions are no longer based on erroneous premises.
[0060] In addition, the soft labels of the responses output by the teacher model are extracted, which avoids the frequent intervention and correction of the teacher model during distillation and reduces training time.
[0061] Optionally, the dynamic entropy threshold is the same for the same initial dialogue training sample.
[0062] For example, the dynamic entropy threshold can be a non-fixed, adaptively adjustable entropy threshold used to determine whether the student model is sufficiently reliable for a given predicted token. For instance, if the entropy of a predicted token is higher than this dynamic entropy threshold, the predicted token is considered to have poor prediction quality and requires intervention.
[0063] In some optional embodiments, in order to better determine the dynamic entropy threshold, as another implementation of this application, this application also provides an implementation for determining the dynamic entropy threshold, as detailed in the following embodiments.
[0064] Figure 2A schematic diagram illustrating a process for determining a dynamic entropy threshold according to an embodiment of this application is shown. Figure 2 As shown, the method for determining the dynamic entropy threshold may include the following steps S210-S230: S210. Determine the target entropy quantile factor based on the number of training steps, total number of training steps, preset scaling factor, and initial entropy quantile factor corresponding to the student model.
[0065] For example, the number of training steps can be the number of iterations the student model has completed from the start of training to the current moment. The total number of training steps can be the total number of iterations required for a pre-defined complete training process.
[0066] For example, the preset scaling factor can be an adjustable hyperparameter. In one example, the preset scaling factor can be determined based on the experience of a technician; for example, the preset scaling factor can be set to 2.
[0067] For example, the initial entropy quantile factor can be a base quantile value set at the start of training, which can be used to determine the statistical quantile points for early threshold selection. The initial entropy quantile factor can be preset by a technician.
[0068] For example, the target entropy quantile factor can be the quantile value actually used at the current moment, calculated by combining the current training progress and the preset scaling factor, and used to dynamically adjust the size of the threshold.
[0069] In some alternative embodiments, the target entropy quantile factor can be calculated using the following formula (1):
[0070] in, The target entropy quantile factor; The initial entropy quantile factor; To train step count, The total number of training steps is, This is the preset scaling factor. In one example, we can set... .
[0071] Understandably, as the number of training steps increases, the student model's capabilities gradually improve, and the accumulated error decreases. At this point, the threshold restriction can be gradually relaxed, allowing more tokens to pass through. This encourages the student model to have more freedom in its output during the later stages of training, thus making the generation behavior during the training phase closer to the distribution during actual inference. Therefore, in this embodiment, as training progresses, the student model's capabilities continuously improve, the target entropy quantile factor gradually increases, and more tokens no longer trigger intervention. This allows the student model to freely generate according to its learned distribution, thereby narrowing the behavioral gap between training and inference, and improving the model's generalization ability and output diversity.
[0072] S220. Using a sliding window based on entropy values, extract multiple token entropies from the student model output to obtain multiple candidate token entropies.
[0073] For example, the entropy sliding window can be a fixed-length buffer used to store the token entropy generated in the most recent steps.
[0074] In one example, an entropy sliding window can be constructed using deque in Python.
[0075] For example, the candidate token entropy can be all the token entropy values captured within the sliding window, serving as a data pool for determining the dynamic entropy threshold.
[0076] S230. Determine the dynamic entropy threshold from multiple candidate token entropies based on the target entropy quantile factor.
[0077] In one example, a candidate token entropy can be selected from multiple candidate token entropies as a dynamic entropy threshold based on the target entropy quantile factor.
[0078] In some alternative embodiments, multiple candidate token entropies are sequentially arranged to obtain a candidate token entropy sequence; the target quantile position in the candidate token entropy sequence is determined according to the target entropy quantile factor, and the candidate token entropy at the target quantile position is used as the dynamic entropy threshold.
[0079] For example, the candidate token entropy can be sorted in ascending (or descending) order to form an ordered sequence, i.e., the candidate token entropy sequence.
[0080] For example, the target quantile position refers to the specific index position calculated based on the target entropy quantile factor within the sorted sequence of candidate token entropy. In one example, the dynamic entropy threshold can be set to (1- ) of the candidate token entropy sequence. Quantities, calculated from the least significant end of the sequence, are those whose cumulative frequency reaches (1- ). The entropy value corresponding to the time.
[0081] For example, if If the value is 0.05, the target quantile position corresponds to the element at the 0.95th quantile position in the sequence.
[0082] In this embodiment, the dynamic entropy threshold is determined from candidate token entropy through statistical ranking. This method, utilizing the distribution characteristics of recent token entropy to determine the dynamic entropy threshold, is unaffected by extreme values and exhibits high robustness. Furthermore, since candidate token entropy comes from an entropy value sliding window, the dynamic entropy threshold reflects the relative level of entropy values in the model's recent generation behavior. This allows for adaptive adjustment across different tasks or datasets without the need for parameter retuning. This relative ranking-based approach is simple and efficient, ensuring that a relatively fixed proportion of tokens are deemed high-entropy and require intervention in each training phase. This results in a relatively balanced distribution of training resources across rounds, avoiding extreme situations where all tokens pass or all are blocked due to unreasonable absolute threshold values, thus improving model robustness.
[0083] Figure 2 In the illustrated embodiment, the dynamic entropy threshold is adaptively adjusted so that it gradually widens as the training process progresses. Specifically, low-confidence tokens are strictly screened in the early stages of training to strengthen supervision, while the threshold is appropriately widened in the later stages to encourage autonomous model generation. A sliding window ensures that the threshold reflects the latest state of the model in real time, and the quantile method ensures that it can be adaptively adjusted under different tasks.
[0084] In some embodiments, a predicted dialogue response can be obtained in S140.
[0085] For example, a predicted dialogue response can be the complete reply statement that the student model finally generates and outputs for a given initial dialogue training sample after all iterations have been completed.
[0086] In one example, the loop stops and a predicted dialogue response is obtained when a preset stopping condition is met. For example, a predicted dialogue response is obtained when the student model outputs an end marker.
[0087] In some embodiments, in S150, the loss function value is calculated based on the predicted tokens output by the student model and the response soft labels.
[0088] For example, the loss function value can be a scalar value (such as cross-entropy loss or KL divergence) used to quantify the difference between the predicted tokens output by the student model and the response soft labels output by the teacher model. It can be understood that the smaller the loss function value, the closer the student model is to the performance of the teacher model.
[0089] In some optional embodiments, token fragments are stored, including a target token and historical tokens generated before the target token. For each token fragment, a fragment loss function value is calculated between the token fragment and the response soft tag fragment according to a preset loss function calculation formula. The fragment loss function values corresponding to multiple token fragments are summed to obtain the total loss function value.
[0090] For example, a token fragment can be a local token sequence unit in the autoregressive generation process of the student model, which ends with a target token and includes several consecutive historical tokens preceding the target token.
[0091] Among them, the historical tokens can be the sequence of preceding tokens that the student model has predicted and output before generating the target token, and which are located in the current segment.
[0092] For example, the fragment loss function value can be a local loss scalar obtained by measuring the difference (such as cross-entropy or KL divergence) between all tokens in the token fragment and the corresponding response soft-label fragment bit by bit.
[0093] In one example, the loss function value can be calculated using the following formula (2). :
[0094] in, The number of student token fragments generated for the student model. Let K be the total length of the student token fragments; For the first The cumulative output length at the end of each student token fragment. This represents the length of the segment for the i-th student. This is a function that measures the difference in distribution. For the teacher model in context The probability distribution of the output token under the given conditions; For parameters Student model in context The predicted probability distribution of the output token under the given conditions. Wherein, , These represent the output sequences of the teacher model and the student model, respectively. Let represent the sequence of the first to nth tokens output by the teacher, so Teacher segment 1 + Teacher segment 2 + ... + Teacher segment i-1; This represents the segment of the i-th student; This represents the first token from the i-th student segment ( The sequence from token(j) to the current token(j). The distribution difference measure function can be the forward KL divergence, i.e. .
[0095] In this embodiment, by calculating the loss function in fragment form, the evaluation granularity is expanded from a single token to token fragments containing historical context, thereby addressing the problem of accumulated error in online distillation. It is understood that in this embodiment, by calculating the loss of each fragment separately and then summing them, the temporal causal structure is preserved. This encourages the model to focus not only on the correctness of isolated tokens during optimization but also on the coherent transition patterns within the local context, thereby improving the overall fluency and semantic consistency of the response and providing a more accurate and targeted optimization direction for subsequent parameter updates.
[0096] In some embodiments, in S160, it is determined whether the loss function value meets the stopping condition. If the stopping condition is met, S170 is executed (the trained student model is obtained); if the stopping condition is not met, S110 is returned.
[0097] For example, the stopping condition can be a preset condition used to terminate the training of the student model. For example, the loss function value converges to a threshold, the loss no longer decreases after several consecutive rounds, or the maximum preset number of training rounds is reached.
[0098] For example, when the stopping condition is met, S170 can be executed to obtain a trained student model; when the stopping condition is not met, the process returns to the step of inputting the initial dialogue training sample into the teacher model, performing token prediction on the initial dialogue training sample through the teacher model, and obtaining the response soft label, until the stopping condition is met and a trained student model is obtained.
[0099] Figure 1 In the illustrated embodiment, dynamic discrimination based on token entropy enables sample correction during the generation process. When the token entropy corresponding to the predicted token is detected to be below the dynamic entropy threshold, the corresponding response soft label fragment is extracted based on the location of the abnormal predicted token, and the current dialogue training sample is updated. Based on the updated sample, the student model is continuously driven to iteratively generate predicted tokens until a complete predicted dialogue response is output. This allows for timely replacement of context fragments with uncertain risks within the generation chain, cutting off the cumulative inference bias caused by the continuous transmission of erroneous information at the source. This better maintains the logical coherence of the dialogue inference context and improves the reliability of the content generated by the student model. Furthermore, this embodiment uses the response soft labels pre-generated by the teacher model as the correction basis, eliminating the need for continuous online real-time inference verification by the teacher model. This reduces the computational overhead of the teacher model in the training process. Combined with a cyclical iterative loss constraint mechanism, the loss function is continuously calculated based on the student model's predicted tokens and response soft labels. Sample generation and model parameter updates are cyclically executed until convergence, efficiently completing knowledge distillation. While ensuring the distillation effect, the overall training resource consumption is optimized, resulting in a student model with high-quality dialogue generation capabilities.
[0100] In some alternative embodiments, in order to achieve distillation of the dialogue model, as another implementation of this application, this application also provides an implementation of a dialogue model distillation method, as detailed in the following embodiments.
[0101] Figure 3 This is a second schematic flowchart illustrating a distillation method for a dialogue model provided in one embodiment of this application. Figure 3 As shown, the distillation method for this dialogue model may include the following steps: S310. Obtain the initial dialogue training samples and input them into the teacher model. The teacher model performs token prediction on the initial dialogue training samples to obtain the response soft labels.
[0102] S320. Input the initial dialogue training samples into the student model. The student model performs token prediction based on the initial dialogue training samples to obtain the predicted token and the token entropy corresponding to the predicted token.
[0103] S331. If it is determined that the token entropy does not meet the dynamic entropy threshold, update the initial dialogue training sample according to the response soft label fragment and the initial dialogue training sample, and return to S320.
[0104] S332. If the token entropy meets the dynamic entropy threshold, update the initial dialogue training sample according to the predicted token and the dialogue training sample to obtain the updated initial dialogue sample, and return to S320.
[0105] S340, Receive the predicted dialogue response.
[0106] S350. Calculate the loss function value based on the predicted tokens and response soft labels output by the student model.
[0107] S360. Determine whether the loss function value meets the stopping condition. If the stopping condition is met, execute S170; otherwise, return to S310.
[0108] S370, Obtain the trained student model.
[0109] Steps S310-S331 are the same as steps S110-S130, and steps S340-S370 are the same as steps S140-S170, so they will not be repeated here.
[0110] In some embodiments, in S332, if it is determined that the token entropy meets the dynamic entropy threshold, the predicted token and the dialogue training sample can be used as output and input into the student model, so that the student model can continue to predict the token based on the input.
[0111] Understandably, when the student model is confident enough in the current prediction (i.e., the token entropy is below the dynamic entropy threshold), it indicates that the predicted token is of reliable quality. Therefore, this predicted token is directly appended to the end of the input sequence to predict the next token, thus driving the dialogue response generation process forward.
[0112] In this embodiment of the application, when the token entropy meets the dynamic entropy threshold, it means that the student model has a high degree of confidence in the current prediction. At this time, the dialogue training sample sequence is updated with the prediction token generated by the student. This not only ensures the continuity and diversity of the generated trajectory, but also avoids the computational overhead caused by frequently requesting the teacher to verify.
[0113] Below, in conjunction with Figure 4 The following examples illustrate the distillation method of the dialogue model.
[0114] Figure 4 The third schematic diagram illustrates a flow chart of a distillation method for a dialogue model provided in one embodiment of this application. Figure 4 As shown, student model 402 generates text online token by token, and the system continuously calculates the token entropy corresponding to each output token in real time. Once the entropy value of a token exceeds the dynamic entropy threshold, the generation of the current student token fragment ends. After the generation of the student token fragment ends, the text fragment corresponding to the position in the standard answer (TGO) output by teacher model 401 is extracted, and the current fragment is subjected to overall replacement correction. Figure 4 As shown, student model 402 initially outputs the incorrect text "2 pages each fried × 2 friends = 4 pages per week". Further, the student model predicts that the next token "4" corresponds to a token entropy greater than the dynamic entropy threshold, triggering a correction process. The system directly uses the correct fragment from the standard answer output by teacher model 401, "He writes each friend 3*2=6 pages a week In So he", to replace this student token fragment output by student model 402. After correction, student model 402 continues to generate tokens one by one based on this corrected text. The entropy of subsequent output tokens remains within the threshold, and no further correction is triggered. Student model 402 continues to generate the remaining solution steps until the final correct result "624" is fully output.
[0115] For example, before distillation training begins, a frozen teacher model is used to generate high-quality reference outputs offline for each training input, and these outputs are saved for subsequent corrections. The teacher model outputs can be batch-generated using an accelerated inference engine (e.g., vLLM) and reused across training rounds to save on online overhead.
[0116] For example, a fragment correction length threshold can be set to constrain the size of the token interval (i.e., the student token fragment) corresponding to a single correction operation, preventing the model from frequently triggering short fragment replacement operations and thus preventing the coherence of text order and inference context from being disrupted. For instance, the fragment correction length threshold can be set to 5 tokens. When the number of tokens in the student token fragment to be corrected output by the student model is less than this fragment correction length threshold, the correction check is skipped to ensure output coherence.
[0117] Using the example above, if there is only a local deviation containing 2 or 3 consecutive erroneous tokens, the system will skip the correction process directly because the student token fragment to be corrected does not reach 5 tokens, allowing the student model to continue to generate subsequent content autonomously; only when the length of the student token fragment corresponding to the target token that exceeds the dynamic entropy threshold is greater than or equal to the fragment correction length threshold will the span replacement logic be activated to retrieve the text fragment corresponding to the position in the teacher's standard answer to complete the token fragment correction.
[0118] For example, the desired student token fragment can be determined based on a dynamic entropy threshold. For instance, a student token fragment can be represented as... .
[0119] In this embodiment, the cumulative error generated by the student model output can be mitigated. It is understood that this embodiment replaces the potentially erroneous generated fragments from the student model with high-quality text fragments from the teacher model, eliminating erroneous contexts that induce subsequent inference errors at the source, improving the quality of student model generation, and thus optimizing the overall effect of knowledge distillation. Simultaneously, this application relies on token entropy self-checking combined with offline teacher fragment correction, reducing the frequency of intervention by the online teacher model, avoiding the high-frequency intervention and correction defects of the online teacher model in speculative distillation schemes, reducing training time, and improving overall training efficiency.
[0120] Based on the distillation method for the dialogue model provided in the above embodiments, this application also provides specific implementations of a distillation apparatus for the dialogue model. Please refer to the following embodiments.
[0121] Figure 5 This application provides a schematic diagram of a distillation apparatus structure for a dialogue model, as illustrated in an embodiment of the present application. Figure 5 As shown, the distillation apparatus 500 of the dialogue model includes: The acquisition module 510 is used to acquire the initial dialogue training samples and input the initial dialogue training samples into the teacher model. The teacher model performs token prediction on the initial dialogue training samples to obtain the response soft labels. The prediction module 520 is used to input the initial dialogue training samples into the student model. The student model performs token prediction based on the initial dialogue training samples to obtain the predicted token and the token entropy corresponding to the predicted token. The first judgment module 530 is used to update the initial dialogue training sample based on the response soft label fragment and the initial dialogue training sample when it is determined that the token entropy does not meet the dynamic entropy threshold, and return the steps of inputting the initial dialogue training sample into the student model, the student model predicting the token based on the dialogue training sample, obtaining the predicted token and the token entropy corresponding to the predicted token, until the predicted dialogue response is obtained, and the position of the response soft label fragment is determined based on the position of the token that does not meet the dynamic entropy threshold among the multiple tokens generated by the student model. The calculation module 540 is used to calculate the loss function value based on the predicted tokens and response soft labels output by the student model; The second judgment module 550 is used to return to the step of inputting the initial dialogue training sample into the teacher model and performing token prediction on the initial dialogue training sample through the teacher model to obtain the response soft label when the loss function value does not meet the stopping condition, until the loss function value meets the stopping condition and the trained student model is obtained.
[0122] In one implementation, after inputting the initial dialogue training sample into the student model, and the student model performs token prediction based on the dialogue training sample to obtain the predicted token and the token entropy corresponding to the predicted token, the first judgment module 530 is further configured to: if it is determined that the token entropy meets the dynamic entropy threshold, update the initial dialogue training sample based on the predicted token and the dialogue training sample to obtain the updated initial dialogue sample, and return to the step of inputting the initial dialogue training sample into the student model, and the student model performing token prediction based on the dialogue training sample to obtain the predicted token and the token entropy corresponding to the predicted token, until the predicted dialogue response is obtained.
[0123] In one embodiment, before updating the initial dialogue training samples based on the response soft-label fragments and the initial dialogue training samples when it is determined that the token entropy does not meet the dynamic entropy threshold, the device further includes a determining module, which is used to determine the target entropy quantile factor based on the number of training steps corresponding to the student model, the total number of training steps, the preset scaling factor, and the initial entropy quantile factor; to truncate multiple token entropies output by the student model according to the entropy value sliding window to obtain multiple candidate token entropies; and to determine the dynamic entropy threshold from the multiple candidate token entropies based on the target entropy quantile factor.
[0124] In one implementation, the target entropy quantile factor is calculated using the following formula (1):
[0125] in, The initial entropy quantile factor; To train step count, The total number of training steps is, This is the preset scaling factor.
[0126] In one implementation, the determining module determines the dynamic entropy threshold from multiple candidate token entropies based on the target entropy quantile factor as follows: the multiple candidate token entropies are arranged sequentially to obtain a candidate token entropy sequence; the target quantile position in the candidate token entropy sequence is determined based on the target entropy quantile factor, and the candidate token entropy at the target quantile position is used as the dynamic entropy threshold.
[0127] In one embodiment, the first judgment module 530 updates the initial dialogue training sample according to the response soft label fragment and the initial dialogue training sample in the following manner: determining the target position of the target token among multiple predicted tokens generated by the student model, wherein the target token is a predicted token that does not meet the dynamic entropy threshold; extracting one or more tokens up to the target position from the token sequence corresponding to the response soft label as the response soft label fragment; and updating the initial dialogue training sample according to the response soft label fragment and the initial dialogue training sample.
[0128] In one embodiment, after determining the position of the target token among multiple tokens generated by the student model, the device further includes a storage module for storing token fragments, the token fragments including the target token and historical tokens generated before the target token; the calculation module 540 calculates the loss function value based on the predicted tokens and response soft tags output by the student model in the following manner: for each token fragment, the fragment loss function value between the token fragment and the response soft tag fragment is calculated according to a preset loss function calculation formula; the fragment loss function values corresponding to multiple token fragments are accumulated to obtain the loss function value.
[0129] Figure 6 A schematic diagram of the hardware structure of the distillation apparatus for the dialogue model provided in this application embodiment is shown.
[0130] The distillation apparatus 600 of the dialogue model may include a processor 601 and a memory 602 storing computer program instructions.
[0131] Specifically, the processor 601 may include a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0132] Memory 602 may include mass storage for data or instructions. For example, and not limitingly, memory 602 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. In one instance, memory 602 may include removable or non-removable (or fixed) media, or memory 602 may be non-volatile solid-state memory. Memory 602 may be internal or external to the distillation apparatus of the dialog model.
[0133] In one instance, memory 602 may be read-only memory (ROM). In one instance, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM), or flash memory, or a combination of two or more of these.
[0134] Memory 602 may include read-only memory (ROM), random access memory (RAM), disk storage media device, optical storage media device, flash memory device, electrical, optical, or other physical / tangible memory storage device. Therefore, generally, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of this disclosure.
[0135] The processor 601 reads and executes computer program instructions stored in the memory 602 to achieve... Figure 1 Distillation method for the dialogue model in the illustrated embodiment.
[0136] In one example, the distillation apparatus of the dialogue model may also include a communication interface 603 and a bus 604. Wherein, as Figure 6 As shown, the processor 601, memory 602, and communication interface 603 are connected through bus 604 and complete communication with each other.
[0137] The communication interface 603 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0138] Bus 604 includes hardware, software, or both, that couples components of a distillation device in a dialog model together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 604 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, this application contemplates any suitable bus or interconnect.
[0139] The distillation device of this dialogue model can execute the distillation method of the dialogue model in the embodiments of this application based on training samples, thereby achieving a combination Figure 1 and Figure 2 The distillation method described in the dialogue model.
[0140] Furthermore, in conjunction with the distillation method of the dialogue model in the above embodiments, this application embodiment can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the dialogue model distillation methods in the above embodiments.
[0141] This application also provides a computer program product, including a computer program that, when executed by a processor, implements a method for distilling any of the dialogue models described in the above embodiments.
[0142] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0143] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, read-only memory (ROM), flash memory, erasable read-only memory (EROM), floppy disks, compact disc read-only memory (CD-ROM), optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0144] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0145] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by special-purpose hardware performing the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.
[0146] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A distillation method for a dialogue model, characterized in that, include: Obtain initial dialogue training samples and input them into the teacher model. Use the teacher model to perform token prediction on the initial dialogue training samples to obtain response soft labels. The initial dialogue training sample is input into the student model, and the student model performs token prediction based on the initial dialogue training sample to obtain the predicted token and the token entropy corresponding to the predicted token. If it is determined that the token entropy does not meet the dynamic entropy threshold, the initial dialogue training sample is updated according to the response soft label fragment and the initial dialogue training sample, and the process of inputting the initial dialogue training sample into the student model, the student model performing token prediction based on the dialogue training sample to obtain the predicted token and the token entropy corresponding to the predicted token is repeated until the predicted dialogue response is obtained. The response soft label fragment is determined based on the position of the predicted token that does not meet the dynamic entropy threshold among the multiple predicted tokens generated by the student model. Calculate the loss function value based on the predicted token output by the student model and the soft label of the response; If the loss function value does not meet the stopping condition, return to the step of inputting the initial dialogue training sample into the teacher model, performing token prediction on the initial dialogue training sample through the teacher model, and obtaining the response soft label, until the loss function value meets the stopping condition, and obtain the trained student model.
2. The distillation method for the dialogue model according to claim 1, characterized in that, After inputting the initial dialogue training samples into the student model, and the student model performing token prediction based on the dialogue training samples to obtain the predicted token and the token entropy corresponding to the predicted token, the method further includes: If the token entropy satisfies the dynamic entropy threshold, the initial dialogue training sample is updated according to the predicted token and the dialogue training sample to obtain the updated initial dialogue sample. Then, the process of inputting the initial dialogue training sample into the student model, where the student model performs token prediction based on the dialogue training sample to obtain the predicted token and the token entropy corresponding to the predicted token is repeated until the predicted dialogue response is obtained.
3. The distillation method for the dialogue model according to claim 1 or 2, characterized in that, Before updating the initial dialogue training sample based on the response soft-label fragment and the initial dialogue training sample when it is determined that the token entropy does not meet the dynamic entropy threshold, the method further includes: The target entropy quantile factor is determined based on the number of training steps, total training steps, preset scaling factor, and initial entropy quantile factor corresponding to the student model. According to the entropy value sliding window, the multiple token entropies output by the student model are truncated to obtain multiple candidate token entropies; The dynamic entropy threshold is determined from a plurality of candidate token entropies based on the target entropy quantile factor.
4. The distillation method for the dialogue model according to claim 3, characterized in that, The target entropy quantile factor is calculated using the following formula (1): , in, The initial entropy quantile factor; The number of training steps, The total number of training steps is, The preset scaling factor is denoted as .
5. The distillation method for the dialogue model according to claim 3, characterized in that, The step of determining the dynamic entropy threshold from multiple candidate token entropies based on the target entropy quantile factor includes: The candidate token entropies are arranged sequentially to obtain a candidate token entropy sequence; Based on the target entropy quantile factor, the target quantile position in the candidate token entropy sequence is determined, and the candidate token entropy at the target quantile position is used as the dynamic entropy threshold.
6. The distillation method for the dialogue model according to claim 1, characterized in that, The step of updating the initial dialogue training samples based on the response soft-label fragments and the initial dialogue training samples includes: Determine the target position of the target token among the multiple predicted tokens generated by the student model, wherein the target token is a predicted token that does not satisfy the dynamic entropy threshold; From the token sequence corresponding to the response soft tag, extract one or more tokens up to the target position as the response soft tag fragment; The initial dialogue training samples are updated based on the response soft-label fragments and the initial dialogue training samples.
7. The distillation method for the dialogue model according to claim 6, characterized in that, After determining the position of the target token among the multiple tokens generated by the student model, the method further includes: Store a token fragment, the token fragment including a target token and historical tokens generated before the target token; The step of calculating the loss function value based on the predicted token output by the student model and the response soft label includes: For each token fragment, the fragment loss function value between the token fragment and the response soft tag fragment is calculated according to a preset loss function calculation formula; The loss function value is obtained by summing the fragment loss function values corresponding to multiple token fragments.
8. A distillation apparatus for a dialogue model, characterized in that, The device includes: The acquisition module is used to acquire initial dialogue training samples and input the initial dialogue training samples into the teacher model. The teacher model performs token prediction on the initial dialogue training samples to obtain response soft labels. The prediction module is used to input the initial dialogue training sample into the student model, and the student model performs token prediction based on the initial dialogue training sample to obtain the predicted token and the token entropy corresponding to the predicted token. The first judgment module is used to update the initial dialogue training sample based on the response soft label fragment and the initial dialogue training sample when it is determined that the token entropy does not meet the dynamic entropy threshold, and return to the step of inputting the initial dialogue training sample into the student model, the student model performing token prediction based on the dialogue training sample to obtain the predicted token and the token entropy corresponding to the predicted token, until the predicted dialogue response is obtained, wherein the position of the response soft label fragment is determined based on the position of the token that does not meet the dynamic entropy threshold among the multiple tokens generated by the student model; The calculation module is used to calculate the loss function value based on the predicted token output by the student model and the response soft label; The second judgment module is used to return to the step of inputting the initial dialogue training sample into the teacher model and performing token prediction on the initial dialogue training sample through the teacher model to obtain the response soft label when it is determined that the loss function value does not meet the stopping condition, until the loss function value meets the stopping condition and the trained student model is obtained.
9. A distillation apparatus for a dialogue model, characterized in that, The device includes: a processor and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement the distillation method of the dialogue model as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer storage medium stores computer program instructions, which, when executed by a processor, implement the distillation method of the dialogue model as described in any one of claims 1-7.
11. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the distillation method of the dialogue model as described in any one of claims 1-7.
