Optimization of model training

DQO addresses the inefficiencies of current LLM training methods by formulating response generation as an MDP and using soft actor-critic for offline learning, enhancing LLM performance on complex tasks through efficient utilization of process rewards.

WO2026081060A1PCT designated stage Publication Date: 2026-04-23BEIJING YOUZHUJU NETWORK TECH CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
BEIJING YOUZHUJU NETWORK TECH CO LTD
Filing Date
2024-10-14
Publication Date
2026-04-23

AI Technical Summary

Technical Problem

Current reinforcement learning methods for large language models (LLMs) are costly and unstable due to online sampling, and bandit-based approaches struggle with multi-step reasoning tasks like math problem-solving and code generation, neglecting intrinsic long-horizon processes.

Method used

Direct Q-function Optimization (DQO) is proposed, formulating the response generation process as a Markov Decision Process (MDP) and using a soft actor-critic framework to directly parameterize the Q-function, incorporating KL-regularization and λ-return for efficient offline learning with process rewards.

Benefits of technology

DQO effectively aligns LLMs with human preferences, improving performance on complex tasks by leveraging offline data and process rewards, outperforming existing methods in multi-step reasoning scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024124837_23042026_PF_FP_ABST
    Figure CN2024124837_23042026_PF_FP_ABST
Patent Text Reader

Abstract

A method for model training, the method comprises: obtaining a data sample for a target machine learning model to be trained; and training the target machine learning model by performing an iterative process comprising: generating, using the target machine learning model, a first likelihood of a predicted response token based on a current token sequence, generating an advantage score for a predicted model response with respect to the current token sequence based on the sample model response, the predicted model response being updated iteratively to comprise the predicted response token, determining a first loss value of a first loss function for the target machine learning model based on the generated likelihood and the advantage score, and updating the target machine learning model based on the first loss value.
Need to check novelty before this filing date? Find Prior Art

Description

OPTIMIZATION OF MODEL TRAININGField

[0001] The disclosed embodiments relate generally to machine learning and, more particularly, to a method, apparatus, device and computer readable storage medium for optimization of model training.Background

[0002] Large language models (LLMs) have shown remarkable performance and potential on a wide range of tasks including dialog generation, general question answering, code generation, agent and math problem solving. To ensure good performance, a procedure is to align the language models with human preference or task-specific requirements by reinforcement learning (RL) . Typically, the alignment training pipeline consists of two stages. In the first stage, a reward model under a Bradley-Terry model is trained on human or environment-labeled preference data. Then, the language model is trained by online RL algorithms like Proximal Policy Optimization (PPO) with the reward signals provided by the reward model trained in stage one. Despite the good performance achieved, the online RL methods usually involve sampling during training, which is both costly and unstable compared to offline methods.Summary

[0003] In a first aspect of the present disclosure, there is provided a method for model training. The method comprises: obtaining a data sample for a target machine learning model to be trained, the target machine learning model being constructed based on a language model, and the data sample comprising a sample prompt input and a sample model response for the target machine learning model; and training the target machine learning model by performing an iterative process comprising: generating, using the target machine learning model, a first likelihood of a predicted response token based on a current token sequence, the current token sequence being initialized to comprise the sample prompt input and being updated iteratively to comprise a predicted response token generated in a previous iteration, generating an advantage score for a predicted model response with respect to the current token sequence based on the sample model response, the predicted model response being updated iteratively to comprise the predicted response token, determining a first loss value of a first loss function for the target machine learning model based on the generated likelihood and the advantage score, and updating the target machine learning model based on the first loss value, where the iterative process is iterated until a training objective is satisfied.

[0004] In a second aspect of the present disclosure, there is provided an apparatus for model training. The apparatus comprises: an obtaining module configured to obtain a data sample for a target machine learning model to be trained. The target machine learning model is constructed based on a language model, and the data sample comprises a sample prompt input and a sample model response for the target machine learning model; and a training module configured to train the target machine learning model by performing an iterative process, where the training module is configured to generate, using the target machine learning mode, a first likelihood of a predicted response token based on a current token sequence, the current token sequence being initialized to comprise the sample prompt input and being updated iteratively to comprise a predicted response token  generated in a previous iteration; generate an advantage score for a predicted model response with respect to the current token sequence based on the sample model response, the predicted model response being updated iteratively to comprise the predicted response token; determine a first loss value of a first loss function for the target machine learning model based on the generated likelihood and the advantage score; and update the target machine learning model based on the first loss value, where the iterative process is iterated until a training objective is satisfied.

[0005] In a third aspect of the present disclosure, there is provided an electronic device. The device comprises at least one processing unit; and at least one memory coupled to the at least one processing unit and storing instructions executable by the at least one processing unit. The instructions, upon execution by the at least one processing unit, cause the device to perform the method of the first aspect.

[0006] In a fourth aspect of the present disclosure, a computer-readable storage medium is provided. The medium stores a computer program which, when executed by a processor, causes the method of the first aspect to be implemented.

[0007] In a fifth aspect of the present disclosure, a computer program product is provided. The computer program product comprises a computer program which, when executed by a processor, causes the method of the first aspect to be implemented.

[0008] It would be appreciated that the content described in the Summary section of the present invention is neither intended to identify key or essential features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will be readily envisaged through the following description.Brief Description of the Drawings

[0009] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent in combination with the accompanying drawings and with reference to the following detailed description. In the drawings, the same or similar reference symbols refer to the same or similar elements, where:

[0010] FIG. 1 illustrates a schematic diagram of an example environment in which embodiments of the present disclosure may be implemented;

[0011] FIG. 2A illustrates an example diagram of a visual demonstration of process reward construction according to some embodiments;

[0012] FIG. 2B illustrates an example diagram of correlation between the trained values (trained without process scores) and the constructed process scores according to some embodiments;

[0013] FIG. 3 illustrates a flow chart of a process for model training in accordance with some embodiments;

[0014] FIG. 4 illustrates a block diagram of an apparatus for model training according to some embodiments; and

[0015] FIG. 5 illustrates a block diagram of an electronic device in which one or more embodiments of the  present disclosure can be implemented.Detailed Description

[0016] The embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the drawings, it would be appreciated that the present disclosure may be implemented in various forms and should not be interpreted as limited to the embodiments described herein. On the contrary, these embodiments are provided for a more thorough and complete understanding of the present disclosure. It would be appreciated that the drawings and embodiments of the present disclosure are only for the purpose of illustration and are not intended to limit the scope of protection of the present disclosure.

[0017] In the description of the embodiments of the present disclosure, the term "including" and similar terms would be appreciated as open inclusion, that is, "including but not limited to" . The term "based on" would be appreciated as "at least partially based on" . The term "one embodiment" or "the embodiment" would be appreciated as "at least one embodiment" . The term "some embodiments" would be appreciated as "at least some embodiments" . Other explicit and implicit definitions may also be included below. As used herein, the term "model" can represent the matching degree between various data. For example, the above matching degree can be obtained based on various technical solutions currently available and / or to be developed in the future.

[0018] It will be appreciated that the data involved in this technical proposal (including but not limited to the data itself, data acquisition or use) shall comply with the requirements of corresponding laws, regulations and relevant provisions.

[0019] It will be appreciated that before using the technical solution disclosed in each embodiment of the present disclosure, users should be informed of the type, the scope of use, the use scenario, etc. of the personal information involved in the present disclosure in an appropriate manner in accordance with relevant laws and regulations, and the user’s authorization should be obtained.

[0020] For example, in response to receiving an active request from a user, a prompt message is sent to the user to explicitly prompt the user that the operation requested operation by the user will need to obtain and use the user's personal information. Thus, users may select whether to provide personal information to the software or the hardware such as an electronic device, an application, a server or a storage medium that perform the operation of the technical solution of the present disclosure according to the prompt information.

[0021] As an optional but non-restrictive implementation, in response to receiving the user's active request, the method of sending prompt information to the user may be, for example, a pop-up window in which prompt information may be presented in text. In addition, pop-up windows may also contain selection controls for users to choose “agree” or “disagree” to provide personal information to electronic devices.

[0022] It will be appreciated that the above notification and acquisition of user authorization process are only schematic and do not limit the implementations of the present disclosure. Other methods that meet relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0023] As used herein, the term "model" can learn a correlation between respective inputs and outputs from  training data, so that a corresponding output can be generated for a given input after training is completed. The generation of the model can be based on machine learning techniques. Deep learning is a machine learning algorithm that processes inputs and provides corresponding outputs by using multiple layers of processing units. A neural networks model is an example of a deep learning-based model. As used herein, "model" may also be referred to as "machine learning model" , "learning model" , "machine learning network" , or "learning network" , and these terms are used interchangeably herein.

[0024] “Neural networks” are a type of machine learning network based on deep learning. Neural networks are capable of processing inputs and providing corresponding outputs, typically comprising input and output layers and one or more hidden layers between the input and output layers. Neural networks used in deep learning applications typically comprise many hidden layers, thereby increasing the depth of the network. The layers of neural networks are sequentially connected so that the output of the previous layer is provided as input to the latter layer, where the input layer receives the input of the neural network and the output of the output layer serves as the final output of the neural network. Each layer of a neural network comprises one or more nodes (also known as processing nodes or neurons) , each of which processes input from the previous layer.

[0025] Usually, machine learning can roughly comprise three stages, namely training stage, test stage, and application stage (also known as inference stage) . During the training stage, a given model can be trained using a large scale of training data, iteratively updating parameter values until the model can obtain consistent inference from the training data that meets the expected objective. Through the training, the model can be considered to learn the correlation between input and output (also known as input-to-output mapping) from the training data. The parameter values of the trained model are determined. In the test stage, test inputs are applied to the trained model to test whether the model can provide correct outputs, thereby determining the performance of the model. In the application stage, the model can be used to process actual inputs and determine corresponding outputs based on the parameter values obtained from training. "

[0026] FIG. 1 illustrates a schematic diagram of an example environment 100 in which embodiments of the present disclosure can be implemented. In the environment 100 of FIG. 1, three different stages of a model are shown, including a training stage 102, a fine-tuning stage (not shown) , and an application stage 106. After the training or fine-tuning stage is completed, there may also be a validation stage, which is not shown in FIG. 1.

[0027] In the training stage 102, a model training system 110 is configured to perform training of a machine learning model 105 using a training dataset 112. At the beginning of training, the model can have initial parameter values. The training process involves updating the parameter values of the machine learning model 105 to expected values based on the training data. In some embodiments, the training stage 102 may involve a pretraining stage and a fine-tuning stage.

[0028] In the application stage 106, the obtained machine learning model 105 has trained parameter values that may be provided to a model application system 130 for use. In the application stage 106, the machine learning model 105 can be used to process a target input 132 in actual scenarios and provide a corresponding target output 134. In some embodiments where the machine learning model 105 is capable of question answering, for example, the machine learning model 105 is a generative model for content generation, the target input 132 may be a prompt input (which can be considered as a question) , and the target output 134 may be a response or  answer for the prompt input. In some examples where the machine learning model 105 is constructed based on a language model, the prompt input may include a text sequence and the response or answer may also include a text sequence for the answer.

[0029] In FIG. 1, the model training system 110 and the model application system 130 may include any computing system with computing capability, such as various computing devices / systems, terminal devices, servers, etc. Terminal devices may involve any type of mobile terminals, fixed terminals, or portable terminals, including mobile phones, desktop computers, laptops, netbooks, tablets, media computers, multimedia tablets, or any combination of the aforementioned, including accessories and peripherals of these devices or any combination thereof. Servers include but are not limited to mainframe, edge computing nodes, computing devices in cloud environment, etc.

[0030] It should be understood that the components and arrangements in the environment 100 shown in FIG. 1 are merely examples, and a computing system suitable for implementing the example embodiments described in the present disclosure may include one or more different components, other components, and / or different arrangements. For example, although shown as separate, the model training system 110 and the model application system 130 may be integrated into the same system or device. The implementation of the present disclosure is not restricted in this regard.

[0031] It should be understood that the structure and function of each element in the environment 100 is described for illustrative purposes only and does not imply any limitations on the scope of the present disclosure.

[0032] As described above, despite the good performance achieved by the online RL methods, the online RL methods usually involve sampling during training, which is both costly and unstable compared to offline methods. These issues are overcome by offline preference learning methods, of which the representative is Direct Preference Optimization (DPO) . DPO and its follow-ups treat the language model as a policy model and a reward model simultaneously and train the language model on offline pairwise preference data directly, therefore eliminating the need for a separate reward model. Though simple, direct preference learning has been shown effective and efficient in LLM alignment.

[0033] However, in practice, sometimes it is hard to acquire pairwise data required by the above methods. This issue becomes particularly severe under scenarios like math problem solving or code generation when generating high-quality data requires domain-specific expertise. This drawback of DPO has recently been circumvented by Direct Reward Optimization (DRO) . DRO formulates the LLM generation task as a single-step Markov Decision Process (MDP) (i.e., bandit) and adopts a soft actor-critic (SAC) framework, where the advantage is directly parameterized by the language model. Consequently, DRO inherits the advantage of offline policy gradient and gets rid of the dependency on pairwise data.

[0034] Nevertheless, DRO treats the process as a bandit problem, which neglects the intrinsic long horizon nature of a wide spectrum of tasks that require complex multi-step reasoning like math problem solving and code generation, where erroneous reasoning is almost fatal. Previous RL research found that if rewards are only provided at the end of the episode, discovering this sparse reward signal is a hard exploration problem and sparse reward functions may not be able to meaningfully distinguish between a wide range of different policies, which makes the training inefficient. In the meanwhile, recent studies show that signals from process reward models  (PRMs) can further boost the performance of language model. The positional information of PRM scores usually implies critical mistakes in the reasoning and therefore provides stronger supervision signals. However, if the whole generation process is simplified as a single action, the process reward will be aggregated and the positional information will be lost, implying that DRO cannot efficiently utilize process supervision.

[0035] In a nutshell, RL plays a crucial role in aligning LLMs with human preferences and improving their ability to perform complex tasks. However, current approaches either require significant computational resources due to the use of multiple models and extensive online sampling for training (e.g., PPO) or are framed as bandit problems (e.g., DPO, DRO) , which often struggle with multi-step reasoning tasks, such as math problem-solving and complex reasoning that involve long chains of thought.

[0036] In order to overcome at least the aforementioned issues, according to some embodiments, there is provided a solution for model training. In this solution, a data sample is obtained for a target machine learning model to be trained. The target machine learning model is constructed based on a language model, and the data sample comprises a sample prompt input and a sample model response for the target machine learning model. Then, the target machine learning model is trained by performing an iterative process. The iterative process comprises: generating, using the target machine learning mode, a first likelihood of a predicted response token based on a current token sequence; generating an advantage score for a predicted model response with respect to the current token sequence based on the sample model response, the predicted model response being updated iteratively to comprise the predicted response token; determining a first loss value of a first loss function for the target machine learning model based on the generated likelihood and the advantage score; and updating the target machine learning model based on the first loss value. The current token sequence is initialized to comprise the sample prompt input and updated iteratively to comprise a predicted response token generated in a previous iteration. The iterative process is iterated until a training objective is satisfied.

[0037] In some embodiments, Direct Q-function Optimization (DQO) , an offline RL algorithm for LLMs, is proposed. In DQO, the responding procedure is formulated as a MDP to learn an optimal policy under KL-regularization. The proposed algorithm adopts the framework of soft Q-learning, where the Q-function is directly parameterized by the language model. Then, both the Q-function network and the value network are updated according to Soft Bellman Equation on offline data. The MDP formulation makes DQO a multi-step learning algorithm and can therefore exploit process reward signals.

[0038] In some embodiments, model language generation may be implemented as a token-level MDP. RL is concerned with learning a policy that maximizes the cumulative reward for an agent interacting with an environment. In an example, language generation tasks may be formalized as an MDP. A prompt may be denoted as x and a response to the prompt may be denoted as y, which can each individually be broken down into a sequence of tokens, for example, x= (x0, ..., xm) , from a fixed discrete vocabulary The token-level MDP may be defined as a tuple In the defined MDP,  is a space of the state consisting of all tokens generated so far, i.e., st= (x0, ..., xm, y0, ..., yt) . The action space is a fixed discrete vocabulary. The dynamics  are a deterministic transition model between tokens, i.e.,  for st= (x0, ..., xm, y0, ...,yt) , a=yt+1 and st+1= (x0, ..., xm, y0, ..., yt, yt+1) . The  generation process will terminate once the terminal action ω (e.g., an end-of-sentence token) is taken. The reward function r (s, a) provides scalar feedback for the agent’s performance after taking action a in state s. In reinforcement learning with human feedback (RLHF) , the reward function may be learned from human feedback over preferences or given by a series of rules depending on the specific tasks. The initial state distribution d0 is a distribution over prompts x, where an initial state s0 comprises the tokens from x.

[0039] In some embodiments, KL-Regularized Reinforcement Learning Objective may be utilized. For example, the optimization objective may be formulated as a KL-regularized RL problem. The goal is to approximate the optimal KL-regularized policy as below.

[0040] where H is the total number of decision steps, s0 is a prompt sampled from the dataset, r (sh, ah) is a token-level reward from the reward function, β is a coefficient controlling a magnitude of KL-regularization and πref is an initialization policy. In classic RLHF and most LLM-related tasks, the reward is sparse and is only applied at a terminal action ω, i.e. an end-of-sentence token <eos>. However, the proposed structure is flexible enough to incorporate both dense and sparse rewards from ruled-based reward models, turn-level reward models, process-supervised reward models (PRM) , or just outcome-supervised reward models.

[0041] In an example, the objective function (1) may be rewritten under the framework of max-entropy reinforcement learning. Specifically, the KL-regularization term KL (π (·|sh) ||πref (·|sh) ) may be decomposed into cross-entropy and entropy, leading to the following objective:

[0042] where denotes the entropy of the policy at state sh and the KL-regularized reward is defined as Equation (2) leads to a maximum entropy reinforcement learning problem, which enjoys the well-known closed-form solution as follows:

[0043] where the Soft Q-function is defined as

[0044] and the Soft V-function is given by:

[0045] Equation (3) reveals that the optimal policy π*, soft Q-function Q*, and soft V-function V* are interdependent, which means that knowing any two of them allows computation of the third one.

[0046] According to some embodiments, for model training, a data sample is obtained for a target machine learning model to be trained. The target machine learning model is constructed based on a language model (e.g. an LLM) . In an example, the language model to be trained may be considered as a policy network in RL. The data sample comprises a sample prompt input and a sample model response for the target machine learning model. In an example, the sample prompt input may include a prompt as x, and the sample model response may include a response to the prompt denoted as y.

[0047] The target machine learning model is trained by performing an iterative process. In the iterative process, a first likelihood of a predicted response token is generated based on a current token sequence using the target machine learning mode. The current token sequence is initialized to comprise the sample prompt input and is updated iteratively to comprise a predicted response token generated in a previous iteration. An advantage score is generated for a predicted model response with respect to the current token sequence based on the sample model response. The predicted model response is updated iteratively to comprise the predicted response token. A first loss value of a first loss function is determined for the target machine learning model based on the generated likelihood and the advantage score. The target machine learning model is updated based on the first loss value. The iterative process is iterated until a training objective is satisfied.

[0048] By way of example, the SAC learning framework may be adopted to learn the state value function V and state-action value function Q. In SAC, the Q-function and V-function, which are parameterized by θ and φ respectively, are updated by minimizing the following squared residuals:

[0049] where   is the distribution of previously sampled states and actions, or a replay buffer. As shown in Equation (3) , the optimal policy π*, optimal Q-function Q*, and optimal value function V* are tightly interconnected. Specifically, they satisfy the following relationship: Q* (sh,ah) =βlogπ* (ahsh)+V*(sh) .            (8)

[0050] Inspired by this, the Q-value-network may be parameterized with the policy as follows: Qθ (sh, ah)=βlogπθ(ah|sh)+Vφ(sh) ,              (9)

[0051] where πθ (·|·) represents a policy network. In an example, the target machine learning model to be trained (e.g., the language model) may be considered as a policy network which the parameters denoted by πθ (·|·) . In Equation  (9) , instead of using an additional model to parameterize Q-value and learning the optimal policy from the optimal Q-function Q*, the policy may be directly inferred from the Q-function by parameterizing it with π.Herein, the proposed algorithm will be called as DQO.

[0052] By plugging in Equation (9) to Equation (7), we can rewrite the loss function for the policy as:

[0053] may be substituted by its definition βlogπref (ah|sh) +r (sh, ah) , and the objective function of the policy network may be obtained as follows:

[0054] where πθ (ah|sh) may indicate a first likelihood of a predicted response token generated based on a current token sequence. The current token sequence may be denoted by st= (x0, ..., xm, y0,..., yt) .The initial state s0 comprises the tokes from the sample prompt input, e.g., a prompt denoted as x. As the decision step is iterated, st may include more and more sample model responses, e.g., responses to the prompt, denoted as yt. r (sh,ah) +Vφ (sh+1) -Vφ (sh) may indicate an advantage score for a predicted model response with respect to the current token sequence, which is determined based on the sample model response. Lπ( θ) may indicate a first loss function for the target machine learning model. Accordingly, the value of Lπ (θ) may indicate a first loss value of the first loss function, which is determined based on the generated likelihood and the advantage score. Then, the target machine learning model is updated based on the first loss value.

[0055] In some embodiments, to determine the first loss value, a second likelihood of the predicted response token may be determined based on the current token sequence, using a reference machine learning model for the target machine learning model. In an example, as shown in Equation (11), πref may represent the reference machine learning model, and πref (ah|sh) may indicate the second likelihood of the predicted response token. Then, the first loss function, e.g., Lπ (θ) , may be determined based on a ratio between the first likelihood (e.g., πθ (ah|sh) ) and the second likelihood (e.g., πref (ah|sh) ) , and the advantage score (e.g., r (sh,ah) +Vφ (sh+1) -Vφ (sh) ) .

[0056] In some embodiments, to generate the advantage score for the predicted response, a reward score may be generated to comprise the predicted response token into the predicted model response. A first value score may be also generated for the predicted model response using a value model. Furthermore, a second value score may be generated based on at least one following predicted model response. The following predicted model response may comprise the predicted model response and at least one following predicted response token that is generated by the target machine learning model based at least on the current token sequence. Then, the advantage score may be determined based on the reward score, the first value score, and the second value score.

[0057] By taking Equation (11) as an example, in the case that the advantage score is indicated by r (sh, ah) +Vφ (sh+1) -Vφ (sh) , r (sh, ah) , as a token-level reward from a reward function, may indicate the  reward score to comprise the predicted response token into the predicted model response. Vφ (sh) may indicate the first value score for the predicted model response (e.g., sh) , and the V-function may be used as the value model. Vφ (sh+1) may indicate the second value score which is generated based on at least one following predicted model response (e.g., sh+1) .

[0058] In some embodiments, to eliminate the Q-function in the V-function objective (6) , the soft Bellman equation may be considered:

[0059] When  is generated online by the current policy πθ, the expectation in state transitions may be estimated by sampling and therefore may be substituted with Vφ (sh+1) . Consequently, the loss for the value function V may be obtained in the following form:

[0060] When comprises pre-generated offline data, importance sampling may be employed to reweight the offline data, ensuring that the offline dataset can be used effectively. Some embodiments in this regard will be described in the following paragraphs.

[0061] In some embodiments, in the formulation of DQO, each single token may be considered as an action. If the whole utterance is generated as a single action and the horizon length is set as H = 1, then Equation (11) and Equation (13) may degenerate to the loss used by DQO. This means that DRO can be viewed as a special case of the learning framework of DQO.

[0062] One-step temporal difference (TD) errors may have high bias and perform poorly when the value function is not well-initialized, resulting in inefficient learning. In some embodiments, the updates for Q-function and V-function may be further improved to address this issue. In an example, to generate the second value score, e.g., Vφ (sh+1) , for a following predicted model response, a plurality of value scores may be determined for a plurality of following predicted model responses using the value model. Then, the second value score may be determined by aggregating the plurality of value scores.

[0063] In an example, λ-return may be incorporated to address the bias. For example, by definition, V (sh) is the sum of reward gained by next n action and V (sh+n) , or formally,

[0064] Given a trajectory {s0, a0, r0,…, sH, aH, rH} where rh=r (ah, sh) , the empirical sample may be used to estimate the n-step return and define the empirical n-step return as:

[0065] where indicates a plurality of value scores that is determined for a plurality of following predicted model responses using the value model (e.g., the V-function) .

[0066] λ-return may be defined as the weighted average of all n-step returns:

[0067] may be used as the second value score for the following predicted model response. For example, the target for value updates may be replaced from one-step return Vφ (sh+1) (e.g., in Equation (11) ) to the λ-return where is the copy of φ but is not counted into the back-propagation gradients.

[0068] In some embodiments, to determine the second value score by aggregating the plurality of value scores, a plurality of weights may be determined for the plurality of value scores based on an iterative step difference between the predicted model response and respective ones of the plurality of following predicted model responses. The plurality of value scores may be weighted with the plurality of determined weights, respectively. Then, the second value score may be determined by aggregating the plurality of weighted value scores.

[0069] By taking Equation (16) as an example, λn-1 may denote the weights for the plurality of value scores, e.g.,  λn-1 is determined based on an iterative step difference, e.g., n-1, between the predicted model response and respective ones of the plurality of following predicted model responses. After  is weighed with λn-1,  may be determined by aggregating the plurality of weighted value scores

[0070] In some embodiments, the iterative process may further comprise determining a second loss value of a second loss function for the value model based on a difference between the second value score and the first value score. The value model may be updated based on the second loss value.

[0071] For example, after the target for value updates is replaced from one-step return Vφ (sh+1) to the λ-return the loss function for the value network is as follows:

[0072] The value model may be updated further using Equation (18) . In this way, the training efficiency may be further improved.

[0073] Similarly, the loss for Q-function (π) using λ-return is:

[0074] Offline RL, also known as batch RL, focuses on learning a policy from a pre-collected, fixed dataset without further interaction with the environment. A challenge in offline RL is the distributional shift between the behavior policy μ, which generated the data, and the target policy π. In order to mitigate this mismatch, offline RL algorithms may incorporate regularization techniques, such as importance sampling or constraints on the learned policy, to remain close to the behavior policy and avoid overestimating the Q-values for out-of-distribution actions.

[0075] In some embodiments, in the case that the target machine learning model is trained with a set of training data samples comprising the training data sample, to update the target machine learning model based on the first loss value (e.g., Equation (11) ) , an importance level of the training data sample with respect to the target machine learning model may be determined based on importance sampling on the set of training data samples and on the target machine learning model. A sample weight may be determined for the training data sample based on the importance level of the training data sample. The first loss value may be weighted with the sample weight, to obtain a first weighted loss value. Then, the target machine learning model may be updated based on the first weighted loss value.

[0076] By way of example, offline data may be re-weighted with importance sampling. For example, a KL-constrained RL objective may be used and then importance sampling may be employed to reweight the offline data to match the distribution of trajectories generated by the current optimized policy.

[0077] Here, importance sampling may be introduced to help correct this mismatch, ensuring that the offline dataset can be used effectively for policy updates. μ may represent the behavior policy under which the offline data was generated and π is the current online policy. The probability of a trajectory τ under μ and π are computed as follows:

[0078] Therefore, when the offline dataset is sampled from τ,

[0079] where f (τ ) is any function of trajectory τ . This indicates that the importance ratio π (τ|sh)  / μ (τ|sh) , which may indicate an importance level of the training data sample, may be used to adjust the loss. The importance sampling rate may be truncated to avoid gradient explosion caused by extreme values. The final ratio that is applied is shown as follows:

[0080] where ω (τ) represents an importance sampling weight that indicates a sample weight for the training data  sample.

[0081] Now, the importance ratio in Equation (22) may be plugged in to the loss functions (17) and (18) and then the final loss functions may be obtained for offline learning as follows.

[0082] Then, the target machine learning model may be updated based on the first weighted loss value, derived from Equation (23) or (24) .

[0083] It is to be noted that the importance sampling weight ω (τ) may not be involved in the gradient backward computation. The introduction of importance ration enables leverage of offline datasets in an online RL framework, ensuring that the updated policy remains consistent with the distribution of trajectories it would encounter during online interaction.

[0084] In some embodiments, to determine the importance level of the training data sample (e.g., π (τ|sh)  / μ (τ|sh) ), two probabilities may be determined, including, for example, a first probability of sampling the training data sample, e.g., π (ah|sh) , and a second probability of generating the training data sample, e.g., μ (ah|sh) .The first probability of sampling the training data sample may be determined from the set of training data samples. The second probability of generating the training data sample may be determined with the target machine learning model. Then, the importance level of the training data sample may be determined based on the first probability and the second probability.

[0085] According to some embodiments, DQO is introduced which formulates the response generation process as an MDP and utilizes the SAC framework to optimize a Q-function directly parameterized by the language model. The MDP formulation of DQO may offer structural advantages over bandit-based methods, enabling more effective process supervision.

[0086] Some embodiments propose Direct Q-function optimization, or DQO, an offline RL algorithm for LLMs. Compared to previous methods, DQO can learn from offline and negative or unbalanced samples. Moreover, DQO is featured by step-wise learning, which is favorable for long-horizon tasks and able to exploit process rewards. In some embodiments, a practical instantiation of DQO may be introduced, which equips DQO with λ-return and importance sampling. These techniques stabilize the training process and ensure a good performance.

[0087] Experiments are conducted by comparing DQO with a wide range of widely used alignment algorithms on math problem-solving tasks. Experimental results on two math problem-solving datasets, GSM8K and MATH, demonstrate that DQO outperforms previous methods, establishing it as a promising offline reinforcement learning approach for aligning language models. Moreover, as shown by the experiment results, when process rewards are available, the performance of DQO can be further boosted, indicating that DQO can  benefit from process rewards, as detailed in the following paragraphs.

[0088] Experimental results on two math problem-solving datasets, GSM8K and MATH, demonstrate that DQO outperforms previous methods, establishing it as a promising offline reinforcement learning approach for aligning language models.

[0089] In the experiments, two pretrained models, Gemma-1.1-it-7B2 (Gemma) and Qwen2-7B-Instruct3 (Qwen) are selected as base models. Table 1 shows experiment results for Qwen2-7B-Instruct model where bold is used for the best and underline is used for the second best.

[0090] Table 1: Experiment results for Qwen2-7B-Instruct model

[0091] As shown in Table 1, the experiment results show that DQO significantly improves the base model’s performance. This improvement surpasses all the baselines when doing sampling. As for greedy generation, DQO is comparable to DPO when doing greedy generation and surpass all other baselines.

[0092] Table 2 shows experiment results for Gemma-1.1-7B-it model where bold is used for the best and underline is used for the second best.

[0093] Table 2: Experiment results for Gemma-1.1-7B-it model

[0094] As shown in Table 2, DQO significantly improves the base model’s performance. On GSM8K, DQO surpasses all other baselines by a significant margin. On MATH dataset, DQO achieves a comparable performance with DRO when doing greedy sampling and outperforms all the baseline when doing sampling at inference. When it turns to the results on Gemma, DQO enjoys larger advantages. As demonstrated in Table 2, all considered methods result in significant improvement.

[0095] In summary, DQO results in promising improvement over the base models under all the scenarios and outperforms all our baseline methods.

[0096] To demonstrate the impact of the importance sampling ratio in DQO, DQO is trained on Gemma without the importance sampling ratio for Q-function loss, V -function loss, and both. Table 3 presents the results where the experiments are conducted on Gemma.

[0097] Table 3: The impact of importance sampling rate on both Q-function loss and V -function loss

[0098] As shown, when training without an importance sampling ratio on Q-function loss, the performances degenerate significantly on both GSM8K and MATH. When keeping the importance ratio only on Q-function loss, there is also a moderate performance loss on MATH. These results show that the importance sampling ratio, on both Q-function and V -function loss, plays important roles in DQO training.

[0099] In order to demonstrate the impact of λ-return, the value of λ is varied and the training results is evaluated on Gemma. Empirically, the best performance may be obtained at λ = 1 and quickly degenerates when decreasing λ. Therefore, λ = 0.95 is picked to make the comparison. The results are shown in Table 4.

[0100] Table 4: The impact of λ-return on Gemma

[0101] When decreasing λ from 1.0 to 0.95, it can be observed that a significant performance drops more than 3.71%on GSM8K and 2.30%on MATH. The results indicate that λ-return is a beneficial component in the target of policy training.

[0102] Moreover, the experiment results when process scores at intermediate steps are available, the performance of DQO can be further improved. Here, synthetic process scores may be used. In order to obtain a synthetic process score, an empirical passing rate may be used to estimate the quality of a given response prefix. Specifically, given a prompt string x, for each failed response y, the response may be first into several segments y [0 : n] , where n is the number of segments and y [0 : i] may be used to denote the concatenation of first i segments. Beginning from i = n -1, 20 trajectories may be randomly sampled given prefix contact (x, y [0 : i] ) . If there is at least one correct completion, it is assumed that the reasoning process in y [0 : i] is correct and all the process rewards for the previous step will be set to 1 / n. This process reward scores may be combined with the original rewards. The process is shown in FIG. 2A.

[0103] FIG. 2A shows a visual demonstration of process reward construction according to some embodiments. All the responses may be split into segments. For correct responses, all process reward may be assigned to one. Negative responses start from each prefix and 20 samples are generated. The longest prefix is  found where the best of 20 samples is correct and all the process rewards are assigned before to 1.

[0104] The experiments are conducted on Gemma, and the results are summarized in Table 5.

[0105] Table 5: Experiment results for DQO augemented by process scores

[0106] As shown in Table 5, equipped with our estimated process scores, a further improvement is observed. The results imply that DQO can be further enhanced by utilizing process scores. Additionally, it can be discovered that even without process scores, DQO is capable of identifying correct reasoning steps. The trained values demonstrate a growing correlation with the synthetic process scores, as shown in FIG. 2B, suggesting that DQO effectively learns to recognize correct reasoning steps, enhancing the reasoning process over time.

[0107] FIG. 2B shows correlation between the trained values (trained without process scores) and the constructed process scores according to some embodiments. As the training proceeds, a growth in the correlation between these two values can be observed, indicating that the value model in DQO learns the correctness of the reasoning process.

[0108] A holistic comparison of the proposed method and other alignment methods is shown in Table 6.

[0109] Table 6: Comparison between different algorithms

[0110] Unlike DPO or DRO, where all tokens (actions) within a response (trajectory) are evenly incentivized or punished, DQO can discover the correct reasoning steps in an incorrect response. Through a comparison between DQO, offline learning algorithms, including supervised fine-tuning (SFT) , reject sampling (RS) , DPO, KTO, DRO and online algorithm PPO, it can be observed that DQO enjoys all the benefits listed in the left-most column.

[0111] FIG. 3 illustrates a flowchart of a process 300 for model training in accordance with some embodiments of the present disclosure.

[0112] At block 310, a data sample is obtained for a target machine learning model to be trained. The target machine learning model is constructed based on a language model, and the data sample comprises a sample prompt input and a sample model response for the target machine learning model.

[0113] At block 320, the target machine learning model is trained by performing an iterative process. The iterative process comprises: generating, using the target machine learning mode, a first likelihood of a predicted  response token based on a current token sequence, the current token sequence being initialized to comprise the sample prompt input and being updated iteratively to comprise a predicted response token generated in a previous iteration; generating an advantage score for a predicted model response with respect to the current token sequence based on the sample model response, the predicted model response being updated iteratively to comprise the predicted response token; determining a first loss value of a first loss function for the target machine learning model based on the generated likelihood and the advantage score; and updating the target machine learning model based on the first loss value. The iterative process is iterated until a training objective is satisfied.

[0114] In some embodiments, determining the first loss value may comprise: determining, using a reference machine learning model for the target machine learning model, a second likelihood of the predicted response token based on the current token sequence; and determining the first loss function based on a ratio between the first likelihood and the second likelihood, and the advantage score.

[0115] In some embodiments, generating the advantage score for the predicted response with respect to the current token sequence based on the sample response may comprise: generating a reward score for comprising the predicted response token into the predicted model response; generating, using a value model, a first value score for the predicted model response; generating a second value score based on at least one following predicted model response, a following predicted model response of the at least one following predicted model response comprising the predicted model response and at least one following predicted response token that is generated by the target machine learning model based at least on the current token sequence; and determining the advantage score based on the reward score, the first value score, and the second value score.

[0116] In some embodiments, generating the second value score for the following predicted model response may comprise: determining, using the value model, a plurality of value scores for a plurality of following predicted model responses; and determining the second value score by aggregating the plurality of value scores.

[0117] In some embodiments, determining the second value score by aggregating the plurality of value scores may comprise: determining a plurality of weights for the plurality of value scores based on an iterative step difference between the predicted model response and respective ones of the plurality of following predicted model responses; and weighting the plurality of value scores with the plurality of determined weights, respectively; and determining the second value score by aggregating the plurality of weighted value scores.

[0118] In some embodiments, the iterative process further may comprise: determining a second loss value of a second loss function for the value model based on a difference between the second value score and the first value score, and updating the value model based on the second loss value.

[0119] In some embodiments, the target machine learning model may be trained with a set of training data samples comprising the training data sample. Updating the target machine learning model based on the first loss value may comprise: determining an importance level of the training data sample with respect to the target machine learning model based on importance sampling on the set of training data samples and on the target machine learning model; determining a sample weight for the training data sample based on the importance level of the training data sample; weighting the first loss value with the sample weight, to obtain a first weighted loss value; and updating the target machine learning model based on the first weighted loss value.

[0120] In some embodiments, determining the importance level of the training data sample may comprise: determining a first probability of sampling the training data sample from the set of training data samples; determining a second probability of generating the training data sample with the target machine learning model; and determining the importance level of the training data sample based on the first probability and the second probability.

[0121] FIG. 4 shows a block diagram of an apparatus 400 for model training in accordance with some embodiments of the present disclosure. Various modules / components in the apparatus 400 may be implemented by hardware, software, firmware, or any combination thereof.

[0122] As shown in FIG. 4, the apparatus 400 includes an obtaining module 410 configured to obtain a data sample for a target machine learning model to be trained. The target machine learning model is constructed based on a language model, and the data sample comprises a sample prompt input and a sample model response for the target machine learning model.

[0123] The apparatus 400 further includes a training module 420 configured to train the target machine learning model by performing an iterative process. The training module 420 is configured to generate, using the target machine learning mode, a first likelihood of a predicted response token based on a current token sequence, the current token sequence being initialized to comprise the sample prompt input and being updated iteratively to comprise a predicted response token generated in a previous iteration. The training module 420 is further configured to generate an advantage score for a predicted model response with respect to the current token sequence based on the sample model response, the predicted model response being updated iteratively to comprise the predicted response token. The training module 420 is further configured to determine a first loss value of a first loss function for the target machine learning model based on the generated likelihood and the advantage score. The training module 420 is further configured to update the target machine learning model based on the first loss value. The iterative process is iterated until a training objective is satisfied.

[0124] In some embodiments, the training module 420 may be configured to determine, using a reference machine learning model for the target machine learning model, a second likelihood of the predicted response token based on the current token sequence; and determine the first loss function based on a ratio between the first likelihood and the second likelihood, and the advantage score.

[0125] In some embodiments, the training module 420 may be configured to generate a reward score for comprising the predicted response token into the predicted model response; generate, using a value model, a first value score for the predicted model response; generate a second value score based on at least one following predicted model response, a following predicted model response of the at least one following predicted model response comprising the predicted model response and at least one following predicted response token that is generated by the target machine learning model based at least on the current token sequence; and determine the advantage score based on the reward score, the first value score, and the second value score.

[0126] In some embodiments, the training module 420 may be configured to determine, using the value model, a plurality of value scores for a plurality of following predicted model responses; and determine the second value score by aggregating the plurality of value scores.

[0127] In some embodiments, the training module 420 may be configured to determine a plurality of weights for the plurality of value scores based on an iterative step difference between the predicted model response and respective ones of the plurality of following predicted model responses; and weight the plurality of value scores with the plurality of determined weights, respectively; and determine the second value score by aggregating the plurality of weighted value scores.

[0128] In some embodiments, the training module 420 may be configured to determine a second loss value of a second loss function for the value model based on a difference between the second value score and the first value score, and update the value model based on the second loss value.

[0129] In some embodiments, the target machine learning model may be trained with a set of training data samples comprising the training data sample. The training module 420 may be configured to determine an importance level of the training data sample with respect to the target machine learning model based on importance sampling on the set of training data samples and on the target machine learning model; determine a sample weight for the training data sample based on the importance level of the training data sample; weight the first loss value with the sample weight, to obtain a first weighted loss value; and updating the target machine learning model based on the first weighted loss value.

[0130] In some embodiments, the training module 420 may be configured to determine a first probability of sampling the training data sample from the set of training data samples; determine a second probability of generating the training data sample with the target machine learning model; and determine the importance level of the training data sample based on the first probability and the second probability.

[0131] FIG. 5 illustrates a block diagram of an electronic device 500 in which one or more embodiments of the present disclosure can be implemented. It would be appreciated that the electronic device 500 shown in FIG. 5 is only an example and should not constitute any restriction on the function and scope of the embodiments described herein. The electronic device 500 may be used, for example, to implement the process 300 in FIG. 3. The electronic device 500 may also be used to implement the apparatus 400 of FIG. 4.

[0132] As shown in FIG. 5, the electronic device 500 is in the form of a general computing device. The components of the electronic device 500 may include, but are not limited to, one or more processors or processing units 510, a memory 520, a storage device 530, one or more communication units 540, one or more input devices 550, and one or more output devices 560. The processing unit 510 may be an actual or virtual processor and can execute various processes according to the programs stored in the memory 520. In a multiprocessor system, multiple processing units execute computer executable instructions in parallel to improve the parallel processing capability of the electronic device 500.

[0133] The electronic device 500 typically includes a variety of computer storage medium. Such medium may be any available medium that is accessible to the electronic device 500, including but not limited to volatile and non-volatile medium, removable and non-removable medium. The memory 520 may be volatile memory (for example, a register, cache, a random access memory (RAM) ) , a non-volatile memory (for example, a read-only memory (ROM) , an electrically erasable programmable read-only memory (EEPROM) , a flash memory) or any combination thereof. The storage device 530 may be any removable or non-removable medium, and may include a machine-readable medium, such as a flash drive, a disk, or any other medium, which can be used to  store information and / or data (such as training data for training) and can be accessed within the electronic device 500.

[0134] The electronic device 500 may further include additional removable / non-removable, volatile / non-volatile storage medium. Although not shown in FIG. 5, a disk driver for reading from or writing to a removable, non-volatile disk (such as a "floppy disk" ) , and an optical disk driver for reading from or writing to a removable, non-volatile optical disk can be provided. In these cases, each driver may be connected to the bus (not shown) by one or more data medium interfaces. The memory 520 may include a computer program product 525, which has one or more program modules configured to perform various methods or acts of various embodiments of the present disclosure.

[0135] The communication unit 540 communicates with a further computing device through the communication medium. In addition, functions of components in the electronic device 500 may be implemented by a single computing cluster or multiple computing machines, which can communicate through a communication connection. Therefore, the electronic device 500 may be operated in a networking environment using a logical connection with one or more other servers, a network personal computer (PC) , or another network node.

[0136] The input device 550 may be one or more input devices, such as a mouse, a keyboard, a trackball, etc. The output device 560 may be one or more output devices, such as a display, a speaker, a printer, etc. The electronic device 500 may also communicate with one or more external devices (not shown) through the communication unit 540 as required. The external device, such as a storage device, a display device, etc., communicate with one or more devices that enable users to interact with the electronic device 500, or communicate with any device (for example, a network card, a modem, etc. ) that makes the electronic device 500 communicate with one or more other computing devices. Such communication may be executed via an input / output (I / O) interface (not shown) .

[0137] According to example implementation of the present disclosure, a computer-readable storage medium is provided, on which a computer-executable instruction or computer program is stored, where the computer-executable instructions or the computer program is executed by the processor to implement the method described above. According to example implementation of the present disclosure, a computer program product is also provided. The computer program product is physically stored on a non-transient computer-readable medium and includes computer-executable instructions, which are executed by the processor to implement the method described above.

[0138] Various aspects of the present disclosure are described herein with reference to the flow chart and / or the block diagram of the method, the device, the equipment and the computer program product implemented in accordance with the present disclosure. It would be appreciated that each block of the flowchart and / or the block diagram and the combination of each block in the flowchart and / or the block diagram may be implemented by computer-readable program instructions.

[0139] These computer-readable program instructions may be provided to the processing units of general-purpose computers, special computers or other programmable data processing devices to produce a machine that generates a device to implement the functions / acts specified in one or more blocks in the flow chart and / or the  block diagram when these instructions are executed through the processing units of the computer or other programmable data processing devices. These computer-readable program instructions may also be stored in a computer-readable storage medium. These instructions enable a computer, a programmable data processing device and / or other devices to work in a specific way. Therefore, the computer-readable medium containing the instructions includes a product, which includes instructions to implement various aspects of the functions / acts specified in one or more blocks in the flowchart and / or the block diagram.

[0140] The computer-readable program instructions may be loaded onto a computer, other programmable data processing apparatus, or other devices, so that a series of operational steps can be performed on a computer, other programmable data processing apparatus, or other devices, to generate a computer-implemented process, such that the instructions which execute on a computer, other programmable data processing apparatus, or other devices implement the functions / acts specified in one or more blocks in the flowchart and / or the block diagram.

[0141] The flowchart and the block diagram in the drawings show the possible architecture, functions and operations of the system, the method and the computer program product implemented in accordance with the present disclosure. In this regard, each block in the flowchart or the block diagram may represent a part of a module, a program segment or instructions, which contains one or more executable instructions for implementing the specified logic function. In some alternative implementations, the functions marked in the block may also occur in a different order from those marked in the drawings. For example, two consecutive blocks may actually be executed in parallel, and sometimes can also be executed in a reverse order, depending on the function involved. It should also be noted that each block in the block diagram and / or the flowchart, and combinations of blocks in the block diagram and / or the flowchart, may be implemented by a dedicated hardware-based system that performs the specified functions or acts, or by the combination of dedicated hardware and computer instructions.

[0142] Each implementation of the present disclosure has been described above. The above description is example, not exhaustive, and is not limited to the disclosed implementations. Without departing from the scope and spirit of the described implementations, many modifications and changes are obvious to ordinary skill in the art. The selection of terms used in this article aims to best explain the principles, practical application or improvement of technology in the market of each implementation, or to enable other ordinary skill in the art to understand the various embodiments disclosed herein.

Claims

1.A method for model training, comprising:obtaining a data sample for a target machine learning model to be trained, the target machine learning model being constructed based on a language model, and the data sample comprising a sample prompt input and a sample model response for the target machine learning model;training the target machine learning model by performing an iterative process comprising:generating, using the target machine learning model, a first likelihood of a predicted response token based on a current token sequence, the current token sequence being initialized to comprise the sample prompt input and being updated iteratively to comprise a predicted response token generated in a previous iteration,generating an advantage score for a predicted model response with respect to the current token sequence based on the sample model response, the predicted model response being updated iteratively to comprise the predicted response token,determining a first loss value of a first loss function for the target machine learning model based on the generated likelihood and the advantage score, andupdating the target machine learning model based on the first loss value,wherein the iterative process is iterated until a training objective is satisfied.2.The method of claim 1, wherein determining the first loss value comprises:determining, using a reference machine learning model for the target machine learning model, a second likelihood of the predicted response token based on the current token sequence; anddetermining the first loss function based on a ratio between the first likelihood and the second likelihood, and the advantage score.3.The method of claim 1, wherein generating the advantage score for the predicted response with respect to the current token sequence based on the sample response comprises:generating a reward score for comprising the predicted response token into the predicted model response;generating, using a value model, a first value score for the predicted model response;generating a second value score based on at least one following predicted model response, a following predicted model response of the at least one following predicted model response comprising the predicted model response and at least one following predicted response token that is generated by the target machine learning model based at least on the current token sequence; anddetermining the advantage score based on the reward score, the first value score, and the second value score.4.The method of claim 3, wherein generating the second value score for the following predicted model response comprises:determining, using the value model, a plurality of value scores for a plurality of following predicted model responses; anddetermining the second value score by aggregating the plurality of value scores.5.The method of claim 4, wherein determining the second value score by aggregating the plurality of value scores comprises:determining a plurality of weights for the plurality of value scores based on an iterative step difference between the predicted model response and respective ones of the plurality of following predicted model responses;weighting the plurality of value scores with the plurality of determined weights, respectively; anddetermining the second value score by aggregating the plurality of weighted value scores.6.The method of claim 3, wherein the iterative process further comprises:determining a second loss value of a second loss function for the value model based on a difference between the second value score and the first value score, andupdating the value model based on the second loss value.7.The method of claim 1, wherein the target machine learning model is trained with a set of training data samples comprising the training data sample, and wherein updating the target machine learning model based on the first loss value comprises:determining an importance level of the training data sample with respect to the target machine learning model based on importance sampling on the set of training data samples and on the target machine learning model;determining a sample weight for the training data sample based on the importance level of the training data sample;weighting the first loss value with the sample weight, to obtain a first weighted loss value; andupdating the target machine learning model based on the first weighted loss value.8.The method of claim 7, wherein determining the importance level of the training data sample comprises:determining a first probability of sampling the training data sample from the set of training data samples;determining a second probability of generating the training data sample with the target machine learning model; anddetermining the importance level of the training data sample based on the first probability and the second probability.9.An apparatus for model training, comprising:an obtaining module configured to obtain a data sample for a target machine learning model to be trained. The target machine learning model is constructed based on a language model, and the data sample comprises a sample prompt input and a sample model response for the target machine learning model; anda training module configured to train the target machine learning model by performing an iterative process,wherein the training module is configured to:generate, using the target machine learning mode, a first likelihood of a predicted response token based on a current token sequence, the current token sequence being initialized to comprise the sample prompt input and being updated iteratively to comprise a predicted response token generated in a previous iteration;generate an advantage score for a predicted model response with respect to the current token sequence based on the sample model response, the predicted model response being updated iteratively to comprise the predicted response token;determine a first loss value of a first loss function for the target machine learning model based on the generated likelihood and the advantage score; andupdate the target machine learning model based on the first loss value, where the iterative process is iterated until a training objective is satisfied .10.The apparatus of claim 9, wherein the training module is configured to:determine, using a reference machine learning model for the target machine learning model, a second likelihood of the predicted response token based on the current token sequence; anddetermine the first loss function based on a ratio between the first likelihood and the second likelihood, and the advantage score.11.The apparatus of claim 9, wherein the training module is configured to:generate a reward score f or comprising the predicted response token into the predicted model response;generate, using a value model, a first value score for the predicted model response;generate a second value score based on at least one following predicted model response, a following predicted model response of the at least one following predicted model response comprising the predicted model response and at least one following predicted response token that is generated by the target machine learning model based at least on the current token sequence; anddetermine the advantage score based on the reward score, the first value score, and the second value score.12.The apparatus of claim 11, wherein the training module is configured to:determine, using the value model, a plurality of value scores for a plurality of following predicted model responses; anddetermine the second value score by aggregating the plurality of value scores.13.The apparatus of claim 12, wherein the training module is configured to:determine a plurality of weights for the plurality of value scores based on an iterative step difference between the predicted model response and respective ones of the plurality of following predicted model responses;weight the plurality of value scores with the plurality of determined weights, respectively; anddetermine the second value score by aggregating the plurality of weighted value scores.14.The apparatus of claim 11, wherein the training module is configured to:determine a second loss value of a second loss function for the value model based on a difference between the second value score and the first value score, andupdate the value model based on the second loss value.15.The apparatus of claim 9, wherein the target machine learning model is trained with a set of training data samples comprising the training data sample, and wherein the training module is configured to:determine an importance level of the training data sample with respect to the target machine learning model based on importance sampling on the set of training data samples and on the target machine learning model;determine a sample weight for the training data sample based on the importance level of the training data sample;weight the first loss value with the sample weight, to obtain a first weighted loss value; andupdate the target machine learning model based on the first weighted loss value.16.The apparatus of claim 15, wherein the training module is configured to:determine a first probability of sampling the training data sample from the set of training data samples;determine a second probability of generating the training data sample with the target machine learning model; anddetermine the importance level of the training data sample based on the first probability and the second probability.17.An electronic device, comprising:at least one processing unit; andat least one memory coupled to the at least one processing unit and storing instructions executable by the at least one processing unit, the instructions, upon execution by the at least one processing unit, causing the device to perform the method according to any of claims 1 to 9.18.A computer-readable storage medium, having a computer program stored thereon which, upon execution by an electronic device, causes the device to perform the method according to any of claims 1 to 9.19.A computer program product being embodied on a computer-readable medium and comprising computer-executable instructions which are executed by a processor to perform the method according to any of claims 1 to 9.

Citation Information

Patent Citations

  • Text analysis model training method and device

    CN118674006A

  • Reward-model based reinforcement learning for performing reasoning tasks

    US20240104391A1

  • Methods and systems for fast inference from machine learning models

    WO2024118603A1