Preconditioned variance reduction
The method of preconditioned variance reduction optimizes training of deep neural networks and language models by using variance reduction gradients and curvature information to enhance convergence and efficiency.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- BEIJING YOUZHUJU NETWORK TECH CO LTD
- Filing Date
- 2024-11-15
- Publication Date
- 2026-05-21
Smart Images

Figure CN2024132420_21052026_PF_FP_ABST
Abstract
Description
PRECONDITIONED VARIANCE REDUCTIONField
[0001] The disclosed example embodiments relate generally to machine learning and, more particularly, to a method, apparatus, device and computer readable storage medium for preconditioned variance reduction.Background
[0002] Training deep neural networks or language models demands efficient and scalable optimizers. Adaptive gradient algorithms have been central to this task. Despite the development of numerous variance reduction algorithms aimed at accelerating stochastic optimization in both convex and nonconvex settings, variance reduction has not been found widespread success in training deep neural networks or language models. Consequently, it has remained a less favored approach in modern artificial intelligence (AI) .Summary
[0003] In a first aspect of the present disclosure, there is provided a method for preconditioned variance reduction. The method comprises: obtaining a first processing result on a first sample by a first version of a machine learning (ML) model and a second processing result on a second sample by a second version of the ML model, wherein the second version is update of the first version; determining a variance reduction gradient corresponding to the second version based on the first processing result, the second processing result and a loss function; and updating the second version of the ML model to a third version of the ML model based on the variance reduction gradient and curvature information of the loss function corresponding to the second version.
[0004] In a second aspect of the present disclosure, there is provided an apparatus for preconditioned variance reduction. The apparatus comprises: a processing result obtaining module configured to obtain a first processing result on a first sample by a first version of a machine learning (ML) model and a second processing result on a second sample by a second version of the ML model, wherein the second version is update of the first version; a variance reduction gradient determining module configured to determine a variance reduction gradient corresponding to the second version based on the first processing result, the second processing result and a loss function; and a version updating module configured to update the second version of the ML model to a third version of the ML model based on the variance reduction gradient and curvature information of the loss function corresponding to the second version.
[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. 2 illustrates a flowchart of a process for preconditioned variance reduction in accordance with some embodiments of the present disclosure;
[0012] FIG. 3 illustrates a schematic diagram of different versions of the ML model in accordance with some embodiments of the present disclosure;
[0013] FIG. 4 illustrates a schematic diagram of an algorithm summarizing the proposed solution in accordance with some embodiments of the present disclosure;
[0014] FIG. 5 illustrates a schematic diagram of an algorithm summarizing a first instance of the proposed solution in accordance with some embodiments of the present disclosure;
[0015] FIG. 6 illustrates a schematic diagram of an algorithm summarizing a second instance of the proposed solution in accordance with some embodiments of the present disclosure;
[0016] FIG. 7 illustrates a schematic diagram of an algorithm summarizing a third instance of the proposed solution in accordance with some embodiments of the present disclosure;
[0017] FIG. 8 shows a block diagram of an apparatus for preconditioned variance reduction in accordance with some embodiments of the present disclosure; and
[0018] FIG. 9 illustrates a block diagram of an electronic device in which one or more embodiments of the present disclosure can be implemented.Detailed Description
[0019] 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.
[0020] 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.
[0021] 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.
[0022] 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.
[0023] 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.
[0024] 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.
[0025] 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.
[0026] 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.
[0027] “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.
[0028] Usually, machine learning may 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.
[0029] FIG. 1 illustrates a block diagram of an example environment 100 in which various embodiments of the present disclosure may be implemented. In the environment 100 of FIG. 1, two distinct phases of a model are showed, including a training phase 102 and an application phase 106. After the training phase 102 is completed, there may be a testing phase, which is not shown in FIG. 1.
[0030] In the training phase 102, a model training system 110 is configured to utilize a training dataset 112 to perform training of the machine learning model 105. At the beginning of training, the machine learning model 105 may have initial parameter values. The training process is to update the parameter values of the machine learning model 105 to the expected values based on the training data. In some embodiments, the machine learning model 105 is configured to modify the source speaker’s voice to resemble the target speaker.
[0031] In the application phase 106, the machine learning model 105 having trained parameter values may be provided to a model application system 130 for use. In the application phase 106, the machine learning model 105 may be used to process a target input 132 and provide a corresponding target output 134.
[0032] In FIG. 1, the model training system 110 and the model application system 130 may be implemented at any computing system with computing capability, such as various computing devices / systems, terminal devices, servers, etc. Terminal devices may include 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.
[0033] 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. In an example, although shown as separate, the model training system 110 and the model application system 130 may be integrated into a same system or device. The implementation method disclosed herein is not limited in this regard.
[0034] As mentioned above, adaptive gradient methods play a central role in optimization for machine learning. Some adaptive gradient methods propose that the learning rate may be adjusted based on the geometry of the training data observed during earlier iterations. Some adaptive gradient methods incorporate the idea of moving average to tackle the issue of diminishing gradient. With the surge of language models, the majority of the models are trained with adaptive gradient methods. Various efforts have been made to improve the convergence of training for language models.
[0035] There exists a number of related works on variance reduction for stochastic optimization, which aims to improve the gradient complexity of the optimizers. A related work proposes the idea of variance reduction to enhance the convergence rate by gradient recomputation with difference in parameters. A related work further refines these approaches by implementing biased estimation of gradient, which reduces storage requirements while improving the complexity bounds for convex optimization problems. A related work proposes an adaptive gradient algorithm combining variance reduction to achieve a better convergence rate. Nevertheless, these advances have primarily been validated in computer vision tasks with convolutional neural networks. While some other attempts have explored applications of the variance reduction method in reinforce learning tasks, there remains a gap in adapting variance reduction techniques specifically for the rapidly developing language models.
[0036] To address at least some of the above issues, embodiments of the present disclosure propose an improved solution for preconditioned variance reduction. In this solution, a first processing result on a first sample is obtained by a first version of a machine learning (ML) model and a second processing result on a second sample is obtained by a second version of the ML model, where the second version is update of the first version. A variance reduction gradient corresponding to the second version is determined based on the first processing result, the second processing result and a loss function. The second version of the ML model is updated to a third version of the ML model based on the variance reduction gradient and curvature information of the loss function corresponding to the second version.
[0037] With these embodiments of the present disclosure, a variance reduction gradient is provided to determine the optimal direction to train the ML model. In this way, deep neural networks, including but not limited to language models, may be efficiently trained.
[0038] In order to better understand embodiments of the present disclosure, some notations used in the present disclosure and preliminaries of stochastic optimization, including standard stochastic gradient methods and variance reduction may be introduced first. It is assumed that xt denotes the parameter of the language model at step t and ξ1, …, ξT∈Ξ are a sequence of independent random variables which denote the training data for each step. For some objective function that is differentiable, it is assumed that It is to be noted that the training data of the current step ξt and previous step ξt-1 are used for attaining different gradient for the same parameter xt, these variables may be explicitly indicated for function f.
[0039] An objective function may be minimized as follows: where f (x, ξ) represents a possibly nonconvex loss function, represents the optimization variable, ξ represents a random vector (e.g., a training data point) drawn from an unknown data distribution It is assumed that a first-order oracle may return an unbiased estimator of the gradient The standard stochastic gradient descent (SGD) algorithm yields:
[0040] Variance reduction techniques for accelerating stochastic optimization problems have garnered increasing interest from both machine learning and optimization communities, leading to the development of several algorithms. These algorithms may reduce the convergence rate of SGD from to demonstrating a provable advantage. The core of variance reduction techniques proposed by some related works may be summarized as follows: xt+1=xt-ηtmt where denotes the trained weights in the neural network, ξt represents random data, and mt represents the variance-reduced (VR) gradient. The gradient correction term cancels out common noise brought by ξt, while pushing the gradient forward from an estimator of to an estimator of For every q steps, mt has to be reset to a full gradient calculation which is called an anchoring step.
[0041] Subsequently, a related work proposes to use a weighted average of and mt in Eq. (3) to achieve the same convergence rate while eliminating the need for periodic anchoring, resulting in the following VR gradient:
[0042] Alternatively, Eq. (4) may be written as an exponential moving average (EMA) of the combined gradient and gradient correction term:
[0043] To understand the variance-reduced gradient mt in Eq. (4) and Eq. (5) , some related works show that the estimation error may be written recursively as:
[0044] When taking the expectation over the squared norm of ∈t, the squared norm of may be bounded by the smoothness of F and is of order which diminishes as the algorithm converges. On the other hand, the squared norm of may be bounded by (1-β1) 2σ2 , where σ represents the variance of the SGD gradient estimator. When 1-β1 is chosen to be sufficiently small, is also small, ensuring a tighter approximation to the true gradient. When assuming access to an unbiased stochastic first-order oracle to the loss function, a tight convergence rate of may be achieved for non-convex smooth optimization problems.
[0045] Example embodiments of the present disclosure will be described in the following. FIG. 2 illustrates a flowchart of a process 200 for preconditioned variance reduction in accordance with some embodiments of the present disclosure. The process 200 may be implemented at the model training system 110 of FIG. 1.
[0046] At block 210, the model training system 110 obtains a first processing result on a first sample by a first version of a ML model (as an example of the machine learning model 105) and a second processing result on a second sample by a second version of the ML model. The second version is an update of the first version. In an example, a sample may include training data at a step. Although singular form is used, it is to be understood that a batch of samples may be used at a training step. The ML model may be trained by the first and second samples and thus the ML model may have capability to generate the first processing result and the second processing result under the first version and the second version, respectively. In some embodiments, the first sample and the second sample may be the same. Alternatively, in some embodiments, the first sample and the second sample may be different.
[0047] FIG. 3 illustrates a schematic diagram 300 of different versions of the ML model in accordance with some embodiments of the present disclosure. As shown in FIG. 3, the first version 310 (denoted as xt-1) may be updated to the second version 320 (denoted as xt) . In some embodiments, the first version 310 may include a first version of parameters of the ML model and the second version 320 may include a second version of parameters of the ML model. As used herein, different versions of the ML model may refer to different values of the parameters of the ML model. For example, values of one or more parameters of the parameters of the ML model may be different for the first version and second version.
[0048] In some embodiments, the ML model may comprise a language model. The first processing result may comprise a first text, and the second processing result may comprise a second text. Alternatively, or in addition, the ML model may comprise a video generation model. The first processing result may comprise a first video, and the second processing result may comprise a second video. Alternatively, or in addition, the ML model may comprise an image generation model. The first processing result may comprise a first image, and the second processing result may comprise a second image.
[0049] Embodiments of the present disclosure propose a framework for a preconditioned, variance-reduced stochastic optimization, which unifies both first-order and second-order adaptive gradient methods. Variance-reduced gradients achieve faster convergence than SGD, yet identifying optimal learning rates remains a practical challenge. Particularly, different parameters often exhibit varying curvatures, requiring tailored learning rates for each. One approach to addressing this issue is to use the Hessian matrix to precondition gradient updates, integrating curvature information into the updates. The idea stems from minimizing the second-order Taylor expansion at xt as follows:
[0050] Eq. (7) results in the updated formula where represents the Hessian matrix. The preconditioned gradient update may be encapsulated within a more generalized framework, leading to the following update rules:
[0051] Reference is now made back to FIG. 2, at block 220, the model training system 110 determines a variance reduction gradient corresponding to the second version based on the first processing result, the second processing result and a loss function. In embodiments of the present disclosure, the loss function may have any suitable form.
[0052] Combining Eq. (8) with Eq. (5) , the following pre-conditioned variance-reduced update may be obtained: where β1 represents a hyperparameter in a range of 0 and 1, mt represents the variance reduction gradient, xt-1 represents the first version, xt represents the second version and f (·) represents the loss function. may be determined according to the first processing result and may be determined according to the second processing result. In the example shown in the above Eq. (9) , the first sample and the second sample are the same, denoted by ξt.
[0053] In some embodiments, a first gradient of the loss function corresponding to the first version 310 of the ML model and a second gradient of the loss function corresponding to the second version 320 of the ML model may be derived. Then, a target gradient corresponding to the second version 320 may be determined by combining the second gradient and a scaled difference between the first gradient and the second gradient.
[0054] Alongside the pre-conditioned variance-reduced update in Eq. (9) , a variable γt may be introduced to control the scale of gradient correction in variance reduction. The new combination of gradient and gradient correction term may be extracted to ct, whose formal definition is given by: where ct represents target gradient, represents the first gradient, represents the second gradient and the second term of Eq. (11) represents the scaled difference between the first gradient and the second gradient.
[0055] When γt=1, Eq. (11) reduces to the second term of Eq. (9) . On the other hand, when γt=0, Eq. (11) reduces to the stochastic gradient. Therefore, ct may be seen as an alternative variance-reduced gradient estimator with flexible variance reduction.
[0056] After the target gradient is determined, the variance reduction gradient corresponding to the second version may be derived based on the target gradient and a further variance reduction gradient corresponding to the first version.
[0057] In some embodiments, in accordance with a determination that the target gradient indicates that a change of the loss function exceeds a threshold, the target gradient may be normalized based on a magnitude of the target gradient. Building on techniques from deep learning models, an example normalization process of the target gradient may include gradient clipping on ct, represented by: where ∥ct∥2>1 represents the change of the loss function exceeding the threshold (i.e., 1) and represents the normalized target gradient. In this way, the target gradient undergoes gradient clipping and is subsequently subjected to exponential averaging and thus the computational stability may be guaranteed throughout the training process.
[0058] After the normalization process of the target gradient is performed, the variance reduction gradient corresponding to the second version may be derived based on the normalized target gradient and the further variance reduction gradient. With adjustable VR intensity and gradient clipping, the variance reduction gradient mt may be written as the EMA of ct. The variance reduction gradient may be derived as follows: where mt-1 represents the further variance reduction gradient.
[0059] At block 230, the model training system 110 updates the second version of the ML model to a third version of the ML model based on the variance reduction gradient and curvature information of the loss function corresponding to the second version. As shown in FIG. 3, the third version 330 (denoted as xt+1) may be updated from the second version 320.
[0060] In some embodiments, for a candidate version of a plurality of candidate versions of the ML model, an impact factor may be determined based on the variance reduction gradient and a candidate version of the ML model, and a proximity factor may be determined based on the curvature information and a difference between the second version and the candidate version. The impact factor may indicate an impact degree of a change from the second version to the candidate version on a gradient of the loss function. The proximity factor may indicate a proximity degree between the second version and the candidate version preconditioned on the curvature information. Then, the third version may be derived by decreasing the impact factor and the proximity factor over the plurality of candidate versions. The third version may be derived as follows: where xt+1 represents the third version, represents a candidate version of a plurality of candidate versions, η <mt, x> represents the impact factor indicating an impact on gradient of the loss function at the current iteration, and <mt, x> represents an inner product of mt (i.e., the variance reduction gradient) and x (i.e., the candidate version) . Furthermore, represents the proximity factor and Ht represents the curvature information.
[0061] In some embodiments, a target candidate version minimizing a sum of the impact factor and the proximity factor may be determined from the plurality of candidate versions. The target candidate version may be employed as the third version 330.
[0062] In some embodiments, the curvature information may include a Hessian matrix (sometimes also referred to as a Hessian information matrix) . Calculating the Hessian information matrix is computationally impractical due to the complexity of second-order differentiation and the significant memory cost of storing Ht, especially when the parameters in a neural network constitute a high-dimensional matrix. Approximations of the Hessian information may be employed.
[0063] In some embodiments, the curvature information comprises diagonal elements of a Hessian matrix. By different choices of approximations to the Hessian matrix Ht , even when using approximated Hessian information matrices, second-order algorithms remain more computationally intensive compared to first-order gradient updates. Hessian information matrix may be utilized through diagonal approximations. This approach to diagonal preconditioning effectively transforms the updates into a first-order method, assigning adaptive learning rates to each gradient coordinate.
[0064] FIG. 4 illustrates a schematic diagram 400 of an algorithm summarizing the proposed solution in accordance with some embodiments of the present disclosure. As shown in FIG. 4, the code segment 405 indicates determining the target gradient, the code segment 410 indicates determining the variance reduction gradient and the code segment 415 indicates updating the second version of the ML model to the third version of the ML model.
[0065] The above have introduced the pre-conditioned variance-reduced update (also referred to as update of the third version 330) in Eq. (14) and explored various approaches for approximating the Hessian matrix. The following will introduce the solution proposed by embodiments of the present disclosure under different choices of Hessian matrix.
[0066] A first instance of proposed solution is built up on the idea of a first related work. The pre-conditioned variance-reduced update of the first related work may be summarized as follows:
[0067] In some embodiments, the curvature information may be represented based on a diagonal matrix that is derived by converting a momentum of the loss function corresponding to the second version. As can be seen from Eq. (15) to Eq. (18) , except for the ε added for computational stability, and the weight decay λxt for regularization, this related work may be seen as a step of mirror descent update in Eq. (8) with mt defined in Eq.(15) . The curvature information may be defined as follows: where Ht represents the curvature information, vt represents the momentum, diag (vt) represents the diagonal matrix, and β1 and β2 are hyperparameters controlling exponential decay rate of first order matrix estimation and second order matrix estimation.
[0068] In the first instance of proposed solution, the preconditioned variance-reduced update may be implemented as Eq. (14) , and the definitions for Ht, ε and weight decay as those specified from Eq. (15) to Eq. (19) may be utilized. vt is calculated as the EMA of gradients in the first related work, which may be adapted into a modified solution of the embodiments of the present disclosure. Specifically, the summation of the gradient and the gradient correction term are denoted as ct and vt is defined as the EMA of concluding the following: where γt represents an adjustable parameter that controls the extent of variance reduction which is usually set between 0 and 1.
[0069] Combining Eq. (20) to Eq. (22) together with Eq. (19) and Eq. (8) , an algorithm for the first instance of proposed solution is concluded. FIG. 5 illustrates a schematic diagram 500 of an algorithm summarizing the first instance of the proposed solution in accordance with some embodiments of the present disclosure. As shown in FIG. 5, the code segment 505 indicates determining the target gradient, the code segment 510 indicates determining the variance reduction gradient and the code segment 515 indicates updating the second version of the ML model to the third version of the ML model.
[0070] A second instance of proposed solution is built up on the idea of a second related work, which employs a sign operation to maintain uniform magnitude across all parameters. The optimization process for the second related work may be formulated as follows:
[0071] In some embodiments, the curvature information may be represented based on a diagonal matrix that is derived by converting a square of the variance reduction gradient corresponding to the second version. Instead of employing an EMA of gradient norms as in Eq. (16) and Eq. (19) , in the sign preconditioning mechanism in the second related work, the curvature information may be defined as follows: where represents the square of the variance reduction gradient corresponding to the second version. The definition for Ht is adopted as in Eq. (26) , which leads to an algorithm for the second instance of proposed solution. FIG. 6 illustrates a schematic diagram 600 of an algorithm summarizing the second instance of the proposed solution in accordance with some embodiments of the present disclosure. As shown in FIG. 6, the code segment 605 indicates determining the target gradient, the code segment 610 indicates determining the variance reduction gradient and the code segment 615 indicates updating the second version of the ML model to the third version of the ML model.
[0072] A third instance of proposed solution is built up on the idea of a third related work, which introduces a pre-conditioning approach that operates on the eigenspace of matrices. Given the update rule of the ML model is as follows:
[0073] In some embodiments, the curvature information may be represented based on a plurality of gradient matrices corresponding to a plurality of versions of the ML model respectively, and the plurality of versions comprises the second version and at least one version previous to the second version. The curvature information may be defined as follows: where represents the plurality of gradient matrices, t represents the plurality of versions of the ML model and is the corresponding weight matrix. In practice, an EMA is often used in place of the direct summation. Considering an EMA with β=0, the update rule of the ML model in Eq. (27) simplifies to This is equivalent to performing preconditioning on the eigenspace of Gt: Ut, Σt, Vt=SVD (Gt) ,
[0074] The eigenspace pre-conditioning is extracted from the third related work and the proposed solution is designed to pre-condition on any matrix-shaped VR gradients as in Eq. (29) , which leads to an algorithm for the third instance of proposed solution. FIG. 7 illustrates a schematic diagram 700 of an algorithm summarizing the third instance of the proposed solution in accordance with some embodiments of the present disclosure. As shown in FIG. 7, the line 705 indicates determining the target gradient, the line 710 indicates determining the variance reduction gradient and the line 715 indicates updating the second version of the ML model to the third version of the ML model. In this way, the proposed solution may be seamlessly integrated with related works and variance-reduction may be performed based on these related works.
[0075] As mentioned above, in some example embodiments, the first sample and the second sample may be different. For example, the first sample may be training data at the training step t, and the second sample may be training data at the training step t+1. Such embodiments are now described.
[0076] As can be seen from the proposed solution, the gradient may be calculated twice for different data with the same parameters. In some examples, may be used to approximate in Eq. (20) and ct will be redefined as:
[0077] FIG. 8 shows a block diagram of an apparatus 800 for preconditioned variance reduction in accordance with some embodiments of the present disclosure. The apparatus 800 may be implemented, for example, or included at the model training system 110 of FIG. 1. Various modules / components in the apparatus 800 may be implemented by hardware, software, firmware, or any combination thereof.
[0078] As shown, the apparatus 800 includes a processing result obtaining module 810 configured to obtain a first processing result on a first sample by a first version of a machine learning (ML) model and a second processing result on a second sample by a second version of the ML model, wherein the second version is update of the first version; a variance reduction gradient determining module 820 configured to determine a variance reduction gradient corresponding to the second version based on the first processing result, the second processing result and a loss function; and a version updating module 830 configured to update the second version of the ML model to a third version of the ML model based on the variance reduction gradient and curvature information of the loss function corresponding to the second version.
[0079] In some embodiments, updating the second version of the ML model to the third version of the ML model comprises: for a candidate version of a plurality of candidate versions of the ML model, determining an impact factor based on the variance reduction gradient and a candidate version of the ML model, the impact factor indicating an impact degree of a change from the second version to the candidate version on a gradient of the loss function; determining a proximity factor based on the curvature information and a difference between the second version and the candidate version, the proximity factor indicating a proximity degree between the second version and the candidate version preconditioned on the curvature information; and deriving the third version by decreasing the impact factor and the proximity factor over the plurality of candidate versions.
[0080] In some embodiments, deriving the third version by decreasing the impact factor and the proximity factor against the plurality of candidate versions comprises: determining, from the plurality of candidate versions, a target candidate version minimizing a sum of the impact factor and the proximity factor.
[0081] In some embodiments, determining the variance reduction gradient corresponding to the second version comprises: deriving a first gradient of the loss function corresponding to the first version of the ML model; deriving a second gradient of the loss function corresponding to the second version of the ML model; determining a target gradient corresponding to the second version by combining the second gradient and a scaled difference between the first gradient and the second gradient; and deriving the variance reduction gradient corresponding to the second version based on the target gradient and a further variance reduction gradient corresponding to the first version.
[0082] In some embodiments, deriving the variance reduction gradient corresponding to the second version comprises: in accordance with a determination that the target gradient indicates that a change of the loss function exceeds a threshold, normalizing the target gradient based on a magnitude of the target gradient; and deriving the variance reduction gradient corresponding to the second version based on the normalized target gradient and the further variance reduction gradient.
[0083] In some embodiments, the curvature information comprises diagonal elements of a Hessian matrix.
[0084] In some embodiments, the curvature information is represented based on a diagonal matrix that is derived by converting a momentum of the loss function corresponding to the second version.
[0085] In some embodiments, the curvature information is represented based on a diagonal matrix that is derived by converting a square of the variance reduction gradient corresponding to the second version.
[0086] In some embodiments, the curvature information is represented based on a plurality of gradient matrices corresponding to a plurality of versions of the ML model respectively, and the plurality of versions comprises the second version and at least one version previous to the second version.
[0087] In some embodiments, the ML model comprises a language model, the first processing result comprises a first text, and the second processing result comprises a second text.
[0088] FIG. 9 illustrates a block diagram of an electronic device 900 in which one or more embodiments of the present disclosure can be implemented. It would be appreciated that the electronic device 900 shown in FIG. 9 is only an example and should not constitute any restriction on the function and scope of the embodiments described herein. The electronic device 900 may be used, for example, to implement the model training system 110 of FIG. 1. The electronic device 900 may also be used to implement the apparatus 800 of FIG. 8.
[0089] As shown in FIG. 9, the electronic device 900 is in the form of a general computing device. The components of the electronic device 900 may include, but are not limited to, one or more processors or processing units 910, a memory 920, a storage device 930, one or more communication units 940, one or more input devices 950, and one or more output devices 960. The processing unit 910 may be an actual or virtual processor and can execute various processes according to the programs stored in the memory 920. In a multiprocessor system, multiple processing units execute computer executable instructions in parallel to improve the parallel processing capability of the electronic device 900.
[0090] The electronic device 900 typically includes a variety of computer storage medium. Such medium may be any available medium that is accessible to the electronic device 900, including but not limited to volatile and non-volatile medium, removable and non-removable medium. The memory 920 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 930 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 900.
[0091] The electronic device 900 may further include additional removable / non-removable, volatile / non-volatile storage medium. Although not shown in FIG. 9, 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 920 may include a computer program product 925, which has one or more program modules configured to perform various methods or acts of various embodiments of the present disclosure.
[0092] The communication unit 940 communicates with a further computing device through the communication medium. In addition, functions of components in the electronic device 900 may be implemented by a single computing cluster or multiple computing machines, which can communicate through a communication connection. Therefore, the electronic device 900 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.
[0093] The input device 950 may be one or more input devices, such as a mouse, a keyboard, a trackball, etc. The output device 960 may be one or more output devices, such as a display, a speaker, a printer, etc. The electronic device 900 may also communicate with one or more external devices (not shown) through the communication unit 940 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 900, or communicate with any device (for example, a network card, a modem, etc. ) that makes the electronic device 900 communicate with one or more other computing devices. Such communication may be executed via an input / output (I / O) interface (not shown) .
[0094] 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.
[0095] 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.
[0096] 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.
[0097] 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.
[0098] 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.
[0099] Each implementation of the present disclosure has been described above. The above description is an 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
A computer implemented method, comprising:obtaining a first processing result on a first sample by a first version of a machine learning (ML) model and a second processing result on a second sample by a second version of the ML model, wherein the second version is update of the first version;determining a variance reduction gradient corresponding to the second version based on the first processing result, the second processing result and a loss function; andupdating the second version of the ML model to a third version of the ML model based on the variance reduction gradient and curvature information of the loss function corresponding to the second version.The method of claim 1, wherein updating the second version of the ML model to the third version of the ML model comprises:for a candidate version of a plurality of candidate versions of the ML model,determining an impact factor based on the variance reduction gradient and a candidate version of the ML model, the impact factor indicating an impact degree of a change from the second version to the candidate version on a gradient of the loss function;determining a proximity factor based on the curvature information and a difference between the second version and the candidate version, the proximity factor indicating a proximity degree between the second version and the candidate version preconditioned on the curvature information; andderiving the third version by decreasing the impact factor and the proximity factor over the plurality of candidate versions.The method of claim 2, wherein deriving the third version by decreasing the impact factor and the proximity factor against the plurality of candidate versions comprises:determining, from the plurality of candidate versions, a target candidate version minimizing a sum of the impact factor and the proximity factor.The method of claim 1, wherein determining the variance reduction gradient corresponding to the second version comprises:deriving a first gradient of the loss function corresponding to the first version of the ML model;deriving a second gradient of the loss function corresponding to the second version of the ML model;determining a target gradient corresponding to the second version by combining the second gradient and a scaled difference between the first gradient and the second gradient; andderiving the variance reduction gradient corresponding to the second version based on the target gradient and a further variance reduction gradient corresponding to the first version.The method of claim 4, wherein deriving the variance reduction gradient corresponding to the second version comprises:in accordance with a determination that the target gradient indicates that a change of the loss function exceeds a threshold, normalizing the target gradient based on a magnitude of the target gradient; andderiving the variance reduction gradient corresponding to the second version based on the normalized target gradient and the further variance reduction gradient.The method of claim 1, wherein the curvature information comprises diagonal elements of a Hessian matrix.The method of claim 1, wherein the curvature information is represented based on a diagonal matrix that is derived by converting a momentum of the loss function corresponding to the second version.The method of claim 1, wherein the curvature information is represented based on a diagonal matrix that is derived by converting a square of the variance reduction gradient corresponding to the second version.The method of claim 1, wherein the curvature information is represented based on a plurality of gradient matrices corresponding to a plurality of versions of the ML model respectively, and the plurality of versions comprises the second version and at least one version previous to the second version.The method of claim 1, wherein the ML model comprises a language model, the first processing result comprises a first text, and the second processing result comprises a second text.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 acts comprising:obtaining a first processing result on a first sample by a first version of a machine learning (ML) model and a second processing result on a second sample by a second version of the ML model, wherein the second version is update of the first version;determining a variance reduction gradient corresponding to the second version based on the first processing result, the second processing result and a loss function; andupdating the second version of the ML model to a third version of the ML model based on the variance reduction gradient and curvature information of the loss function corresponding to the second version.The electronic device of claim 11, wherein updating the second version of the ML model to the third version of the ML model comprises:for a candidate version of a plurality of candidate versions of the ML model,determining an impact factor based on the variance reduction gradient and a candidate version of the ML model, the impact factor indicating an impact degree of a change from the second version to the candidate version on a gradient of the loss function;determining a proximity factor based on the curvature information and a difference between the second version and the candidate version, the proximity factor indicating a proximity degree between the second version and the candidate version preconditioned on the curvature information; andderiving the third version by decreasing the impact factor and the proximity factor over the plurality of candidate versions.The electronic device of claim 12, wherein deriving the third version by decreasing the impact factor and the proximity factor against the plurality of candidate versions comprises:determining, from the plurality of candidate versions, a target candidate version minimizing a sum of the impact factor and the proximity factor.The electronic device of claim 11, wherein determining the variance reduction gradient corresponding to the second version comprises:deriving a first gradient of the loss function corresponding to the first version of the ML model;deriving a second gradient of the loss function corresponding to the second version of the ML model;determining a target gradient corresponding to the second version by combining the second gradient and a scaled difference between the first gradient and the second gradient; andderiving the variance reduction gradient corresponding to the second version based on the target gradient and a further variance reduction gradient corresponding to the first version.The electronic device of claim 14, wherein deriving the variance reduction gradient corresponding to the second version comprises:in accordance with a determination that the target gradient indicates that a change of the loss function exceeds a threshold, normalizing the target gradient based on a magnitude of the target gradient; andderiving the variance reduction gradient corresponding to the second version based on the normalized target gradient and the further variance reduction gradient.The electronic device of claim 11, wherein the curvature information comprises diagonal elements of a Hessian matrix.The electronic device of claim 11, wherein the curvature information is represented based on a diagonal matrix that is derived by converting a momentum of the loss function corresponding to the second version.The electronic device of claim 11, wherein the curvature information is represented based on a diagonal matrix that is derived by converting a square of the variance reduction gradient corresponding to the second version.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 10.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 10.