Large model increment training method, system, equipment and medium
By chunking the large model training data set into small data sets in delta units and reading the corresponding weights and numbers during training interruptions, the problem of not being able to quickly restore the training site in the existing technology is solved, and incremental training and Improves training efficiency and robustness.
Patent Information
- Application Number
- CN202411152515.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-21
- Publication Date
- 2024-11-08
AI Technical Summary
The existing large-model training methods cannot quickly restore the field during the training process and cannot perform incremental training, resulting in wasted time and cost.
By chunking the training data set according to the preset classification ratio, a small data set of multiple delta units is formed, and these data sets are loaded in delta units for training in model training, saving the corresponding model weights and numbers. If the training is interrupted, the training will be interrupted. The last or preset numbered dataset and weights are read to restore the training site, and the loss value interval is divided using a Fibonacci sequence during the verification phase to determine the optimal weight.
It realizes rapid recovery of the training site after model training interruption and supports incremental training, which improves the robustness and efficiency of training and reduces verification time and cost.
Smart Images

Figure CN118917381A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a large model incremental training method, system, device and medium. Background Art
[0002] In the field of artificial intelligence (AI), big models usually refer to deep learning models with a large number of parameters and complex structures. Because big models can capture richer patterns and features in the data, they perform well in many tasks, such as natural language processing, computer vision, and speech recognition.
[0003] The current large model training method uses epoch + step as the unit for training and saving weights. If an accident occurs during training (such as a program crash) or the effect is not good (such as a worsening loss trend), the training site cannot be quickly restored, wasting time and cost. In addition, the existing large model training method requires the number of training data sets to be determined before training begins, and incremental training cannot be performed during training. Summary of the invention
[0004] In order to solve the problems existing in the prior art, the present invention provides a large model incremental training method, system, device and medium, which can quickly restore the training site after the model training is interrupted, and can perform incremental training during the training process.
[0005] To achieve the above object, the present invention provides a large model incremental training method, comprising: The training data set is divided into blocks according to the preset classification ratio to obtain a small data set of multiple delta units; Load the small data set in delta units for model training, count and number the currently loaded small data set, and save the model weight corresponding to the current number; If the model training is interrupted, the small data set and model weight corresponding to the last number or the preset number are read when the training is restarted to restore the training scene.
[0006] Optionally, while saving the model weight corresponding to the current number, the training loss value corresponding to the current number is recorded; the method further includes: In the weight verification phase, all saved training loss values are divided into multiple intervals according to the Fibonacci sequence; Select the lowest training loss value in each of the intervals; Based on the model weights corresponding to the minimum training loss values, respectively calculating the model loss values of the models after training is completed; According to the model loss value, the optimal model weight is determined.
[0007] Optionally, before loading the small data set in delta units for model training, the method further includes: Determine whether the value of the current epoch has reached the epoch upper limit. If so, end model training. Otherwise, determine whether the current delta unit load quantity has reached the delta upper limit. If yes, then add up the value of the current era and determine again whether the value of the current era reaches the upper limit of the era; If not, the small data set is loaded in delta units for model training, and the current number of delta units loaded is accumulated, and then it is determined again whether the current number of delta units loaded reaches the delta upper limit.
[0008] Optionally, before determining whether the current delta unit loading quantity reaches the delta upper limit, the method further includes: Determine the number of delta units to load based on the number of the last small dataset loaded.
[0009] The present invention also provides a large model incremental training system, comprising: A data set processing module is used to process the training data set in blocks according to a preset classification ratio to obtain a small data set of multiple delta units; Model training module, used to: Load the small data set in delta units for model training, count and number the currently loaded small data set, and save the model weight corresponding to the current number; If the model training is interrupted, the small data set and model weight corresponding to the last number or the preset number are read when the training is restarted to restore the training scene.
[0010] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above method when executing the computer program.
[0011] The present invention also provides a computer-readable storage medium on which a computer program is stored, and the computer program implements the above method when executed.
[0012] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects: The large model incremental training method provided by the present invention divides the training data set into multiple small data sets of delta (incremental) units. On the basis of the [epoch--step] two-layer nested loop training logic in the existing training method, a delta layer is added, and the [epoch--delta--step] three-layer nested loop training logic is changed; during the model training process, the data set is not fully loaded in the training initialization stage, but only the small data set of the current delta unit is loaded at the beginning of the delta layer logic. In this way, not only incremental training can be achieved, but also the recovery site logic is added to support the rapid recovery of the training site after the model training is interrupted, so as to continue the model training. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The above and other objects, features and advantages of the present invention will become more apparent through a more detailed description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, wherein like reference numerals generally represent like components throughout the exemplary embodiments of the present invention.
[0014] Figure 1 A method flow chart of a large model incremental training method shown in an embodiment of the present invention; Figure 2 A schematic diagram of a flow chart of an existing training method according to an embodiment of the present invention; Figure 3 A schematic diagram of the flow of an improved large model incremental training method according to an embodiment of the present invention; Figure 4 A schematic diagram of the module structure of a large model incremental training system according to an embodiment of the present invention; Figure 5 The figure is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0015] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0016] The purpose of the present invention is to provide a large model incremental training method, system, device and medium, which can quickly restore the training site after the model training is interrupted, and can perform incremental training during the training process.
[0017] See also Figure 1 , Figure 1The method flow of the large model incremental training method is as follows. The large model incremental training method includes the following steps: Step 101: Divide the training data set into blocks according to a preset classification ratio to obtain small data sets of multiple delta units.
[0018] The training data set used for training large models is usually large in size. In the application, the training data set can be divided into blocks according to the preset classification ratio to obtain small data sets of multiple delta units. Among them, the block processing can be divided according to the overall capacity of the training data set. For example, if the size of each block is predefined as 20M, then a training data set of 100M will be divided into 5 blocks; it is understandable that when it is impossible to divide evenly, the capacity of one training set is smaller than the predefined size of each block.
[0019] Regarding the preset classification ratio, the application can pre-classify according to the content of the training data set. For example, the content of the overall training data set can be divided into multiple categories such as news / books / encyclopedia / others / English as needed, and then determine the corresponding preset classification ratio, such as news 20% / books 30% / encyclopedia 30% / others 10% / English 10%; among which, the preset classification ratio is determined according to the number of tokens in each category. When performing block processing, the content composition of each block (delta) is determined according to the preset classification ratio. For example, the content in each delta unit of small data set is composed of the classification ratio of news 20% / books 30% / encyclopedia 30% / others 10% / English 10%.
[0020] Each training data set is classified to obtain a small data set of multiple delta units.
[0021] Previous model training all followed the two-layer nested loop training logic of "epoch--step". On this basis, the present invention adds a delta data unit between the epoch and the step in the training logic, that is, adds a delta layer.
[0022] Step 102: Load a small data set in delta units for model training, count and number the currently loaded small data set, and save the model weight corresponding to the current number.
[0023] During the model training process, due to the addition of a delta layer, when loading the training set, the full training data set is no longer directly loaded to participate in the model training as in the past, but a small data set is obtained in delta units to participate in the model training; for this reason, new training data sets can be added during the model training process, that is, on the basis of the existing number of small data sets, new small data sets in delta units are added to participate in the model training, thereby achieving incremental training.
[0024] During the model training process, each small data set of delta units will be counted and numbered, and the corresponding model weight will be saved; that is, all small data sets that have participated in model training will have their own unique number, and the corresponding number will save the model weight corresponding to the small data set.
[0025] Step 103: If the model training is interrupted, the small data set and model weight corresponding to the last number or the preset number are read when the training is restarted to restore the training scene.
[0026] Among them, model training interruption may be an accidental interruption, such as program crash, power outage, insufficient hard disk space, etc., or it may be a human interruption, such as manually interrupting training when poor training results are observed. Of course, it can also be a self-interruption, for example, setting a corresponding monitoring module to monitor the loss value of model training in real time. When the preset conditions are met, such as the increase in the loss value exceeds the preset threshold, the monitoring module sends a corresponding interrupt signal to the model training module to interrupt the model training.
[0027] When restarting training, you only need to use the last number (the last counted number before the training was interrupted) or the preset number (one of the counted numbers before the training was interrupted) to obtain the small data set that participated in the training last before the model training was interrupted, or the small data value corresponding to the preset number, as well as the corresponding model weight. This allows you to quickly restore the training site and continue model training.
[0028] Among them, the preset number can be manually set according to the actual training situation. For example, in the case of poor training effect, the delta data set corresponding to a certain number (preset number) before the loss trend deteriorates is manually selected to restore the training scene. Of course, the preset number can also be set to determine the corresponding recovery number determination module by itself; illustratively, the recovery number determination module can select the number corresponding to the last loss value that meets the decline condition before the training is interrupted as the preset number; the decline condition is smaller than the previous loss value.
[0029] See also Figure 2 and Figure 3Compared with the existing model training methods, the large model incremental training method provided by the present invention loads data training and saves weights in delta units. In the event of an accident or poor effect, the most appropriate delta weight can be selected to restore the training site, thereby improving the robustness of large model training while reducing the training cost of large models.
[0030] For further information, see Figure 3 Before loading a small dataset in delta units for model training, the above incremental training method also includes: Determine whether the value of the current epoch has reached the epoch upper limit. If so, end model training. Otherwise, determine whether the current delta unit load quantity has reached the delta upper limit. If yes, then add up the value of the current era and determine again whether the value of the current era reaches the upper limit of the era; If not, load a small data set in delta units for model training, accumulate the current number of delta units loaded, and then determine again whether the current number of delta units loaded has reached the delta upper limit.
[0031] Exemplarily, the number of delta units to be loaded can be determined according to the number of the last loaded small data set.
[0032] In one embodiment, while saving the model weight corresponding to the current number, the training loss value corresponding to the current number is also recorded; accordingly, the above large model incremental training method also includes: In the weight verification phase, all saved training loss values are divided into multiple intervals according to the Fibonacci sequence; Select the lowest training loss value in each interval; Based on the model weights corresponding to each minimum training loss value, the model loss value of the model after training is calculated respectively; Determine the optimal model weight based on the model loss value.
[0033] In the existing model training methods, the verification phase requires the verification calculation of all the weights saved after the training to obtain the loss value before the optimal weight can be obtained; while the large model incremental training method provided by the present invention does not require the verification calculation of all the saved model weights during the verification phase, but only requires the selection of a small number of model weights for verification, which greatly reduces the verification time and cost and improves the verification efficiency. Among them, the model loss value can be calculated using the cross-entropy loss function (Cross-Entropy Loss).
[0034] It can be understood that the large model incremental training method provided by the present invention can be applied to model training of large-scale (trillions of labeled tokens) data sets (multiple deltas) as well as model training of small data sets (1 delta).
[0035] In actual application, during a certain training process, monitoring found that the loss value after N+1 deltas rose very quickly, and there was a large-scale jump in the loss value. At this time, the training was stopped immediately. After investigation, it was found that the data quality of these delta data sets was very poor, with a large amount of repeated text and disordered garbled characters. After re-cleaning and replacing these delta data sets, a new batch of high-quality texts was sorted out at the same time. After dividing this batch of texts into blocks, multiple new delta data sets (small data sets) were generated. After modifying the current delta count, the training was restarted, and the loss value continued to drop after the selected restart delta N; thus, it is shown that the incremental continuous training method provided by the present invention is efficient and effective.
[0036] It should be noted that the loss value of each delta will be recorded during the model training process. The changing trend of the loss value can be observed through TensorBoard (visualization tool), so that you can know how fast the loss value increases.
[0037] Corresponding to the aforementioned application function implementation method embodiment, the present invention also provides a large model incremental training system, equipment, medium and corresponding embodiments.
[0038] See also Figure 4 , Figure 4 The module structure diagram of the large model incremental training system is shown in FIG. The large model incremental training system includes: The data set processing module 41 is used to process the training data set in blocks according to a preset classification ratio to obtain a small data set of multiple delta units; The model training module 42 is used to: Load the small data set in delta units for model training, count and number the currently loaded small data set, and save the model weight corresponding to the current number; If the model training is interrupted, the small data set and model weight corresponding to the last number or the preset number are read when the training is restarted to restore the training scene.
[0039] In one embodiment, the model training module 42 is further used to record the training loss value corresponding to the current serial number, and the large model incremental training system further includes: Loss value calculation module, used for: After the model training is completed, all the saved training loss values are divided into multiple intervals according to the Fibonacci sequence; Select the lowest training loss value in each interval; Based on the model weights corresponding to each minimum training loss value, the model loss value of the model after training is calculated respectively; The weight verification module is used to determine the optimal model weight based on the model loss value.
[0040] In one embodiment, before loading the small data set in delta units for model training, the model training module 42 is further used to: Determine whether the value of the current epoch has reached the epoch upper limit. If so, end model training. Otherwise, determine whether the current delta unit load quantity has reached the delta upper limit. If yes, then add up the value of the current era and determine again whether the value of the current era reaches the upper limit of the era; If not, the small data set is loaded in delta units for model training, and the current number of delta units loaded is accumulated, and then it is determined again whether the current number of delta units loaded reaches the delta upper limit.
[0041] In one embodiment, before determining whether the current delta unit loading quantity reaches the delta upper limit, the model training module 42 is further used to: Determine the number of delta units to load based on the number of the last small dataset loaded.
[0042] Regarding the system in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated again here.
[0043] The present application also provides an electronic device. Figure 5 , the electronic device 5000 includes a memory 5010 and a processor 5020.
[0044] The processor 5020 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0045] The memory 5010 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices. Among them, ROM can store static data or instructions required by the processor 5020 or other modules of the computer. The permanent storage device may be a readable and writable storage device. The permanent storage device may be a non-volatile storage device that does not lose the stored instructions and data even after the computer is powered off. In some embodiments, the permanent storage device uses a large-capacity storage device (such as a magnetic or optical disk, flash memory) as a permanent storage device. In some other embodiments, the permanent storage device may be a removable storage device (such as a floppy disk, an optical drive). The system memory may be a readable and writable storage device or a volatile readable and writable storage device, such as a dynamic random access memory. The system memory may store some or all instructions and data required by the processor at runtime. In addition, the memory 5010 may include any combination of computer-readable storage media, including various types of semiconductor storage chips (such as DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and disks and / or optical disks may also be used. In some embodiments, the memory 5010 may include a readable and / or writable removable storage device, such as a laser disc (CD), a read-only digital versatile disc (such as a DVD-ROM, a double-layer DVD-ROM), a read-only Blu-ray disc, an ultra-density optical disc, a flash memory card (such as an SD card, a mini SD card, a Micro-SD card, etc.), a magnetic floppy disk, etc. The computer-readable storage medium does not include carrier waves and transient electronic signals transmitted wirelessly or wired.
[0046] The memory 5010 stores executable codes, and when the executable codes are processed by the processor 5020, the processor 5020 can execute part or all of the methods described above.
[0047] In addition, the method according to the present application may also be implemented as a computer program or a computer program product, which includes computer program code instructions for executing some or all of the steps in the above method of the present application.
[0048] Alternatively, the present application can also be implemented as a computer-readable storage medium (or non-transitory machine-readable storage medium or machine-readable storage medium) on which executable code (or computer program or computer instruction code) is stored. When the executable code (or computer program or computer instruction code) is executed by a processor of an electronic device (or server, etc.), the processor executes part or all of the steps of the above-mentioned method according to the present application.
[0049] The embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A large model incremental training method, characterized in that: include: The training data set is divided into blocks according to the preset classification ratio to obtain a small data set of multiple delta units; Load the small data set in delta units for model training, count and number the currently loaded small data set, and save the model weight corresponding to the current number; If the model training is interrupted, the small data set and model weight corresponding to the last number or the preset number are read when the training is restarted to restore the training scene.
2. The large model incremental training method according to claim 1, characterized in that: While saving the model weight corresponding to the current number, the training loss value corresponding to the current number is recorded.
3. The large model incremental training method according to claim 2, characterized in that: The method further comprises: In the weight verification phase, all saved training loss values are divided into multiple intervals according to the Fibonacci sequence; Select the lowest training loss value in each of the intervals; Based on the model weights corresponding to the minimum training loss values, respectively calculating the model loss values of the models after training is completed; According to the model loss value, the optimal model weight is determined.
4. The large model incremental training method according to claim 1, characterized in that: Before loading the small data set in delta units for model training, the method further includes: Determine whether the value of the current epoch has reached the epoch upper limit. If so, end model training. Otherwise, determine whether the current delta unit load quantity has reached the delta upper limit. If yes, then add up the value of the current era and determine again whether the value of the current era reaches the upper limit of the era; If not, the small data set is loaded in delta units for model training, and the current number of delta units loaded is accumulated, and then it is determined again whether the current number of delta units loaded reaches the delta upper limit.
5. The large model incremental training method according to claim 4, characterized in that: Before determining whether the current delta unit loading quantity reaches the delta upper limit, the method further includes: Determine the number of delta units to load based on the number of the last small dataset loaded.
6. A large model incremental training system, characterized in that: include: A data set processing module is used to process the training data set in blocks according to a preset classification ratio to obtain a small data set of multiple delta units; Model training module, used to: Load the small data set in delta units for model training, count and number the currently loaded small data set, and save the model weight corresponding to the current number; If the model training is interrupted, the small data set and model weight corresponding to the last number or the preset number are read when the training is restarted to restore the training scene.
7. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Cited By
Model training system
CN121189523A
