A response text generation method and device, electronic equipment and storage medium

By using a lightweight inference model to generate text in parallel and a process reward model to verify it, the problem of slow response text generation by large-scale language models is solved, and efficient and accurate text generation is achieved.

CN120354951BActive Publication Date: 2025-11-21北京衔远有限公司 +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510804376.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-17
Publication Date
2025-11-21
Estimated Expiration
2045-06-17

AI Technical Summary

Technical Problem

Large-scale language models suffer from slow inference speed and high latency when generating response text, leading to excessively long latency in practical applications.

Method used

A lightweight inference model is used to generate multiple inference time steps, which are then input into the target model in parallel to generate reference time steps. The accuracy of the inference time steps is verified by combining a process reward model to ensure output quality.

Benefits of technology

It improves the speed of response text generation, reduces the frequency of calling the target model, ensures that the output quality is close to the level of the target model's independent reasoning, and reduces the risk of error accumulation. In particular, it significantly improves generation efficiency and accuracy in logical reasoning tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120354951B_ABST
    Figure CN120354951B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of computers, and provides a response text generation method and device, electronic equipment and a storage medium. The method generates a speculation time step through a speculation model. Since the parameter quantity of the speculation model is less than that of a target model, the speculation model can quickly generate multiple speculation time steps compared with the target model, which equivalently reduces the calling frequency of the target model. For example, if the speculation model proposes an average of 3 speculation time steps, and the target model is verified once, the calling frequency of the target model is reduced to about 1 / 3 of the original, thereby improving the response efficiency of the target model. In addition, the target model and the process reward model check the speculation time step output by the speculation model, so that the quality of the finally output speculation time step is close to the level of the single inference of the target model, thereby guaranteeing the correctness of the response text.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computers, and in particular to a response text generation method and device, electronic equipment and a storage medium. BACKGROUND

[0002] In recent years, the parameter quantity of a large language model (LLM) has rapidly grown, ranging from several billion to several hundred billion parameters. Although larger models have significantly improved generation effect and reasoning ability, they have also brought problems of slow reasoning speed and high latency. In practical applications (such as real-time dialogue, code automatic generation, etc.), how to accelerate the reasoning of the LLM while ensuring the generation quality has become a technical problem to be solved. SUMMARY

[0003] Therefore, the embodiments of the present application provide a response text generation method and device, electronic equipment and a storage medium to solve the problem that the large language model is very slow in generating a response text in the prior art.

[0004] In a first aspect, the embodiments of the present application provide a response text generation method, which comprises: obtaining a plurality of speculation time steps generated by a speculation model based on a prompt word; inputting the plurality of speculation time steps into a target model, so that the target model generates reference time steps corresponding to the speculation time steps in parallel based on the plurality of speculation time steps, and the parameter quantity of the target model is greater than that of the speculation model; inputting the plurality of speculation time steps and the plurality of reference time steps into a process reward model, so that the process reward model verifies the corresponding speculation time steps based on the reference time steps; and when the process reward model determines that the verification result of the speculation time step is passed, taking the speculation time step as the output of the target model to determine the response text corresponding to the prompt word.

[0005] In a second aspect, the embodiments of the present application provide a response text generation device, which comprises: a speculation module configured to obtain a plurality of speculation time steps generated by a speculation model based on a prompt word; a reference module configured to input the plurality of speculation time steps into a target model, so that the target model generates reference time steps corresponding to the speculation time steps in parallel based on the plurality of speculation time steps, and the parameter quantity of the target model is greater than that of the speculation model; a verification module configured to input the plurality of speculation time steps and the plurality of reference time steps into a process reward model, so that the process reward model verifies the corresponding speculation time steps based on the reference time steps; and an output module configured to, when the process reward model determines that the verification result of the speculation time step is passed, take the speculation time step as the output of the target model to determine the response text corresponding to the prompt word.

[0006] In a third aspect, the embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the above method when executing the computer program.

[0007] In a fourth aspect, the embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the computer program implements the steps of the above method when executed by a processor.

[0008] Compared with the prior art, the embodiment of the present application has the beneficial effects that: the embodiment of the present application generates the inference time steps through the inference model, and because the parameter quantity of the inference model is less than that of the target model, the inference model can quickly generate multiple inference time steps compared with the target model, which equivalently reduces the calling frequency of the target model. For example, if the inference model proposes an average of 3 inference time steps, and the target model passes the verification once, the calling frequency of the target model is reduced to about 1 / 3, thereby improving the efficiency of the target model in generating the response text. In addition, considering the partial parallelism of the target model and the inference model / process reward model, the present application can improve the overall generation speed of the response text by more than 2 times. Furthermore, the present application controls the inference time steps output by the inference model through the target model+process reward model, so that the quality of the final output inference time steps is close to the level of the target model alone. Especially in logical reasoning tasks, the process reward model can ensure that each intermediate step is correct, greatly reducing the risk of error accumulation caused by the inference model guessing randomly. For example, in mathematical calculation, multi-hop reasoning and other scenarios, the present application based on the inference model, the target model and the process reward model can ensure that the output reasoning steps are consistent with the standard solution, thereby ensuring the correctness of the response text generated by the target text. BRIEF DESCRIPTION OF DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.

[0010] Figure 1 is a flowchart of a response text generation method provided by the embodiment of the present application;

[0011] Figure 2 is a flowchart of another response text generation method provided by the embodiment of the present application;

[0012] Figure 3 is a structural schematic diagram of a response text generation device provided by the embodiment of the present application;

[0013] Figure 4 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0014] In the following description, for the purpose of explanation and not limitation, specific details are set forth, such as particular system configurations, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application can be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.

[0015] A response text generation method and device according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.

[0016] Figure 1 is a flowchart of a response text generation method provided by an embodiment of the present application, as shown in Figure 1 The response text generation method comprises the following steps.

[0017] S101, obtaining a plurality of speculative time steps generated by a speculation model based on a prompt word;

[0018] S102, inputting the plurality of speculative time steps to a target model, so that the target model generates reference time steps corresponding to the speculative time steps in parallel based on the plurality of speculative time steps, and the parameter quantity of the target model is greater than that of the speculation model;

[0019] S103, inputting the plurality of speculative time steps and the plurality of reference time steps to a process reward model, so that the process reward model verifies the corresponding speculative time steps based on the reference time steps;

[0020] S104, when the process reward model determines that the verification result of the speculative time step is passed, taking the speculative time step as the output of the target model to determine the response text corresponding to the prompt word.

[0021] The inference model is a lightweight language model that uses a language model with a small parameter size (e.g., 7B parameters) as a "draft generation model". The inference model has the advantage of fast reasoning speed and is responsible for generating subsequent content in a time step (step) level (step by step / segment by segment). The inference model can output one or more steps at a time, and can generate the complete content of an intermediate step according to certain logic (e.g., a line of code or an intermediate reasoning step of a mathematical problem). Since the inference model is fast, the present application allows it to "advance" to generate several candidate contents to form an inference step (draft step) representing the inference model's guess of the subsequent output. The inference model in the present application can use a small parameter version of the same architecture as the target model (e.g., both are Transformers), but with reduced number of layers / dimensions, or can be a distilled model, a small pre-trained model (such as GPT2-small), etc.

[0022] The target model is a high-performance large-scale language model (e.g., a 72B parameter model) such as GPT-3, PaLM, LLaMA, etc. The target model has stronger generation capability and accuracy, and has stronger language understanding and reasoning capability, but has high running overhead and slow generation step speed.

[0023] The process reward model (PRM) is a model for verifying the quality of candidate output, which compares the reference output (reference time step) of the target model with the prediction (inference time step) of the inference model and decides whether to accept the inference time step.

[0024] Specifically, after obtaining the prompt, in order to avoid the problem of slow reasoning speed, high delay, and waste of system resources caused by the high running overhead of the target model and the slow generation step speed of the target model when the target model directly generates a response text based on the prompt, the present application will give the prompt to the inference model (since the parameter size of the inference model is significantly smaller than that of the target model, the inference model has fast reasoning speed, low delay, and requires less system resources, and has low running overhead), so that the inference model quickly generates multiple possible subsequent inference time steps as drafts. It can be understood that the number of inference time steps generated by the inference model at a time is determined by the inference length, for example, if the inference length is 2, the inference model generates 2 inference time steps at a time, and if the inference length is 5, the inference model generates 5 inference time steps at a time; wherein the inference length of the inference time steps generated by the inference model ranges from 2 to N, which can be set by relevant personnel, and the inference length can also be adjusted by the confidence of the inference model.

[0025] In some examples, after the speculation model outputs the speculation time steps based on the prompt word, the speculation model outputs the speculation time steps to the target model, so that the target model generates the reference time steps corresponding to the speculation time steps in parallel based on the plurality of speculation time steps, and the parameter quantity of the target model is greater than the parameter quantity of the speculation model. That is, if the speculation model generates N speculation time steps, the N speculation time steps generated by the speculation model are denoted as A1, A2, A3, A4…An, and the target model generates the reference time steps B1, B2, B3, B4…Bn corresponding to the speculation time steps in parallel based on A1, A2, A3, A4…An, wherein the speculation time step A1 corresponds to the reference time step B1, the speculation time step A2 corresponds to the reference time step B2, and so on.

[0026] In the present application, the target model generates the reference time steps corresponding to the plurality of speculation time steps in parallel, which improves the efficiency of the target model in generating the reference time steps and avoids the problem of slow inference speed, delay and the like caused by the target model generating the reference time steps one by one based on the prompt word.

[0027] Specifically, the plurality of speculation time steps are input to the target model, so that the target model generates the reference time steps corresponding to the plurality of speculation time steps in parallel, including: inputting the plurality of speculation time steps to the target model, so that the target model generates the corresponding reference time steps for the first to the Nth speculation time steps in parallel, wherein the reference time step corresponding to the ith speculation time step is generated according to the first to the (i-1)th speculation time steps, N is the number of the plurality of speculation time steps (N is an integer greater than or equal to 2), and the value range of i is 2 to N; for example, the N speculation time steps generated by the speculation model are denoted as A1, A2, A3, A4…An, then when i is 2, the target model generates the reference time step B2 corresponding to the speculation time step A2 based on the speculation time step A1; when i is 3, the target model generates the reference time step B3 corresponding to the speculation time step A3 based on the speculation time steps A1 and A2; and so on. When i is N, the target model generates the reference time step BN corresponding to the speculation time step AN based on the speculation time steps A1, A2…AN-1, and the above process of generating the reference time steps is performed in parallel by the target model, thereby improving the efficiency of the target model in generating the reference time steps and avoiding the problem of slow inference speed, delay and the like caused by the target model generating the reference time steps one by one based on the prompt word.

[0028] It can be understood that the value range of i is 2 to N, and therefore the above step discloses a step of generating a corresponding reference time step for the target model from the second prediction time step to the Nth prediction time step. In some examples, generating a corresponding reference time step for the target model from the first prediction time step includes directly taking the first prediction time step as the reference time step (i.e., the target model assumes that the first prediction time step is correct by default), or directly generating a reference time step corresponding to the first prediction time step based on the prompt word. Generating a corresponding reference time step for the target model from the first prediction time step is also performed in parallel with generating a corresponding reference time step for the target model from the second prediction time step to the Nth prediction time step, thereby improving the efficiency of generating a reference time step by the target model and avoiding the problem of slow reasoning speed, delay, and the like caused by generating a reference time step one by one based on the prompt word by the target model.

[0029] In some examples, the present application inputs multiple prediction time steps and multiple reference time steps into the process reward model, so that the process reward model verifies the corresponding prediction time steps based on the reference time steps. Specifically, the multiple prediction time steps include A1, A2, A3, A4…An, and the multiple reference time steps include B1, B2, B3, B4…Bn. The process reward model verifies the prediction time step A1 based on the reference time step B1, verifies the prediction time step A2 based on the reference time step B2, and verifies the prediction time step An based on the reference time step Bn.

[0030] In some examples, when the process reward model determines that the verification result of the prediction time step is passed, the prediction time step is taken as the output of the target model to determine the response text corresponding to the prompt word. Since the process reward model verifies the prediction time step, the accuracy of the prediction time step is guaranteed. When the verification result is passed, the prediction time step is taken as the output of the target model, thereby making the final output of the prediction time step close to the level of the target model alone reasoning. The output quality of the output response text is guaranteed, and the reasoning speed is improved.

[0031] According to the technical scheme provided in the embodiments of the present application, the prediction model generates prediction time steps, and because the parameter quantity of the prediction model is less than that of the target model, the prediction model can quickly generate multiple prediction time steps compared with the target model, which equivalently reduces the number of times of calling the target model. For example, if the prediction model proposes an average of 3 prediction time steps, and the target model passes the verification once, the frequency of calling the target model is reduced to about 1 / 3, thereby improving the efficiency of the target model in generating response text. In addition, considering the partial parallelism of the target model and the prediction model / process reward model, the present application can improve the overall generation speed of the response text by more than 2 times. Furthermore, the target model+process reward model checks the prediction time steps output by the prediction model, so that the quality of the final output prediction time steps is close to the level of the target model alone. Especially in logical reasoning tasks, the process reward model can ensure that each intermediate step is correct, greatly reducing the risk of error accumulation caused by the prediction model guessing randomly. For example, in mathematical calculation, multi-hop reasoning and other scenarios, the present application based on the prediction model, the target model and the process reward model can make the output reasoning steps consistent with the standard solution, thereby ensuring the correctness of the response text generated by the target text.

[0032] In some embodiments, as shown in Figure 2 The plurality of prediction time steps and the plurality of reference time steps are input into the process reward model, so that the process reward model verifies the corresponding prediction time step based on the reference time step, including:

[0033] S201, inputting a plurality of prediction time steps and a plurality of reference time steps into a process reward model, so that the process reward model respectively obtains a score of each prediction time step and each reference time step;

[0034] S202, determining a verification result corresponding to each prediction time step according to the score of each prediction time step and the score of the reference time step corresponding to each prediction time step.

[0035] The process reward model verifies each reasoning prediction time step generated by the prediction model. Specifically, the process reward model gives a process quality score according to the context of the prediction time step. For example, in the code generation scenario, the process reward model judges whether the newly added line of code (a prediction time step) may introduce syntax / logic errors; in the mathematical reasoning scenario, the process reward model evaluates whether the current step calculation (prediction time step) is correct, thereby obtaining a score of each prediction time step.

[0036] Similarly, based on the same principle, the process reward model scores each reference time step, which will not be described here.

[0037] The application determines a verification result corresponding to each speculative time step based on the score of each speculative time step and the score of the reference time step corresponding to each speculative time step. Specifically, the plurality of speculative time steps include A1, A2, A3, A4…An, and the plurality of reference time steps include B1, B2, B3, B4…Bn. The process reward model verifies the speculative time step A1 based on the reference time step B1, verifies the speculative time step A2 based on the reference time step B2, and verifies the speculative time step An based on the reference time step Bn. The application determines the verification result of A1 based on the score of the speculative time step A1 and the score of the reference time step B1.

[0038] Specifically, the verification result corresponding to each speculative time step is determined based on the score of each speculative time step and the score of the reference time step corresponding to each speculative time step, including: comparing the score of the speculative time step and the score of the reference time step, and determining the verification result corresponding to the speculative time step according to the comparison result; or, obtaining the score difference between the score of the speculative time step and the score of the reference time step, comparing the score difference with a pre-set difference threshold, and determining the verification result corresponding to the speculative time step according to the comparison result.

[0039] In the above example, the score of the speculative time step and the score of the reference time step are compared, and the verification result corresponding to the speculative time step is determined according to the comparison result, including: comparing the score of the speculative time step and the score of the reference time step, if the comparison result represents that the score of the speculative time step is greater than or equal to the score of the reference time step, then the verification result corresponding to the speculative time step is determined to be verified, and if the comparison result represents that the score of the speculative time step is less than the score of the reference time step, then the verification result corresponding to the speculative time step is determined to be not verified.

[0040] For example, the speculative time step includes A1 and the reference time step B1, after obtaining the score X of the speculative time step A1 and the score Y of the reference time step B1, if X is greater than or equal to Y, then the verification of the speculative time step A1 is determined to be passed, and if X is less than Y, then the verification of the speculative time step A1 is determined to be not passed.

[0041] In some examples, the score difference between the score of the speculative time step and the score of the reference time step is obtained by: subtracting the score of the corresponding reference time step from the score of the speculative time step to obtain a difference value, and taking the absolute value of the difference value as the score difference; and determining the verification result corresponding to the speculative time step according to the difference comparison result, including: if the difference comparison result indicates that the score difference is greater than a pre-set difference threshold, determining that the verification result of the speculative time step is verification failure; or if the difference comparison result indicates that the score difference is less than or equal to the pre-set difference threshold, determining that the verification result of the speculative time step is verification success. It can be understood that the difference threshold is a value set by relevant personnel according to actual conditions.

[0042] For example, the speculative time step corresponds to the reference time step B1, and after obtaining the score X of the speculative time step A1 and the score Y of the reference time step B1, the difference between X and Y is calculated, the absolute value of the difference between X and Y is taken as the score difference, and then the score difference is compared with the pre-set difference threshold. If the score difference is greater than the difference threshold, it is determined that the verification result of the speculative time step is verification failure; or if the score difference is less than or equal to the difference threshold, it is determined that the verification result of the speculative time step is verification success.

[0043] In some examples, the verification result corresponding to each speculative time step is determined according to the score of each speculative time step and the score of the reference time step corresponding to each speculative time step, including: comparing the score of the speculative time step with the score of the reference time step, comparing the score difference with a pre-set difference threshold according to the score comparison result, and determining the verification result corresponding to the speculative time step according to the score comparison result and the difference comparison result; specifically, if the score comparison result indicates that the score of the speculative time step is greater than or equal to the score of the reference time step, and the difference comparison result indicates that the score difference is less than or equal to the pre-set difference threshold, it is determined that the verification result corresponding to the speculative time step is verification success; or if the score comparison result indicates that the score of the speculative time step is less than the score of the reference time step, or the difference comparison result indicates that the score difference is greater than the pre-set difference threshold, it is determined that the verification result corresponding to the speculative time step is verification failure.

[0044] According to the technical scheme provided in the embodiments of the present application, the process reward model determines the verification result of each speculative time step through the score of each speculative time step and the score of each reference time step, thereby improving the accuracy of the verification result.

[0045] In some embodiments, the method further comprises: in a case where the process reward model determines that the verification result of the speculative time step is failed, sending the reference time step corresponding to the speculative time step to the speculation model, so that the speculation model generates a new speculative time step according to the received reference time step. Specifically, in a case where a certain speculative time step of the speculation model fails in the verification of the process reward score, the target module will reject the speculative time steps after the problem point (the speculative time step that fails in the verification), at this time, the target model directly takes over the generation from the problem point, that is, the speculative time step whose verification result is failed in this time is discarded, and the target model generates a correct reference time step by itself, and then determines whether the subsequent speculative time steps generated by the speculation model are consistent with the target model after the speculation model continues to speculate the subsequent. The present application realizes timely error correction of the speculation model by the target model and the process reward model when the speculation model makes an error, and ensures the accuracy of the speculative time steps generated by the speculation model.

[0046] In some embodiments, the method further comprises: in a case where the process reward model determines that the verification result of the speculative time step is failed, recording the number of verification results that are failed, and in a case where the number of failed verification results is higher than a pre-set failure threshold number, reducing the speculation length of the speculation model; in a case where the process reward model determines that the verification result of the speculative time step is passed, recording the number of verification results that are passed, and in a case where the number of passed verification results is higher than a pre-set passing threshold number, increasing the speculation length of the speculation model. That is, in the scheme provided by the present application, when multiple speculative time steps are rejected (verification failed), the speculation length (i.e., the number of generated speculative time steps) of each speculation of the speculation model can be adaptively shortened to improve the passing rate of the speculative time steps output by the speculation model; on the contrary, if multiple speculative time steps are successfully verified, the speculation length of the speculation model can be increased to obtain a higher acceleration ratio. Through such dynamic adjustment, the probability of the small model proposal being accepted is maximized, and invalid calculations are reduced.

[0047] In some examples, the present application can also pre-set a minimum speculation length and a maximum speculation length of the speculation model, and the speculation length of the speculation model will not be reduced when the speculation length reaches the minimum speculation length, and the speculation length of the speculation model will not be increased when the speculation length reaches the maximum speculation length.

[0048] In some examples, the present application can also set the speculation length of the speculation model as a fixed value, and the speculation length of the speculation model will not be increased or reduced subsequently.

[0049] In some examples, the plurality of speculative time steps are input to the target model, including: determining a task difficulty corresponding to the prompt; and in a case where the task difficulty exceeds a threshold, inputting the plurality of speculative time steps to the target model. In some examples, in a case where an inference computing budget is fixed, in order to achieve the effect of saving inference computing resources, the present application can flexibly adjust the ratio of use of the speculative model and the target model, thereby improving resource utilization. Specifically, since the speculative model has low computing overhead, if the task is simple, the speculative model can complete the main work (i.e., directly using the speculative time step output by the speculative model as the output of the target model), without the need to use the target model; only in the case of complex situations or uncertain parts (i.e., in the case where the task difficulty exceeds the threshold), the target model is called to generate the corresponding reference time step. This on-demand use of the target model strategy makes it possible to serve more requests with limited GPU / TPU resources when deploying. When the hardware is limited, the present application is particularly meaningful, because the present application provides a method for sharing the load with the speculative model while maintaining the effect of the target model.

[0050] In order to better understand the present application, a more specific example is provided in the present embodiment for illustration, which is as follows:

[0051] In the present application, the target model is referred to as a large model, and the speculative model is referred to as a small model. After the large model reads a prompt, it does not directly generate a response text, but instead passes the prompt to the small model for exploratory continuation. The small model quickly generates several possible subsequent speculative steps as drafts (the length can be 2 steps to multiple steps, and the speculative length of the small model is adjusted by a preset threshold or small model confidence). Then, these speculative steps are sent to the large model for review. The large model outputs multiple reference steps in parallel for each speculative step, and the PRM checks whether the logical process of the speculative step is reasonable to check whether the speculative step meets the task requirements. If the speculative step passes the PRM check as a whole (the score of the speculative time step is not lower than the score of the reference step output by the large model), then these speculative steps are confirmed as the output of the target model, which is equivalent to the large model "agreeing" with the proposal of the small model, and the large model generates multiple steps at once. Then, the decoding process continues, and the small model continues to generate the next batch of speculative time steps from the new position, and the large model verifies again in parallel. Through this alternating advancement, the generation of a complete answer is gradually completed.

[0052] If in a certain verification, the score of the small model's speculative step on the PRM is originally lower than the score of the reference step of the large model, the large model will reject the speculative step after the problem point. The present application provides two processing strategies: (1) immediate fallback: the large model directly takes over generation from the position where the problem point occurs, i.e. discarding the part of the speculative step of the small model that fails to pass the verification, generating the correct step by the large model itself, and then returning the small model to continue speculating the subsequent, which ensures that the final output is consistent with the independent generation of the large model, only slightly sacrificing speed at the error point for correction. (2) Adjust the length of the draft: when multiple speculative steps are rejected, the length of each speculation of the small model can be adaptively shortened (the number of steps), or even reduced to one step at a time, to improve the pass rate; on the contrary, if multiple verifications are successfully passed, the length of the small model's single speculation can be increased to obtain a higher speedup ratio. Through this dynamic adjustment, the probability of the small model's proposal being accepted is maximized, and invalid calculations are reduced.

[0053] It is worth mentioning that the parallel verification in the present application can make full use of modern multi-core and multi-card hardware: while the small model generates the next speculative step, the large model and the PRM verify the previous speculative step on another computing unit, and the small model, the large model and the PRM exchange data through a shared buffer. In this way, the small model and the large model / PRM can almost run at the same time, further reducing the overall delay. For example, on a GPU cluster, the small model runs on one card, and the large model runs on multiple cards in parallel to score, greatly improving the throughput. Even on a single card, since the small model has much less computational overhead than the large model, the small model generates a batch of tokens first, and then uses the same card to verify the large model, which is still faster than the large model that calculates every step.

[0054] In summary, the scheme of the present application realizes two optimizations of large language model inference through the decoding mode of "small model fast guess, large model + PRM check": first, the frequency of the large model participating in inference is reduced (from calling every step to calling once every few steps), and second, the PRM is used to ensure that even if the small model participates, the intermediate inference steps are within a controlled range and do not accumulate errors. In this way, the generation time is greatly shortened without significantly changing the quality of the final output.

[0055] Introducing a process reward model to participate in verification: traditional speculative decoding mainly relies on the probability distribution of the large model itself to accept or reject the candidate output of the small model, and essentially focuses on the consistency of the output distribution. The present application adds the evaluation of the correctness of the inference process by the PRM as a decision factor. This means that the verification standard includes "whether the candidate inference step is logically reasonable", which further improves the accuracy of the speculative time steps of the final output.

[0056] The present application emphasizes step-level fine-grained collaboration between small models, large models, and process reward models: according to the prompt word, the output is divided into logical steps (for example, each step of the problem, each line of code, each semantic unit of the dialogue), and the small model generates the content of each step, and the large model verifies the step in real time. This granularity allows the process supervision of the PRM to precisely act on each reasoning link, distinguishing it from previous solutions that only look at the correctness of the overall output.

[0057] The present application ensures the output speed of the target model while maintaining the final output quality of the target model: unlike most model compression, distillation, and other methods that improve the target model, the present application improves the final output effect of the target model by supervising the correctness of the output of the PRM in the inference time step. In this process, even if there is a deviation in the inference time step of the output of the inference model, the error correction mechanism ensures that it continues after correction and does not output results that deviate from the correct answer due to errors in the small model. The present application introduces another model (PRM) to assist in verification, rather than relying solely on the large model to verify the draft.

[0058] The present application is non-invasive to the small model and the large model itself, avoiding the problem of increasing the training steps of the small model and the large model, resulting in increased training costs. The present application does not require changes to the internal structure of the large model and the small model, nor does it require additional training (the small model and the PRM can be fine-tuned using existing open-source models). For example, the small model can use a small parameter version with the same architecture as the large model or other models, and the PRM is trained from public process supervision data. Compared to some methods that require modification of the calculation order of the Transformer layer or the addition of specific modules, the present application has less impact on the underlying implementation and is easy to integrate into existing LLM inference frameworks.

[0059] In the present application, the fusion inference acceleration and quality improvement of the target model are realized. Related technologies often treat acceleration and improvement of inference reliability as different directions, resulting in the need for more calculations. The present application combines acceleration and improvement of inference reliability through the cooperation of small models, large models, and process reward models. While accelerating, the PRM is used to improve the accuracy of each inference step, avoiding the quality decline that may be caused by previous acceleration. The present application combines "small model acceleration" and "large model + process reward model quality preservation" into one, a balanced approach to process reliability and explainability improvement: with the help of PRM evaluation of steps, the present application can identify intermediate errors in the output in a timely manner and correct them immediately, making the generation process more reliable. In addition, PRM scoring can also be used to produce certain explanation information, such as marking the key steps of model inference and where corrections have been made. This is helpful for analyzing the decision path of the model and improving the reliability of the results. Compared to traditional LLMs, which implicitly include the inference process in the attention mechanism, the present application makes part of the inference process "explicit", which is conducive to debugging and security monitoring.

[0060] In some examples, the application can select different training data to train the reward model, thereby improving the generalization flexibility of the overall scheme. Specifically, by selecting different training data PRM, the scheme provided by the application can adapt to different types of task scenarios. For example, a special code PRM can be used to evaluate the syntax and functional correctness in code generation, a mathematical PRM can be used to evaluate formula derivation, and a common sense PRM can be used to evaluate the consistency of facts in dialogue. The scheme provided by the application can accommodate process supervision signals in various fields, thereby ensuring quality in a wide range of applications.

[0061] The following lists some typical applications of the response text generation method provided by the application:

[0062] 1. Intelligent dialogue (Chatbot), in customer service Q&A, intelligent assistant and other chat scenarios, response speed is very critical. The response text generation method in the application can be used for intelligent dialogue, such as after the user asks a question, the small model first quickly gives a reply draft (speculative time step), and the large model + PRM verifies its politeness, accuracy and safety. If the draft passes, the user will immediately get a reply; if there is a problem, the large model will fine-tune the answer and output it. The user hardly feels the difference in delay, but can get the answer quality close to the large model after careful consideration.

[0063] 2. Code generation and debugging, in programming assistant scenarios (such as Copilot type plug-ins), when the user inputs a function description or error log, the small model can quickly generate a code draft or repair suggestion (speculative time step), and the large model and code PRM check the correctness of the draft (whether the syntax is correct, the logic is reasonable, and whether it is possible to introduce new bugs, etc.). For suggestions that pass the check, provide them directly to the developer, and for those that do not pass, provide more authoritative modifications by the large model. In this way, programmers can see the preliminary scheme immediately, and rely on the system to ensure a certain correctness, greatly improving development efficiency.

[0064] 3. Complex problem solving (mathematics, reasoning Q&A), in problems that require step-by-step reasoning (such as mathematical proofs, multi-step reasoning Q&A), the application can let the small model try to reason each step, such as each step of transforming an equation or each clue derivation of a reasoning question (speculative time step), and the large model and mathematical PRM check whether each step is correct. If all steps pass, the small model has actually completed the reasoning independently, and gets the answer very quickly; if a step is wrong, the large model identifies and corrects it in time, and then the small model continues to try the subsequent part. The user finally gets both the complete solution process and the correct answer, and the response time is much faster than having the large model reason from start to finish.

[0065] 4、Knowledge Q&A and information retrieval. In a Q&A system, sometimes it is needed to find an answer from a large amount of knowledge. A small model can quickly generate a possible answer draft or list several candidate answers (speculation time steps), and a large model acts as a "judge" to check whether these answers are consistent with the knowledge base and whether there are loopholes with the help of PRM (integrable fact verification mechanism). If obvious errors are found, the large model can find the correct answer to supplement. In this scenario, the application can accelerate the answer output and ensure the credibility of the answer through PRM, so as to be applied to high-accuracy QA systems such as medical inquiry assistants (quickly provide suggestions but avoid mistakes by large model verification).

[0066] 4、Autonomous agent. For an agent with planning and execution capabilities, the application can be used to accelerate its decision-making process. For example, in a task planning agent, a small model quickly formulates a series of action step plans (speculation time steps), and a large model jointly audits the feasibility, safety, and compliance with user goals of these plans with the help of PRM. If the small model's plan is reasonable, the agent immediately enters execution, improving response speed; if there is something wrong, the large model adjusts the plan. Similarly, in a conversational agent, a small model can generate the next dialogue action (asking, answering, calling tools, etc.), PRM judges whether the action is appropriate (such as whether it violates rules), and a large model evaluates the strategy score to finally decide whether to adopt it. In this way, the agent can think quickly and act cautiously, maintaining stability in complex interactions.

[0067] 5、Other fields: including machine translation (small model first, large model polishing and checking terminology and grammar), abstract generation (small model abstract draft, large model checking whether key information is missed), content creation (small model continuing writing article paragraphs, large model maintaining style consistency and avoiding deviation), etc. Wherever quality and efficiency are required, the application's solution can be considered. For example, in multi-modal applications, a small model can also be extended to generate a preliminary image description, and a large model + PRM can check the description accuracy, etc.

[0068] The response text generation method provided by the application will be described in detail below through a specific embodiment. This embodiment is for a code generation scenario and shows how to use a small model, a large model, and a process reward model to automatically complete code and accelerate high-quality code output. It should be noted that this is only one of many possible implementations, and actual applications can be adjusted as needed.

[0069] Embodiment: Code completion assistant.

[0070] Scenario: When a developer is writing code in an IDE, an AI assistant is called to complete the next several lines of code based on the context. The requirement is that the completion result is correctly executed and the style conforms to the project specification.

[0071] System components: a 7B-parameter code language model as the “small model”, a 70B-parameter code large model as the “large model”, and a specially trained “code process reward model (Code-PRM)”. Code-PRM can evaluate the correctness of the code line by line, including syntax legality, variable reference validity, logic reasonableness, etc. (which can be trained on a large amount of code data with unit tests, and whether each line of code passes compilation / test as a process label).

[0072] Completion trigger: when the developer inputs the beginning of a function and triggers the completion request by line break, the AI assistant first reads the current file context (function signature, existing code, etc.). This is provided as a prompt to the small model and the large model. Assuming the logic that needs to be completed is relatively complex, such as implementing an algorithm detail, the assistant will tend to involve the large model more to check.

[0073] Small model speculation generation: After the small model receives the prompt, it quickly generates the next possible code draft. For example, it predicts that the next line may be “initialize some variables”, and outputs a line of code draft: “int count = 0;”. Based on its internal judgment, the small model continues to predict the next two lines and outputs three lines of code draft, forming a draft block. For example:

[0074] int count = 0;

[0075] for(int i=0; i<n; ++i) { / / ...some logic...

[0076] }。

[0077] The above code is a 3-line code snippet speculated by the small model (including an unfinished loop logic).

[0078] Large model parallel verification: At the same time that the small model outputs the above code snippet, the large model will receive the same prompt and the small model's code snippet. The large model will not immediately provide the draft to the user, but will verify the 3 lines of code.

[0079] The large model generates these three steps in parallel. At the same time, Code-PRM checks these 3 lines of code line by line and gives a process reward score. For example: the first line defines a variable and gets a high score for correct syntax; the second line for loop has correct syntax, but PRM notices that the loop body is not yet filled in (with the comment / / ...some logic... placeholder), which is not an error in itself because the code is incomplete; the third line is just a closing bracket}, and PRM may not give a negative evaluation at this time without seeing the complete loop body, but will score it in the context. The score of the small model's code snippet is not much different from the score of the large model's output code snippet. In summary, assuming that PRM considers the draft snippet to be currently free of obvious errors (such as syntax errors) and structurally reasonable.

[0080] Verification decision: According to PRM score. If the three lines of draft are passed (PRM score is qualified), the large model accepts the three lines of draft. At this time, the AI assistant will immediately display the first line of code "int count = 0;" to the developer (or choose to display it line by line after the complete block is verified, depending on the product interaction). And, the content of these three lines of code is temporarily added to the current context, preparing for subsequent generation. Important: Since the small model draft prompted an incomplete loop PRM sees the comment bit prompt "there is logic to fill in", it is not considered an error. Therefore, the verification module as a whole judges that the draft is a partial code snippet and can be accepted.

[0081] Iterative generation: Now the context contains the "small model generation and verification passed" three lines of code, and the cursor is at the comment position, ready to complete the text logic. At this time, the system again asks the small model to continue to speculate from this position. The small model reads the context and tries to fill in the for loop logic. For example, it generates "if(arr[i]>0) { count += arr[i];} " as the two lines of code inside the loop, and then considers the loop complete and stops speculation. The small model's output candidate for this round is:

[0082] if(arr[i]>0) {

[0083] count += arr[i];

[0084] }。

[0085] Subsequently, the large model verifies these two lines: probabilistic verification: the large model evaluates that this logic is very reasonable in the current scenario (sum of positive numbers), and belongs to a high probability output. PRM verification: Code-PRM checks the syntax and finds that it is correct, and references the already defined arr array and count variable, everything is legal. At the same time, it is noticed that the loop body is now filled in, and these two lines complete the previous logic. PRM gives a positive evaluation.

[0086] Both lines are verified, and the large model accepts and outputs them. Now the complete code completion content has been generated:

[0087] int count = 0;

[0088] for(int i = 0; i<n; ++i) {if(arr[i]>0) {

[0089] count += arr[i];

[0090] }

[0091] }。

[0092] Exception handling: Suppose in a certain round, the small model generates a fragment that is not very good in semantics or logic, for example, it mistakenly guesses an implementation that does not conform to the intention. For example: it may mistakenly produce a line like count = i;. The PRM will find that the logic is unreasonable (it is not reasonable to assign the counter to the index i without any reason). At this time, the PRM gives a low score, and the large model judges that it does not pass. The present application will execute the correction mechanism described earlier: the large model discards the bad candidate of the small model, and generates a more reasonable code to replace the line (for example, the large model outputs / / TODO: implement logic or directly gives the correct logic). Then continue the subsequent process. In the whole process, the user finally sees the completion result that has been corrected and the correct code.

[0093] Output completion: When the small model detects that the required code block has been completed (for example, encountering a logic end symbol or function completion), or reaching the preset maximum completion length, the decoding process terminates. The large model may make a final overall check (using the PRM to ensure that there are no unclosed parentheses, etc.). Finally, the code presented to the developer in the IDE is the high-quality code generated through the above-mentioned cooperation and verification. Since most of the lines are quickly generated by the small model, the entire completion process takes nearly half the time of the pure 70B model generating line by line, and with the supervision of the PRM, the code can be directly run without additional modification by the developer.

[0094] Performance analysis: In this embodiment, the small model generates a total of 5 lines of code, and the large model actually only generates (or modifies) a small number of lines that may have errors, and the rest of the time is only verification. Based on experience, the reasoning speed of the small model 7B is usually several times that of the 70B model, so the overall delay is significantly reduced. At the same time, the output code quality is comparable to that of the 70B model, and some common vulnerabilities of the small model are avoided. This proves that the present application realizes "fast coding, correct coding" in the high-value scenario of code completion.

[0095] For other application scenarios, the implementation is similar to the above: adjust the size of the small model and the training data to adapt to the task language style, and output reasonable drafts at high speed; train or select appropriate PRMs for process evaluation (such as safety PRMs for detecting inappropriate speech in dialogue scenarios); set draft length and verification strictness threshold on the decoding process according to the characteristics of the scene (such as safety-related tasks that can require PRM scores to be very high to pass). Through these adjustments, the present application can be widely applied while playing its acceleration and quality preservation utility.

[0096] All the optional technical solutions described above can be combined to form optional embodiments of the present application, which will not be described one by one here.

[0097] The following is an embodiment of the device of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.

[0098] The present embodiment also provides a response text generation device, as shown in Figure 3 The device comprises:

[0099] The inference module 301 is configured to obtain a plurality of inference time steps generated by an inference model based on a prompt word;

[0100] The reference module 302 is configured to input the plurality of inference time steps to a target model, so that the target model generates reference time steps corresponding to the plurality of inference time steps in parallel based on the plurality of inference time steps, and the number of parameters of the target model is greater than the number of parameters of the inference model;

[0101] The verification module 303 is configured to input the plurality of inference time steps and the plurality of reference time steps to a process reward model, so that the process reward model verifies the corresponding inference time steps based on the reference time steps;

[0102] The output module 304 is configured to, when the process reward model determines that the verification result of the inference time steps is passed, take the inference time steps as the output of the target model to determine the response text corresponding to the prompt word.

[0103] In some examples, inputting the plurality of inference time steps to the target model so that the target model generates reference time steps corresponding to the plurality of inference time steps in parallel based on the plurality of inference time steps comprises: inputting the plurality of inference time steps to the target model so that the target model generates corresponding reference time steps for the first to the Nth inference time steps in parallel, wherein the reference time step corresponding to the ith inference time step is generated according to the first to the i-1th inference time steps, and N is the number of the plurality of inference time steps, and i ranges from 2 to N.

[0104] In some examples, inputting the plurality of speculative time steps and the plurality of reference time steps into the process reward model such that the process reward model validates the corresponding speculative time step based on the reference time step comprises: inputting the plurality of speculative time steps and the plurality of reference time steps into the process reward model such that the process reward model respectively obtains a score of each speculative time step and a score of each reference time step; and determining a validation result corresponding to each speculative time step according to the score of each speculative time step and the score of the reference time step corresponding to each speculative time step.

[0105] In some examples, determining the validation result corresponding to each speculative time step according to the score of each speculative time step and the score of the reference time step corresponding to each speculative time step comprises: comparing the score of the speculative time step and the score of the reference time step, and determining the validation result corresponding to the speculative time step according to a comparison result of the scores; or, obtaining a score difference between the score of the speculative time step and the score of the reference time step, comparing the score difference with a pre-set difference threshold, and determining the validation result corresponding to the speculative time step according to a comparison result of the difference.

[0106] In some examples, the validation module 303 is further configured to, in a case where the process reward model determines that the validation result of the speculative time step is failed, send the reference time step corresponding to the speculative time step to the speculation model, so that the speculation model generates a new speculative time step according to the received reference time step.

[0107] In some examples, the apparatus further comprises an adjustment module configured to, in a case where the process reward model determines that the validation result of the speculative time step is failed, record a number of failed validation results, and in a case where the recorded number of failed validation results is higher than a pre-set failed threshold number, reduce a speculation length of the speculation model; and in a case where the process reward model determines that the validation result of the speculative time step is passed, record a number of passed validation results, and in a case where the recorded number of passed validation results is higher than a pre-set passed threshold number, increase the speculation length of the speculation model.

[0108] In some examples, inputting the plurality of speculative time steps into the target model comprises: determining a task difficulty corresponding to the prompt word; and in a case where the task difficulty exceeds a threshold, inputting the plurality of speculative time steps into the target model.

[0109] According to the technical solution provided in this application, speculative time steps are generated through a speculative model. Since the speculative model has fewer parameters than the target model, it can generate multiple speculative time steps more quickly than the target model, effectively reducing the number of calls to the target model. For example, if the target model verifies every three speculative time steps proposed by the speculative model on average, the target model's call frequency is reduced to about one-third of its original frequency, thereby improving the target model's response efficiency. Considering the partial parallelism between the target model and the speculative model / process reward model, this application can increase the overall response text generation speed by more than two times. Furthermore, because the target model and the process reward model monitor the speculative time steps output by the speculative model, the quality of the final output speculative time steps is close to the level of the target model's independent reasoning. Especially in logical reasoning tasks, the process reward model ensures the correctness of each intermediate step, significantly reducing the risk of error accumulation caused by "random guessing by the speculative model." For example, in mathematical calculations and multi-hop reasoning scenarios, this application, based on the speculative model, the target model, and the process reward model, ensures that the output reasoning steps are consistent with the standard solution, thereby guaranteeing the correctness of the response text.

[0110] Figure 4 This is a schematic diagram of the electronic device 4 provided in an embodiment of this application. Figure 4 As shown, the electronic device 4 of this embodiment includes: a processor 401, a memory 402, and a computer program 403 stored in the memory 402 and executable on the processor 401. When the processor 401 executes the computer program 403, it implements the steps in the various method embodiments described above. Alternatively, when the processor 401 executes the computer program 403, it implements the functions of each module / unit in the various device embodiments described above.

[0111] Electronic device 4 can be a desktop computer, laptop, handheld computer, cloud server, or other electronic device. Electronic device 4 may include, but is not limited to, processor 401 and memory 402. Those skilled in the art will understand that... Figure 4 This is merely an example of electronic device 4 and does not constitute a limitation on electronic device 4. It may include more or fewer components than shown, or different components.

[0112] The processor 401 can be a central processing unit (CPU), other general purpose processors, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or the like.

[0113] The memory 402 can be an internal storage unit of the electronic device 4, for example, a hard disk or a memory of the electronic device 4. The memory 402 can also be an external storage device of the electronic device 4, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, or the like equipped on the electronic device 4. The memory 402 can also include both the internal storage unit and the external storage device of the electronic device 4. The memory 402 is used to store computer programs and other programs and data required by the electronic device.

[0114] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above functional units and modules is exemplified, and in actual application, the above functions can be completed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to complete all or part of the above described functions. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit, and the integrated unit can be realized in the form of hardware or in the form of software functional unit.

[0115] The integrated modules / units, if implemented in the form of software functional units and sold or used as independent products, can be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the above-mentioned embodiment methods can also be completed by a computer program instructing related hardware, and the computer program can be stored in a computer readable storage medium. The computer program can be executed by a processor to implement the steps of the above-mentioned various method embodiments. The computer program can include computer program code, which can be in the form of source code, object code, executable files, or some intermediate forms. The computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), electric carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content contained in the computer readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, the computer readable medium does not include electric carrier signals and telecommunication signals.

[0116] The above embodiments are only used to illustrate the technical solutions of the present application, rather than limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. A method for generating response text, characterized in that, The method includes: Obtain multiple inference time steps generated by the inference model based on the prompt words; Multiple inferred time steps are input into the target model, so that the target model generates reference time steps corresponding to the inferred time steps in parallel based on the multiple inferred time steps, and the number of parameters of the target model is greater than the number of parameters of the inferred model. Multiple predicted time steps and multiple reference time steps are input into the process reward model, so that the process reward model verifies the corresponding predicted time steps based on the reference time steps; When the process reward model determines that the verification result of the inferred time step is passed, the inferred time step is used as the output of the target model to determine the response text corresponding to the prompt word; Inputting multiple speculative time steps into a target model, such that the target model generates reference time steps corresponding to the speculative time steps in parallel based on the multiple speculative time steps, includes: inputting multiple speculative time steps into the target model, such that the target model generates reference time steps corresponding to the 1st to Nth speculative time steps in parallel, wherein the reference time step corresponding to the i-th speculative time step is generated based on the 1st to i-1th speculative time steps, N is the number of multiple speculative time steps, and the value of i ranges from 2 to N.

2. The method according to claim 1, characterized in that, Inputting multiple predicted time steps and multiple reference time steps into a process reward model, such that the process reward model validates the corresponding predicted time steps based on the reference time steps, includes: The process reward model is input into the multiple predicted time steps and the multiple reference time steps, so that the process reward model obtains a score for each predicted time step and each reference time step respectively; The verification result corresponding to each of the inferred time steps is determined based on the score of each inferred time step and the score of the reference time step corresponding to each inferred time step.

3. The method according to claim 2, characterized in that, Based on the score of each predicted time step and the score of the reference time step corresponding to each predicted time step, the verification result corresponding to each predicted time step is determined, including: The score of the inferred time step is compared with the score of the reference time step, and the verification result corresponding to the inferred time step is determined based on the score comparison result. or, The score difference between the score of the inferred time step and the score of the reference time step is obtained. The score difference is compared with a preset difference threshold. Based on the difference comparison result, the verification result corresponding to the inferred time step is determined.

4. The method according to claim 1, characterized in that, The method further includes: If the process reward model determines that the verification result of the inferred time step is unsuccessful, the reference time step corresponding to the inferred time step is sent to the inference model so that the inference model can generate a new inferred time step based on the received reference time step.

5. The method according to claim 1, characterized in that, The method further includes: If the process reward model determines that the verification result of the inference time step is unsuccessful, the number of unsuccessful verification results is recorded. If the number of unsuccessful records is higher than the number of pre-set failure thresholds, the inference length of the inference model is reduced. If the process reward model determines that the verification result of the inference time step is passed, the number of times the verification result is passed is recorded. If the number of times the verification result is passed is higher than the number of times the verification result is passed, the inference length of the inference model is increased.

6. The method according to claim 1, characterized in that, Inputting multiple of the predicted time steps into the target model includes: Determine the task difficulty corresponding to the prompt word; If the task difficulty exceeds the threshold, multiple predicted time steps are input into the target model.

7. A device for generating responsive text, characterized in that, The device includes: The inference module is used to obtain multiple inference time steps generated by the inference model based on the prompt words; A reference module is used to input multiple speculative time steps into a target model, such that the target model generates reference time steps corresponding to the speculative time steps in parallel based on the multiple speculative time steps, wherein the number of parameters of the target model is greater than the number of parameters of the speculative model; inputting multiple speculative time steps into the target model, such that the target model generates reference time steps corresponding to the speculative time steps in parallel based on the multiple speculative time steps, includes: inputting multiple speculative time steps into the target model, such that the target model generates reference time steps corresponding to the 1st to Nth speculative time steps in parallel, wherein the reference time step corresponding to the i-th speculative time step is generated based on the 1st to i-1th speculative time steps, N is the number of multiple speculative time steps, and the value of i ranges from 2 to N; The verification module is used to input multiple predicted time steps and multiple reference time steps into the process reward model, so that the process reward model verifies the corresponding predicted time steps based on the reference time steps; The output module is used to determine the response text corresponding to the prompt word by using the inferred time step as the output of the target model when the process reward model determines that the verification result of the inferred time step is passed.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 6.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Ensemble learning-oriented question and answer method and device under large model fine tuning

    CN118761459A

  • Speculative decoding optimization method, electronic device and storage medium

    CN119761316A