Model training method and apparatus, and computer storage medium

By using distributed storage and asynchronous training, model parameters are distributed across multiple nodes, solving the problem of slow training speed in TensorFlow, improving model training speed and efficiency, and ensuring the accuracy and scalability of model training.

CN114185902BActive Publication Date: 2026-04-17BEIJING 360 INTELLIGENT TECHNOLOGY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING 360 INTELLIGENT TECHNOLOGY CO LTD
Filing Date
2020-09-15
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

TensorFlow's training speed is slow and its execution efficiency is low, making it difficult to meet the needs of large-scale model training.

Method used

The method employs distributed storage and asynchronous training, distributing model parameters across multiple nodes and uniformly allocating them using hash values. Training is performed by inputting only the model parameters required for the current training, and the parameters are updated by asynchronous uploading of gradient values ​​and machine learning optimization algorithms.

Benefits of technology

It significantly improves model training speed and execution efficiency, avoids network congestion and slow single-node training, and ensures the accuracy and scalability of model training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114185902B_ABST
    Figure CN114185902B_ABST
Patent Text Reader

Abstract

The application discloses a model training method and device and a computer storage medium. The method comprises the following steps: acquiring at least one to-be-updated model parameter; the at least one to-be-updated model parameter is part of a model parameter; inputting the at least one to-be-updated model parameter into a model, acquiring a gradient value to update the at least one to-be-updated model parameter, and improving the training speed of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of big data, and in particular to a model training method, apparatus, and computer storage medium. Background Technology

[0002] When promoting ads on a webpage, it's often necessary to predict the click-through rate (CTR) of each ad and display the ads with the highest predicted CTRs in prominent positions on the webpage to achieve the desired advertising effect. CTR prediction is typically done using deep learning models. Developers generally choose TensorFlow as the training framework for these models. However, TensorFlow suffers from slow training speed and low execution efficiency. Summary of the Invention

[0003] This application provides a model training method, apparatus, and computer storage medium, which can improve the training speed of the model and increase execution efficiency.

[0004] In a first aspect, embodiments of this application provide a model training method, including:

[0005] Obtain at least one model parameter to be updated; the at least one model parameter to be updated is a part of the model parameters;

[0006] The at least one model parameter to be updated is input into the model, and the gradient value is obtained to update the at least one model parameter to be updated.

[0007] In this embodiment, by inputting only the model parameters that need to be updated for the current training into the model for training, compared with the current TensorFlow which inputs all model parameters into the model, the dimensionality of the input data is greatly reduced, the capacity of the embedding tensor is reduced, and thus the training speed of the model is improved.

[0008] In one possible implementation, the at least one model parameter to be updated is stored in multiple nodes.

[0009] The current TensorFlow implementation stores all model parameters on a single node. However, due to the limited storage capacity of a single node, some parameters are usually selected for optimal storage on that node. This embodiment of the application expands data storage capacity by distributing model parameters across multiple nodes, ensuring the comprehensiveness of model parameters and thus guaranteeing the accuracy of model training.

[0010] In one possible implementation, the at least one model parameter to be updated is evenly distributed among the multiple nodes according to its hash value.

[0011] This application embodiment distributes the model parameters evenly across the nodes according to the hash value of each model parameter, which can ensure that the network consumption of each node is equal and avoid network congestion caused by a certain node being called continuously.

[0012] In one possible implementation, before obtaining at least one model parameter to be updated, the method further includes:

[0013] Locate the storage node corresponding to each of the at least one model parameter to be updated;

[0014] Obtaining at least one model parameter to be updated includes:

[0015] The at least one model parameter to be updated is obtained from the storage node corresponding to each of the at least one model parameter to be updated.

[0016] This application embodiment can first obtain the storage node of the model parameters to be updated, and then obtain the model parameters to be updated from each node. Distributing the model parameters across multiple nodes can expand the data storage capacity, ensure the comprehensiveness of the model parameters, and thus ensure the accuracy of model training.

[0017] In one possible implementation, before finding the storage node of at least one model parameter to be updated, the method further includes: determining the hash value of the at least one model parameter to be updated;

[0018] The process of finding at least one storage node for a model parameter to be updated includes:

[0019] Based on the hash value of the at least one model parameter to be updated, determine the storage node corresponding to each of the at least one model parameter to be updated.

[0020] In this embodiment, hash values ​​are used to index the storage nodes of each model parameter, ensuring that the storage node corresponding to the model parameter can be accurately found, thereby ensuring the normal progress of model training.

[0021] In one possible implementation, the model parameters to be updated are obtained by the node storing the model parameters based on gradient values ​​uploaded by other nodes.

[0022] The distributed model training in this embodiment is asynchronous. The model parameters obtained by the current node can be obtained from the node corresponding to those parameters, and the model parameters in the corresponding node can be updated by the gradient information uploaded by other nodes. By adopting asynchronous training, the problem of slow training speed of some nodes causing slow training speed of the entire model can be avoided, thereby improving the training speed of the model.

[0023] In one possible implementation, after updating the at least one model parameter to be updated, the method further includes:

[0024] The gradient values ​​of the at least one model parameter to be updated obtained from training are uploaded to the storage node corresponding to each of the at least one model parameter to be updated, so that the storage node corresponding to each of the at least one model parameter to be updated can use a machine learning optimization algorithm to update the at least one model parameter to be updated.

[0025] The distributed model training in this embodiment is asynchronous. The current node obtains the gradient of the parameters and uploads it to the corresponding storage node. Then, a machine learning optimization algorithm is used to optimize the parameters, resulting in new parameters. This ensures that other nodes can access the latest model parameters when they subsequently update them. Asynchronous training avoids the problem of slow training speeds on some nodes affecting the overall model training speed, thus improving the overall training speed.

[0026] Secondly, embodiments of this application provide a model training apparatus, including:

[0027] An acquisition module is used to acquire at least one model parameter to be updated; the at least one model parameter to be updated is a part of the model parameters.

[0028] The training module is used to input the at least one model parameter to be updated into the model, train it to obtain the gradient value of the at least one model parameter to be updated, and update the at least one model parameter to be updated.

[0029] In one possible implementation, the at least one model parameter to be updated is stored in multiple nodes.

[0030] In one possible implementation, the at least one model parameter to be updated is evenly distributed among the multiple nodes according to its hash value.

[0031] In one possible implementation, the device further includes:

[0032] The lookup module is used to find the storage node corresponding to each of the at least one model parameter to be updated;

[0033] The acquisition module is specifically used to: acquire the at least one model parameter to be updated from the storage node corresponding to each of the at least one model parameter to be updated.

[0034] In one possible implementation, the device further includes:

[0035] A determining module is used to determine the hash value of the at least one model parameter to be updated;

[0036] The search module is specifically used to: determine the storage node corresponding to each of the at least one model parameter to be updated based on the hash value of the at least one model parameter to be updated.

[0037] In one possible implementation, the model parameters to be updated are obtained by the node storing the model parameters based on gradient values ​​uploaded by other nodes.

[0038] In one possible implementation, the device further includes:

[0039] An upload module is used to upload the gradient values ​​of the at least one model parameter to be updated obtained from training to the storage node corresponding to each of the at least one model parameter to be updated, so that the storage node corresponding to each of the at least one model parameter to be updated can use a machine learning optimization algorithm to train the at least one model parameter to be updated.

[0040] Thirdly, embodiments of this application provide a model training apparatus, including: a processor and a memory; wherein the memory stores a computer program, the computer program being adapted to be loaded and executed by the processor:

[0041] Obtain at least one model parameter to be updated; the at least one model parameter to be updated is a part of the model parameters;

[0042] The at least one model parameter to be updated is input into the model, and the gradient value is obtained to update the at least one model parameter to be updated.

[0043] In one possible implementation, the at least one model parameter to be updated is stored in multiple nodes.

[0044] In one possible implementation, the at least one model parameter to be updated is evenly distributed among the multiple nodes according to its hash value.

[0045] In one possible implementation, before the processor obtains at least one model parameter to be updated, it is also used to perform:

[0046] Locate the storage node corresponding to each of the at least one model parameter to be updated;

[0047] Obtaining at least one model parameter to be updated includes:

[0048] The at least one model parameter to be updated is obtained from the storage node corresponding to each of the at least one model parameter to be updated.

[0049] In one possible implementation, before the processor locates the storage node for at least one model parameter to be updated, it is further configured to perform: determining the hash value of the at least one model parameter to be updated;

[0050] When the processor searches for a storage node containing at least one model parameter to be updated, it specifically executes the following:

[0051] Based on the hash value of the at least one model parameter to be updated, determine the storage node corresponding to each of the at least one model parameter to be updated.

[0052] In one possible implementation, the model parameters to be updated are obtained by the node storing the model parameters based on gradient values ​​uploaded by other nodes.

[0053] In one possible implementation, after updating the at least one model parameter to be updated, the processor is further configured to perform:

[0054] The gradient information of the at least one model parameter to be updated after training is uploaded to the storage node corresponding to each of the at least one model parameter to be updated, so that the storage node corresponding to each of the at least one model parameter to be updated can use a machine learning optimization algorithm to train the at least one model parameter to be updated.

[0055] Fourthly, embodiments of this application provide a computer storage medium storing a plurality of instructions adapted for loading by a processor and executing the method steps provided by the first aspect or any implementation thereof of the embodiments of this application.

[0056] Fifthly, embodiments of this application provide a computer program product containing instructions that, when run on a computer or processor, cause the computer or processor to execute the encoding method provided by the first aspect of the embodiments of this application or any possible implementation thereof.

[0057] Understandably, the model training apparatus provided in the second aspect, the model training apparatus provided in the third aspect, the computer storage medium provided in the fourth aspect, and the computer program product provided in the fifth aspect are all used to execute the model training method provided in the first aspect. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects of the model training method provided in the first aspect, and will not be repeated here. Attached Figure Description

[0058] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0059] Figure 1 This is a schematic diagram of the structure of a model training system provided in an embodiment of this application;

[0060] Figure 2 A schematic flowchart illustrating a model training method provided in an embodiment of this application;

[0061] Figure 3 A flowchart illustrating another model training method provided in an embodiment of this application;

[0062] Figure 4 A demonstration diagram of an asynchronous training model provided for an embodiment of this application;

[0063] Figure 5 This is a schematic diagram of the structure of a model training device provided in an embodiment of this application;

[0064] Figure 6 This is a schematic diagram of another model training device provided in an embodiment of this application. Detailed Implementation

[0065] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.

[0066] The terms "first," "second," "third," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.

[0067] Figure 1 An exemplary schematic diagram of a model training system provided in an embodiment of this application is shown. Figure 1 As shown, the model training system 10 may include at least one or more model training devices 110 and data storage devices 120. Figure 1The illustrated model training system 10 includes three model training devices (110a, 110b, and 110c). The data storage device 120 can be an application server used to store massive amounts of user data. For example, if 300 million users use the website, and each user browses the website multiple times a day, then each user browsing a webpage can generate one piece of user data. This user data can be used to train the model and update the model parameters. Exemplarily, user data can be information left by a user each time they browse a webpage, including, but not limited to, user identification (ID), user-input query request information, query results, etc.

[0068] The model training device 110 can read user data from the aforementioned data storage device 120 to train the model. After the model is trained, it can be used, but is not limited to, to recommend advertisements to users. Specifically, the model can be used to predict which advertisements a user might be interested in, and display the advertisements that the user is most likely to be interested in in the most prominent position based on the prediction results. It is understood that a model can include a large number of model parameters, and the model training device 110 needs to continuously update the model parameters to make the prediction results of the model continuously more accurate.

[0069] The model training device 110 involved in the embodiments of this application can be a tablet computer, desktop computer, laptop computer, ultra-mobile personal computer (UMPC), handheld computer, netbook, personal digital assistant (PDA), server, etc.

[0070] Specifically, backend personnel can pre-authorize the model training device 110 to read user data from the data storage device 120. The model training device 110 can interact with the data storage device 120 via a network. This network can be a wired network or a wireless network. Each model training device 110, in addition to training the model, can also store some model parameters. This can be done using a hash table. The hash table can include each model parameter and its corresponding hash value. The hash value of each model parameter can be determined by its ID. The specific contents of the hash table can be determined based on the model parameters corresponding to the model training device 110 it stores.

[0071] like Figure 1As shown, the hash table stored in model training device 110a can be part-a; the hash table stored in model training device 110b can be part-b; and the hash table stored in model training device 110c can be part-c. It can be seen that parts-a, part-b, and part-c of the hash table can be combined to form a complete hash table. Each model training device can query each other's hash table to determine the storage location of the model parameters. Therefore, the various model training devices can also communicate with each other. The communication method can be wired or wireless.

[0072] Not limited to Figure 1 The number of model training devices shown is not limited to the number shown in the diagram. In a specific implementation, the model training system 10 may include more or fewer model training devices. The number of data storage devices 120 is also not limited to this number. Figure 1 The model training system 10 shown is one example; in specific implementations, it may include more data storage devices. This application does not limit the number of model training devices 110 and data storage devices 120.

[0073] Specifically, the data storage device 120 can divide the massive amount of user data it stores into smaller parts, and different model training devices (referred to as nodes in the following embodiments) can read different parts of the user data in the data storage device 120. Taking the division of user data into 100 parts (numbered from 00-99) and the existence of 5 nodes as an example, the correspondence between the parts of user data that each node can read (data parts) is shown in Table 1.

[0074] Table 1 shows the data relationship between nodes and their corresponding nodes.

[0075] node Node 1 Node 2 Node 3 Node 4 Node 5 Data section 00-19 20-39 40-59 60-79 80-99

[0076] As shown in Table 1, node 1 can read user data from portions 00-19 of data storage device 120; node 2 can read user data from portions 20-39 of data storage device 120; node 3 can read user data from portions 40-59 of data storage device 120; node 4 can read user data from portions 60-79 of data storage device 120; and node 5 can read user data from portions 80-99 of data storage device 120. Therefore, each portion can include multiple records of user data.

[0077] It is known that user data can include multiple features, such as ad ID, user ID, and the user's city. Each feature typically corresponds to different dimensions, ranging from tens to hundreds of millions. For example, a user ID often has hundreds of millions of dimensions (representing hundreds of millions of users), and the user's city can have hundreds of dimensions (representing hundreds of cities). When there are many features, extracting model parameters from these high-dimensional features poses a significant challenge for training the model. In this embodiment, the hash value corresponding to each model parameter can be determined based on its ID, and the node it belongs to can be queried based on the hash value.

[0078] Next, join Figure 1 The illustrated model training system introduces a model training method provided in this application embodiment. This model training method can be executed by any one of the model training devices 110 in the model training system 10. For example... Figure 2 As shown, the model training method can include at least the following steps:

[0079] S201: Obtain at least one model parameter to be updated.

[0080] Specifically, the number of model parameters is large, while the model parameters needed for each training session (i.e., the model parameters to be updated) are only a portion of all model parameters. That is, at least one model parameter to be updated is a subset of all model parameters. Therefore, in this embodiment, the model parameters required for the current training can be obtained first.

[0081] Possibly, all model parameters can be stored in the model training device (node). This implementation is suitable for scenarios with a small number of model parameters, where a single node can store all model parameters.

[0082] It is possible that the above model parameters can be distributed and stored across multiple nodes (i.e., Figure 1 In the multiple model training devices shown, each node can train the model independently. Different nodes can store different model parameters. If a node wants to obtain the model parameters to be updated, these parameters might be stored in other nodes, requiring the node to retrieve them from those nodes. At least one of these model parameters to be updated might be stored in the same node or in different nodes.

[0083] S202: Input at least one of the model parameters to be updated into the model, obtain the gradient value, and update the at least one model parameter to be updated.

[0084] Specifically, after inputting at least one of the model parameters to be updated into the model, the gradient information can be calculated using optimization algorithms such as gradient descent, and then the values ​​of each parameter to be updated can be updated. The loss function of the updated model will gradually decrease, indicating that the accuracy of the model is gradually improving.

[0085] Specifically, when constructing a model with sparse features using TensorFlow, a large embedding tensor must be constructed, which is usually very large.

[0086] For example, the embedding tensor for the ad dimension can typically exceed 100 million dimensions. Assuming each ad needs to be represented by four numbers, and there are a total of 300 million ads, a matrix of size (300 million, 4) would be required to represent these 300 million ads. However, in actual model training, each training iteration only involves updating a small portion of the model parameters, such as the parameters of only 32 ads. In this case, we only need to find the 32 ads needed from the 300 million ads and input the (32, 4) matrix representing these 32 ads into the model. This reduces the size of the embedding tensor, thereby improving the training speed of the model.

[0087] This application embodiment trains the model by inputting only the model parameters that need to be updated for the current training, using a small tensor that can hold a batch of data. Compared with the current TensorFlow, which inputs all model parameters into the model, this greatly reduces the dimensionality of the input data, reduces the size of the embedding tensor, and minimizes the lookup and synchronization overhead of the sparse embedding tensor, thereby improving the training speed of the model.

[0088] Figure 3 This application provides an exemplary embodiment of another model training method, which is an asynchronous distributed training method. This means that multiple model training devices (nodes) can be used to train the model, and the training process of each node does not depend on the model training process of other nodes. For example... Figure 3 As shown, the model training method can include at least the following steps:

[0089] S301: Determine the hash value of at least one model parameter to be updated.

[0090] Specifically, the number of model parameters is large, while the model parameters needed for each training session (i.e., the model parameters to be updated) are only a portion of all the model parameters. Therefore, in this embodiment, the model parameters required for the current training can be obtained first.

[0091] Specifically, each model parameter can correspond to a hash value. These model parameters can then be evenly distributed across the nodes based on their hash values. This ensures equitable network consumption for each node and prevents network congestion caused by a single node being continuously accessed.

[0092] S302: Based on the hash value of the at least one model parameter to be updated, determine the storage node corresponding to each of the at least one model parameter to be updated.

[0093] Specifically, each node can store a hash table. For example... Figure 1 As shown, the hash table stored in model training device 110a can be part-a; the hash table stored in model training device 110b can be part-b; and the hash table stored in model training device 110c can be part-c. It can be seen that part-a, part-b, and part-c of the hash table can be combined to form a complete hash table. The specific content of the hash table stored in each node can be determined according to the model parameters corresponding to the node it stores.

[0094] Specifically, after determining the hash value of the model parameter to be updated, it is only necessary to check whether the corresponding hash value exists in the hash table stored on each node. If so, it is determined that the model parameter to be updated is stored in that node.

[0095] S303: Obtain at least one model parameter to be updated from the storage node corresponding to each of the at least one model parameter to be updated.

[0096] Specifically, after determining the storage node of the model parameters to be updated, the model parameters can be obtained from the storage node corresponding to each model parameter to be updated.

[0097] For example, at least one parameter that needs to be updated can be a specific batch of user data retrieved sequentially from the user data corresponding to that node, determining the user ID in each batch. The corresponding storage node is then located based on the hash value of the user ID. The model parameter corresponding to that user ID is then retrieved from the corresponding storage node.

[0098] For example, user data generated by user A browsing web pages in the morning is assigned to part 38 (corresponding to node 2), while user data generated by user A browsing web pages in the afternoon is assigned to part 09 (corresponding to node 1). Based on the hash value of the model parameter corresponding to user A's user ID, this model parameter is stored in node 4. Therefore, after node 1 obtains the user data from part 09, it determines that the model parameter corresponding to the user ID is stored in node 4 based on the hash value, and can then retrieve this model parameter from node 4. Similarly, after node 2 obtains the user data from part 38, it determines that the model parameter corresponding to the user ID is stored in node 4 based on the hash value, and can also retrieve this model parameter from node 4.

[0099] S304: Input the values ​​of at least one of the model parameters to be updated into the model, and obtain the gradient values ​​corresponding to each of the at least one model parameter to be updated.

[0100] Specifically, after obtaining the latest model parameters to be updated from other nodes, these parameters can be input into the model to train it using optimization algorithms such as gradient descent. After calculating the gradient values, these values ​​are sent to the corresponding storage node, allowing the storage node to update the parameters based on these gradients. The updated model's loss gradually decreases, indicating that the model's accuracy is gradually improving. The updated model parameters can be obtained through training using gradient values ​​uploaded from other nodes to the corresponding storage node.

[0101] S305: Upload the gradient values ​​of at least one of the above-mentioned model parameters to be updated after training to the storage nodes corresponding to each of the above-mentioned model parameters to be updated.

[0102] Specifically, after training is complete, the current node can upload the gradient values ​​of the trained model parameters to be updated to its corresponding storage node to update the latest parameter values, so that other nodes can further train and update the model parameters.

[0103] Specifically, storage nodes can use machine learning optimization algorithms to update the model parameters based on gradient values. These machine learning optimization algorithms can be, but are not limited to, stochastic gradient descent (SGD), batch gradient descent (BGD), Adagrad, Adam, etc.

[0104] It's possible that the updated model parameter values ​​can be obtained by combining the previous model parameter values ​​with historical gradient values. For example, the updated model parameter values ​​can be obtained by summing the squares of the previous model parameter values ​​and the historical gradient values. The historical gradient values ​​are the gradient values ​​uploaded by other nodes before this update.

[0105] It is possible that the updated model parameter values ​​can be the sum of the original model parameter values ​​and the gradient values. The following... Figure 4 This embodiment uses this calculation method as an example for illustrative purposes.

[0106] However, there are other ways to calculate the updated model parameters and the original model parameters and gradient values, which are not limited in this application embodiment.

[0107] Specifically, the difference between the updated model parameters and the original model parameters can be called the update step size. It is known that the longer the update step size, the faster the model updates. As the model update progresses, the update step size needs to be gradually decreased so that the model parameters can approach the ideal value infinitely.

[0108] Figure 4 An exemplary diagram illustrating the asynchronous training model provided in an embodiment of this application is shown. Figure 4 As shown, there are 5 nodes training the model, and the model parameter 'a' (with a value of a1) is stored in node 4. At time T1, node 1 needs to use the model parameter 'a' (with a value of a1) for training. Node 1 can determine that the model parameter 'a' (with a value of a1) is stored in node 4 based on its hash value. After determining its storage node, node 1 can retrieve the model parameter 'a' with the value a1 from node 4 and input it into the model for training, obtaining the gradient value g1 corresponding to the model parameter 'a'. After training, node 1 sends the gradient value g1 of the model parameter 'a' to node 4, and node 4 uses the gradient value to update the latest value of the parameter 'a' to a2 (at time T2).

[0109] Next, at time T3, node 3 needs to update the model parameter a (latest value a2). Node 3 can determine that the model parameter a is stored in node 4 based on its hash value. After determining its storage node, node 3 can retrieve the model parameter a with the value a2 from node 4 and input it into the model for training, obtaining the gradient value g2 corresponding to the model parameter a. After training, node 3 sends the gradient value g2 of the model parameter a to node 4, and node 4 uses the gradient value g2 to update the latest value of parameter a to a3 (time T4).

[0110] This application embodiment trains the model by inputting only the model parameters needed for the current training, using a small tensor capable of accommodating a batch of data. Compared to TensorFlow's current approach of inputting all model parameters, this significantly reduces the dimensionality of the input data, decreases the size of the embedding tensor, and minimizes the lookup and synchronization overhead of the sparse embedding tensor, thereby improving the model's training speed. Furthermore, distributing the model parameters evenly across nodes according to their hash values ​​expands data storage capacity, ensures the comprehensiveness of model parameters and thus guarantees training accuracy, and ensures equitable network consumption across nodes, preventing network congestion caused by a single node being constantly invoked. Moreover, this application embodiment employs asynchronous training, which avoids slow training speeds on some nodes affecting the overall model training speed, further improving the overall training speed.

[0111] Figure 5 An exemplary schematic diagram of a model training apparatus provided in an embodiment of this application is shown. Figure 5 As shown, the model training device 50 may include at least: an acquisition module 510 and an update module 520. Wherein:

[0112] The acquisition module 510 is used to acquire at least one model parameter to be updated; the at least one model parameter to be updated is a part of the model parameters.

[0113] The update module 520 is used to input the at least one model parameter to be updated into the model and obtain the gradient value to update the at least one model parameter to be updated.

[0114] In one possible embodiment, the at least one model parameter to be updated is stored in multiple nodes.

[0115] In one possible embodiment, the at least one model parameter to be updated is evenly distributed among the plurality of nodes according to its hash value.

[0116] In one possible embodiment, the model training device 50 further includes:

[0117] The lookup module is used to find the storage node corresponding to each of the at least one model parameter to be updated;

[0118] The acquisition module 510 is specifically used to: acquire the at least one model parameter to be updated from the storage node corresponding to each of the at least one model parameter to be updated.

[0119] In one possible embodiment, the model training device 50 further includes:

[0120] A determining module is used to determine the hash value of the at least one model parameter to be updated;

[0121] The lookup module is specifically used to: determine the storage node corresponding to each of the at least one model parameter to be updated based on the hash value of the at least one model parameter to be updated.

[0122] In one possible embodiment, the model parameters to be updated are obtained by the node storing the model parameters based on gradient values ​​uploaded by other nodes.

[0123] In one possible embodiment, the model training device 50 further includes:

[0124] An upload module is used to upload the gradient values ​​of the at least one model parameter to be updated after training to the storage node corresponding to each of the at least one model parameter to be updated, so that the storage node corresponding to each of the at least one model parameter to be updated can use a machine learning optimization algorithm to train and update the at least one model parameter to be updated.

[0125] This application embodiment trains the model by inputting only the model parameters needed for the current training, using a small tensor capable of accommodating a batch of data. Compared to TensorFlow's current approach of inputting all model parameters, this significantly reduces the dimensionality of the input data, decreases the size of the embedding tensor, and minimizes the lookup and synchronization overhead of the sparse embedding tensor, thereby improving the model's training speed. Furthermore, distributing the model parameters evenly across nodes according to their hash values ​​expands data storage capacity, ensures the comprehensiveness of model parameters and thus guarantees training accuracy, and ensures equitable network consumption across nodes, preventing network congestion caused by a single node being constantly invoked. Moreover, this application embodiment employs asynchronous training, which avoids slow training speeds on some nodes affecting the overall model training speed, further improving the overall training speed.

[0126] It should be noted that the model training device provided in the above embodiments is only illustrated by the division of the above functional modules when executing the model training method. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the wireless screen projection connection device and the wireless screen projection connection method embodiments provided in the above embodiments belong to the same concept, and the implementation process is detailed in the method embodiments, which will not be repeated here.

[0127] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0128] Please see Figure 6 The diagram below illustrates the structure of a model training device provided in this application. Figure 6 As shown, the model training device 60 may include: at least one processor 601, at least one network interface 604, user interface 603, memory 605, and at least one communication bus 602.

[0129] The communication bus 602 is used to enable communication between these components.

[0130] The user interface 603 may include a display screen and a camera. Optionally, the user interface 603 may also include a standard wired interface and a wireless interface.

[0131] The network interface 604 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).

[0132] The processor 601 may include one or more processing cores. The processor 601 connects to various parts within the model training device 60 using various interfaces and circuits. It executes various functions and processes data of the electronic device 60 by running or executing instructions, programs, code sets, or instruction sets stored in the memory 605, and by calling data stored in the memory 605. Optionally, the processor 601 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 601 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content to be displayed on the screen; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 601 and may be implemented as a separate chip.

[0133] The memory 605 may include random access memory (RAM) or read-only memory. Optionally, the memory 605 may include a non-transitory computer-readable storage medium. The memory 605 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 605 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 605 may also be at least one storage device located remotely from the aforementioned processor 601. Figure 6 As shown, the memory 605, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a model training application.

[0134] exist Figure 6In the model training device 60 shown, the user interface 603 is mainly used to provide an input interface for the user and to obtain the user input data; while the processor 601 can be used to call the model training application stored in the memory 605 and specifically perform the following operations:

[0135] Obtain at least one model parameter to be updated; the at least one model parameter to be updated is a part of the model parameters;

[0136] The at least one model parameter to be updated is input into the model, and the gradient value is obtained to update the at least one model parameter to be updated.

[0137] In one possible embodiment, the at least one model parameter to be updated is stored in multiple nodes.

[0138] In one possible embodiment, the at least one model parameter to be updated is evenly distributed among the plurality of nodes according to its hash value.

[0139] In one possible embodiment, before the processor 601 acquires at least one model parameter to be updated, it is also configured to perform:

[0140] Locate the storage node corresponding to each of the at least one model parameter to be updated;

[0141] When the processor 601 obtains at least one model parameter to be updated, it specifically executes:

[0142] The at least one model parameter to be updated is obtained from the storage node corresponding to each of the at least one model parameter to be updated.

[0143] In one possible embodiment, before the processor 601 searches for the storage node of at least one model parameter to be updated, it is further configured to perform: determining the hash value of the at least one model parameter to be updated;

[0144] When the processor 601 searches for at least one storage node containing model parameters to be updated, it specifically executes the following:

[0145] Based on the hash value of the at least one model parameter to be updated, determine the storage node corresponding to each of the at least one model parameter to be updated.

[0146] In one possible embodiment, the model parameters to be updated are obtained by the node storing the model parameters based on gradient values ​​uploaded by other nodes.

[0147] In one possible embodiment, after updating the at least one model parameter to be updated, the processor 601 is further configured to perform:

[0148] The gradient values ​​of the at least one model parameter to be updated obtained from training are uploaded to the storage node corresponding to each of the at least one model parameter to be updated, so that the storage node corresponding to each of the at least one model parameter to be updated can use a machine learning optimization algorithm to train the at least one model parameter to be updated.

[0149] This application embodiment trains the model by inputting only the model parameters needed for the current training, using a small tensor capable of accommodating a batch of data. Compared to TensorFlow's current approach of inputting all model parameters, this significantly reduces the dimensionality of the input data, decreases the size of the embedding tensor, and minimizes the lookup and synchronization overhead of the sparse embedding tensor, thereby improving the model's training speed. Furthermore, distributing the model parameters evenly across nodes according to their hash values ​​expands data storage capacity, ensures the comprehensiveness of model parameters and thus guarantees training accuracy, and ensures equitable network consumption across nodes, preventing network congestion caused by a single node being constantly invoked. Moreover, this application embodiment employs asynchronous training, which avoids slow training speeds on some nodes affecting the overall model training speed, further improving the overall training speed.

[0150] This application also provides a computer-readable storage medium storing instructions that, when executed on a computer or processor, cause the computer or processor to perform the above-described instructions. Figures 2-4 One or more steps in the illustrated embodiment. If the constituent modules of the above-described model training device are implemented as software functional units and sold or used as independent products, they can be stored in the computer-readable storage medium.

[0151] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., digital versatile discs (DVDs)), or semiconductor media (e.g., solid-state drives (SSDs)).

[0152] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The aforementioned storage medium includes various media capable of storing program code, such as Read Only Memory (ROM), Random Access Memory (RAM), magnetic disks, or optical disks. Unless otherwise specified, the technical features of this embodiment and its implementation schemes can be combined arbitrarily.

[0153] The embodiments described above are merely preferred embodiments of this application and are not intended to limit the scope of this application. Any modifications and improvements made to the technical solutions of this application by those skilled in the art without departing from the spirit of this application should fall within the protection scope defined by the claims of this application.

Claims

1. A model training method, characterized in that, include: Locate the storage node corresponding to at least one model parameter to be updated, wherein the at least one model parameter to be updated is stored in multiple nodes respectively; Obtain at least one model parameter to be updated; the at least one model parameter to be updated is a part of the model parameters, and the model parameter to be updated is obtained by the node storing the model parameter to be updated based on the gradient values ​​uploaded by other nodes; The at least one model parameter to be updated is input into the model, and the gradient value is obtained to update the at least one model parameter to be updated. The storage node uses a machine learning optimization algorithm to update the model parameter to be updated based on the gradient value. The step of obtaining at least one model parameter to be updated includes: obtaining the at least one model parameter to be updated from the storage node corresponding to each of the at least one model parameter to be updated; After updating the at least one model parameter to be updated, the method further includes: The gradient values ​​of the at least one model parameter to be updated obtained from training are uploaded to the storage nodes corresponding to the at least one model parameter to be updated, so that the storage nodes corresponding to the at least one model parameter to be updated can use machine learning optimization algorithms to train the at least one model parameter to be updated; the updated model parameter value is obtained by combining the value of the model parameter before the update with the historical gradient value, wherein the historical gradient value is the gradient value uploaded by other nodes before this update.

2. The method of claim 1, wherein, The at least one model parameter to be updated is evenly distributed among the multiple nodes according to its hash value.

3. The method of claim 1, wherein, Before finding the storage node for at least one model parameter to be updated, the method further includes: determining the hash value of the at least one model parameter to be updated; The process of finding at least one storage node for a model parameter to be updated includes: Based on the hash value of the at least one model parameter to be updated, determine the storage node corresponding to each of the at least one model parameter to be updated.

4. A model training apparatus characterized by comprising: include: The lookup module is used to find the storage node corresponding to at least one model parameter to be updated, wherein the at least one model parameter to be updated is stored in multiple nodes respectively; The acquisition module is used to acquire at least one model parameter to be updated; The at least one model parameter to be updated is a part of the model parameters, and the model parameters to be updated are obtained by the node storing the model parameters to be updated based on the gradient values ​​uploaded by other nodes. The training module is used to input the at least one model parameter to be updated into the model, train to obtain the gradient value of the at least one model parameter to be updated in order to update the at least one model parameter to be updated, and the storage node uses a machine learning optimization algorithm to update the model parameter to be updated according to the gradient value. The search module is specifically used to: determine the storage node corresponding to each of the at least one model parameter to be updated based on the hash value of the at least one model parameter to be updated; The device further includes: An upload module is used to upload the gradient values ​​of the at least one model parameter to be updated obtained from training to the storage node corresponding to each of the at least one model parameter to be updated, so that the storage node corresponding to each of the at least one model parameter to be updated can use a machine learning optimization algorithm to train the at least one model parameter to be updated.

5. The apparatus of claim 4, wherein, The at least one model parameter to be updated is evenly distributed among the multiple nodes according to its hash value.

6. The apparatus of claim 4, wherein, The device further includes: A determining module is used to determine the hash value of the at least one model parameter to be updated; The search module is specifically used to: determine the storage node corresponding to each of the at least one model parameter to be updated based on the hash value of the at least one model parameter to be updated.

7. A model training apparatus characterized by comprising: include: A processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and executed the method steps as claimed in any one of claims 1-3.

8. A computer storage medium, characterized in that, The computer storage medium stores a plurality of instructions adapted for loading by a processor and executing the method steps as claimed in any one of claims 1-3.

Citation Information

Patent Citations

  • Model file storage method and device, readable storage medium and computer device

    CN109977077A

  • Fault-tolerant method and system for high-availability distributed machine learning computing framework

    CN110033095A

  • Model parameter updating method and device

    CN111461290A