Model storage method and device, equipment and storage medium

By hierarchical storage of parameters and incremental parameter segmentation storage of large models, the storage challenges of large model storage and iterative fine-tuning are solved, efficient model storage and distribution is achieved, and storage and distribution pressure is reduced.

CN118796121APending Publication Date: 2024-10-18LENOVO (BEIJING) LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410866021.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

The huge size of large models leads to storage challenges during storage and iterative fine-tuning. It is difficult for existing technology to efficiently manage and optimize the storage resources of the model.

Method used

By hierarchically storing the parameter layers of the model, acquiring and storing the incremental parameters generated by fine-tuning on the basic model, and using algorithm features to split the parameter layers, efficient storage of the fine-tuned model is achieved.

Benefits of technology

It greatly saves storage resources, solves the storage pressure during large model storage and iterative fine-tuning, improves model distribution efficiency, and reduces distribution bandwidth and delay.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118796121A_ABST
    Figure CN118796121A_ABST
Patent Text Reader

Abstract

The invention discloses a model storage method and device, equipment and a storage medium, and the method comprises the steps: carrying out the hierarchical storage of N first parameter layers of a first model, and enabling the N first parameter layers to be obtained through the segmentation of a first parameter of the first model based on the algorithm features of the first model, and enabling N to be an integer greater than or equal to 1; obtaining an increment parameter generated by finely adjusting the first model; and carrying out hierarchical storage on at least one second parameter layer obtained by segmenting the increment parameter, so as to realize storage of a fine-tuning model obtained by fine-tuning the first model based on the N first parameter layers and all the second parameter layers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of electronic technology, and relate to but are not limited to a model storage method, device, equipment and storage medium. Background Art

[0002] Currently, large models are developing rapidly, and the size of the models is also increasing rapidly with the increase of model parameters. Taking a large model with 70 billion (70B) parameters as an example, the size of the model can reach 140 gigabytes (GB), while the size of a commercial large model with trillion parameters can reach several terabytes (TB). On the other hand, large models will be frequently fine-tuned and iterated according to downstream tasks, and the huge size of the model brings many challenges to the storage of the model. Summary of the invention

[0003] In view of this, embodiments of the present application provide a model storage method, apparatus, device and storage medium.

[0004] The technical solution of the embodiment of the present application is implemented as follows:

[0005] In a first aspect, an embodiment of the present application provides a model storage method, the method comprising:

[0006] The N first parameter layers of the first model are stored in layers, wherein the N first parameter layers are obtained by segmenting the first parameters of the first model based on the algorithm features of the first model, and N is an integer greater than or equal to 1;

[0007] Obtaining incremental parameters generated by fine-tuning the first model;

[0008] At least one second parameter layer obtained by dividing the incremental parameters is stored in layers, so as to implement storage of a fine-tuned model obtained by fine-tuning the first model based on N first parameter layers and all the second parameter layers.

[0009] In a second aspect, an embodiment of the present application provides a model storage device, the device comprising:

[0010] A first hierarchical storage module, used for hierarchically storing N first parameter layers of the first model, wherein the N first parameter layers are obtained by segmenting the first parameters of the first model based on the algorithm features of the first model, and N is an integer greater than or equal to 1;

[0011] An acquisition module, used for acquiring incremental parameters generated by fine-tuning the first model;

[0012] The second hierarchical storage module is used to hierarchically store at least one second parameter layer obtained by dividing the incremental parameters, so as to store the fine-tuned model obtained by fine-tuning the first model based on N first parameter layers and all the second parameter layers.

[0013] In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and the processor implements the above method when executing the program.

[0014] In a fourth aspect, an embodiment of the present application provides a storage medium storing executable instructions for implementing the above method when executed by a processor.

[0015] In a fifth aspect, a computer program product includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the steps in the above method are implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1A A schematic diagram of an implementation flow of a model storage method provided in an embodiment of the present application;

[0017] Figure 1B A schematic diagram of the structure of an LLaMA model provided in an embodiment of the present application;

[0018] Figure 1C A schematic diagram of a hierarchical structure of a first model provided in an embodiment of the present application;

[0019] Figure 2A A layered schematic diagram of a second model provided in an embodiment of the present application;

[0020] Figure 2B A schematic diagram of the first transformation block layer expansion provided in an embodiment of the present application;

[0021] Figure 2C A layered schematic diagram of a third model provided in an embodiment of the present application;

[0022] Figure 3 A schematic diagram of an implementation flow of a model sending method provided in an embodiment of the present application;

[0023] Figure 4 A schematic diagram of a large model two-dimensional hierarchical storage provided in an embodiment of the present application;

[0024] Figure 5 A schematic diagram of the structure of a model storage device provided in an embodiment of the present application;

[0025] Figure 6 A hardware entity schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the specific technical solution of the embodiments of the present application will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following embodiments are used to illustrate the present application, but are not used to limit the scope of the present application.

[0027] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0028] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0029] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0030] The present application embodiment provides a model storage method, such as Figure 1A As shown, the method includes:

[0031] Step S110: storing N first parameter layers of the first model in layers, wherein the N first parameter layers are obtained by segmenting the first parameters of the first model based on the algorithm features of the first model, and N is an integer greater than or equal to 1;

[0032] Here, the first model may be a large model (Large Model) also called a foundation model (Foundation Model), which may refer to a machine learning model with a large number of parameters and complex structures, capable of processing massive data and completing various complex tasks, such as natural language processing, computer vision, speech recognition, etc. For example, the first model may be a foundation model such as GPT4, LLaMA2, LLaMA3, etc., among which GPT-4 is a language model released by OpenAI for the chatbot ChatGPT, and LLaMA2 and LLaMA3 are large language models released by Meta AI.

[0033] Different parameter layers of the first model may be divided based on different algorithm features, that is, each parameter layer divided based on the algorithm features may correspond to a different function or algorithm.

[0034] In some embodiments, the first parameters of the first model may also be divided into different first parameter layers based on the model structure of the first model and a commonly used fine-tuning granularity.

[0035] For example, Figure 1B A schematic diagram of the structure of an LLaMA model provided in an embodiment of the present application is shown in FIG. Figure 1B As shown, the structural diagram includes a normalization layer (Softmax) 11, a linearization layer (Linear) 12, a root mean square normalization layer (RMSNorm) 13, a thirty-second transform block layer (Transformer Block) 14, an omitted transform block layer 15 (including the second transform block layer to the thirty-first transform block layer), a first transform block layer (Transformer Block) 16 and an input embedding layer (InputEmbedding) 17. In the implementation process, the above layers can be determined based on different algorithm features, that is, the model structure.

[0036] Figure 1C A schematic diagram of a hierarchical structure of a first model provided in an embodiment of the present application, such as Figure 1C As shown, the hierarchical structure diagram includes layer 1, layer 2, layer 3...layer N.

[0037] In the implementation process, the first model is Figure 1B In the case of the LLaMA model shown, Figure 1B Each of the normalization layer (Softmax) 11, the linearization layer (Linear) 12, the root mean square normalization layer (RMSNorm) 13, the thirty-second transform block layer (Transformer Block) 14, the omitted transform block layer 15 (including the second transform block layer to the thirty-first transform block layer), the first transform block layer (Transformer Block) 16 and the input embedding layer (Input Embedding) 17 is as shown. Figure 1C Each level in the hierarchical structure shown is stored accordingly.

[0038] In some embodiments, the full amount can be fine-tuned such as Figure 1C The first model is shown, and the N first parameter layers (layer 1, layer 2, layer 3 ... layer N) of the first model are stored in layers.

[0039] Step S120, obtaining incremental parameters for fine-tuning the generation of the first model;

[0040] Here, fine-tuning is to adjust the parameters of the first model by using the model part fine-tuning technology on the basis of the first model, and the incremental parameters are generated on the basis of the first parameters.

[0041] During implementation, the incremental parameters may be obtained by fine-tuning at least one of the N first parameter layers; or by adding a parameter layer on the basis of the N first parameter layers; or by fine-tuning at least one first parameter layer and adding a parameter layer at the same time.

[0042] Basic large models such as GPT4, LLaMA2, and LLaMA3 require a lot of computing power and time to train. Therefore, once the basic large model itself is determined, it will not be iterated frequently.

[0043] Common large model adaptation downstream tasks can use a small amount of professional field data to fine-tune the basic large model. Considering the amount of professional field data and the amount of computation, the model partial fine-tuning technology can be used, and the adjusted model parameters are less than 5% of the total parameters. For example, Low-Rank Adaptation (LoRA) is obtained by adjusting each first parameter layer, so that the adjusted model parameters can be less than 1% of the total parameters. Among them, LoRA is a technology for fine-tuning deep learning models. A small number of trainable parameter models are added to the model, while the original model parameters remain frozen. LoRA is one of the most widely used and parameter-efficient fine-tuning technologies for training custom LLMs.

[0044] Step S130: hierarchically store at least one second parameter layer obtained by dividing the incremental parameters, so as to store a fine-tuned model obtained by fine-tuning the first model based on N first parameter layers and all the second parameter layers.

[0045] Here, since the fine-tuning model is obtained by fine-tuning the parameters based on the first model, and the parameters of the first model have been stored in layers, in the implementation process, only the incremental parameters generated by the fine-tuning are stored, that is, the storage of the fine-tuning model can be realized based on N first parameter layers and all second parameter layers.

[0046] In some embodiments, it can be combined with container image storage technology to manage model storage using the corresponding ecosystem of the image repository.

[0047] In the embodiment of the present application, the N first parameter layers of the first model are first stored in layers, wherein the N first parameter layers are obtained by dividing the first parameter of the first model based on the algorithmic features of the first model; then the incremental parameters generated by fine-tuning the first model are obtained; finally, at least one second parameter layer obtained by dividing the incremental parameters is stored in layers, so as to realize the storage of the fine-tuned model obtained by fine-tuning the first model based on the N first parameter layers and all the second parameter layers. In this way, the hierarchical storage of the first model can be realized, and on the basis of the hierarchical storage of the first model, it is only necessary to store the incremental parameters that have been divided, that is, the storage of the fine-tuned model obtained by fine-tuning the first model can be completed, thereby greatly saving storage resources.

[0048] In some embodiments, the above step S120 "obtaining incremental parameters for fine-tuning the generation of the first model" can be implemented by the following process:

[0049] Using a first fine-tuning method to adjust the first model, obtaining a second model including M parameter layers, wherein the second model increases a first incremental parameter compared to the first model, and M is an integer greater than N;

[0050] Here, the first fine-tuning method may be to add a parameter layer fine-tuning on the basis of the first model.

[0051] For example, supervised fine-tuning (SFT) fine-tuning can be performed based on the first model (Model#1) to obtain a second model (Model#2) that adds a first incremental parameter in the depth direction compared to the first model.

[0052] Correspondingly, the above step S130 "storing the at least one second parameter layer obtained by dividing the incremental parameter in layers" can be implemented by the following process:

[0053] The algorithm feature based on the first incremental parameter is segmented, and the obtained at least one second parameter layer is stored in layers, and the M parameter layers include N first parameter layers and at least one second parameter layer.

[0054] During implementation, the first incremental parameter may be divided into different second parameter layers based on the algorithmic features of the first incremental parameter, just like dividing the first model, and all the second parameter layers may be stored in layers.

[0055] Figure 2A A layered schematic diagram of a second model provided in an embodiment of the present application, such as Figure 2AAs shown, the layered schematic diagram includes layer 1, layer 2, layer 3 ... layer N and newly added layers N+1 to layer M of the first model, wherein the newly added layers N+1 to layer M are obtained by dividing the first incremental parameter.

[0056] For example, supervised fine-tuning (SFT) fine-tuning can be performed based on the first model (Model#1), and the output appended model structure can be stored in layers.

[0057] In the embodiment of the present application, the first model is first adjusted using the first fine-tuning method to obtain a second model including M parameter layers; then the algorithm feature based on the first incremental parameter is segmented, and the at least one second parameter layer obtained is stored in layers. In this way, when the first incremental parameter is added in the depth direction by fine-tuning the first model, the storage of the second parameter layer can be completed by segmenting the first incremental parameter.

[0058] In some embodiments, the metadata of the first parameter layer and the second parameter layer include: parameter layer name, input layer name, output layer name and parameter node information, wherein:

[0059] The parameter layer name is an index identifying the connection relationship of the target parameter layer;

[0060] Here, the parameter layer name (Name) is the layer (Layer) name, which is used for the vertical (depth direction) layer connection relationship index.

[0061] The input layer name is an index of the input parameter layer that identifies the target parameter layer;

[0062] The input layer (Top) name is a list of layer names (Layer Name) of the Layer input. There may be multiple inputs.

[0063] The output layer name is an index of an output parameter layer that identifies the target parameter layer.

[0064] The output layer (Bottom) name is a list of layer names (Layer Name) output by Layer. There may be multiple outputs.

[0065] Parameter node information can be used to record the internal structure of the Layer, such as node description (such as operators, parameters, etc.), node internal connection structure, and node operations, where node operations include create, update, and delete operations.

[0066] During implementation, a Layer may include multiple nodes. Figure 2BA schematic diagram of the first transformation block layer expansion provided in an embodiment of the present application is shown in FIG. Figure 2B As shown, the schematic diagram includes an expanded schematic diagram of the first transformation block layer 16, wherein:

[0067] The first transformation block layer 16 includes two algorithms, feedforward and attention. During implementation, the first transformation block layer can be divided into feedforward nodes and attention nodes based on different algorithm characteristics.

[0068] In the embodiment of the present application, the metadata of the first parameter layer and the second parameter layer include: parameter layer name, input layer name, output layer name and parameter node information, wherein the parameter layer name is an index identifying the connection relationship of the target parameter layer; the input layer name is an index identifying the input parameter layer of the target parameter layer; the output layer name is an index identifying the output parameter layer of the target parameter layer. In this way, the data storage format of the hierarchical storage of the model can be defined based on the above metadata, and the splicing of the first parameter layer and the second parameter layer can be realized on the basis of the first model that has been loaded, so as to further realize the loading of the second model.

[0069] In some embodiments, the above step S120 "obtaining incremental parameters for fine-tuning the generation of the first model" can be implemented by the following process:

[0070] The first model is adjusted by using a second fine-tuning method to obtain a third model including N parameter layers, wherein the third model increases the i-th second incremental parameter corresponding to the i-th first parameter layer of the first model, wherein i is an integer greater than or equal to 1 and less than or equal to N;

[0071] Here, the second fine-tuning method may be to fine-tune the i-th second incremental parameter corresponding to the i-th first parameter layer on the basis of the first model.

[0072] For example, LoRA fine-tuning can be performed based on the first model (Model#1), and the third model (Model#3) can be obtained by adding a second incremental parameter in the horizontal axis direction compared to the first model.

[0073] Figure 2C A layered schematic diagram of a third model provided in an embodiment of the present application, such as Figure 2C As shown, the layered schematic diagram includes layer 1, layer 2, layer 3 ... layer N of the first model and adjustment patches generated for each layer, including patch 1, patch 2, patch 3 ... patch N.

[0074] Correspondingly, the above step S130 "storing the at least one second parameter layer obtained by dividing the incremental parameter in layers" can be implemented by the following process:

[0075] The i second incremental parameters are stored in layers as i second parameter layers.

[0076] For example, Model#3 performs LoRA fine-tuning on Model#1. Since all the hierarchical parameters of Model#1 have been stored, the incremental parameters generated by the trained LoRA can be stored in the form of a new hierarchical storage patch.

[0077] In the embodiment of the present application, the first model is first adjusted using the second fine-tuning method to obtain a third model including N parameter layers, wherein the third model increases the i-th second incremental parameter corresponding to the i-th first parameter layer of the first model; and then the i-th second incremental parameters are stored in layers as i-th second parameter layers. In this way, when the first model is fine-tuned to increase the i-th second incremental parameters in the horizontal direction, the i-th second incremental parameters are stored in layers as i-th second parameter layers to complete the storage of the second parameter layers.

[0078] In some embodiments, the metadata of the first parameter layer and the second parameter include: parameter layer name, revision number, input layer name, output layer name and parameter node information, wherein,

[0079] The parameter layer name is an index identifying the connection relationship of the target parameter layer;

[0080] Here, the parameter layer name (Name) is the layer (Layer) name, and the second parameter layer and the first parameter layer of the same layer can be identified as the same layer name.

[0081] The revision number is an index used to fuse the i-th second parameter layer with the i-th first parameter layer;

[0082] Revision numbers can be used to record revision indexes when horizontal layers are merged. Layered data with the same name can achieve horizontal dependencies.

[0083] The input layer name is an index of the input parameter layer that identifies the target parameter layer;

[0084] The output layer name is an index of the output parameter layer identifying the target parameter layer;

[0085] The parameter node information is used to record the node information included in the parameter layer, so as to fuse the i-th second parameter layer and the i-th first parameter layer based on the node information.

[0086] The following is an example of the data storage structure of a parameter layer (Layer). The storage of the layer includes metadata (Manifests) and parameters (Data):

[0087] Manifests:

[0088] Name:trans_block_layer2

[0089] Top:[trans block layer1]

[0090] Bottom:[trans_block_layer3]

[0091] Revision:0

[0092] Nodes:RMSNorm1:{

[0093] #Node description (such as operator type, parameters, etc.)

[0094] Meta:{"key1":"value1", ......

[0096] }

[0097] #Node connection structure, Type is create, required

[0098] Topology:

[0099] Top: [trans_block layer1],

[0100] Bottom: [linear 1]

[0101] }

[0102] Data:

[0103] ."RMSNorm1: {

[0104] #SHA can quickly verify whether the data has changed

[0105] SHA: 452a.

[0106] data: [0.34, 0.56, .....]

[0107] }

[0108] From the above data storage structure instance, it can be seen that the metadata in the data storage structure instance is used to describe the parameter layer identified as trans_block_layer2, the input parameter layer of the parameter layer is trans block layer1, the output parameter layer is trans_block_layer3, the revision number is 0, and the node information of the root mean square normalization (RMSNorm) 1 includes the node description and the node connection structure. Here, the data storage structure instance also includes the parameter (Data) information corresponding to the parameter layer.

[0109] In the embodiment of the present application, the metadata of the first parameter layer and the second parameter include: parameter layer name, revision number, input layer name, output layer name and parameter node information, wherein the parameter layer name is an index identifying the connection relationship of the target parameter layer; the revision number is an index used to fuse the i-th second parameter layer with the i-th first parameter layer; the input layer name is an index identifying the input parameter layer of the target parameter layer; the output layer name is an index identifying the output parameter layer of the target parameter layer; the parameter node information is used to record the node information included in the parameter layer, so as to fuse the i-th second parameter layer with the i-th first parameter layer based on the node information. In this way, the data storage format of the hierarchical storage of the model can be defined based on the above metadata, so as to realize the splicing of the first parameter layer and the second parameter layer on the basis of the loaded first model, so as to further realize the loading of the third model.

[0110] In some embodiments, the node information includes node description, node connection structure and node operation, wherein:

[0111] The node description is used to record at least the operator type and parameters of the node;

[0112] As described in the above data storage structure example, the node may at least record the operator type, parameters, etc.

[0113] The node connection structure is used to record the connection relationship of the newly added nodes;

[0114] The node description in the above data storage structure example, including the input (Top) layer and the output (Bottom) layer, can record the connection relationship of the newly added nodes to achieve the fusion of the i-th second parameter layer and the i-th first parameter layer.

[0115] The node operation is used to record at least one of the following node operations: creation, update and deletion.

[0116] Here, Create is used to represent the creation of a new Node; Patch is used to represent the update of the current Node parameters, while the Node connection structure remains unchanged; Delete is used to represent the deletion of the current Node.

[0117] In the embodiment of the present application, the node information includes a node description, a node connection structure, and a node operation, wherein the node description is used to record at least the operator type and parameters of the node; the node connection structure is used to record the connection relationship of the newly added node; and the node operation is used to record at least one of the following node operations: create, update, and delete. In this way, the loading of the third model can be realized based on the node information description in the metadata.

[0118] In some embodiments, the present application also provides a method for sending a model, such as Figure 3 As shown, the method comprises the following steps:

[0119] Step S310: When it is determined that the target server is to deploy the first model, N first parameter layers are sent to the target server;

[0120] Here, the model storage method can be applied to a model warehouse server, and the model warehouse server can provide models corresponding to the required deployment for different target servers.

[0121] During implementation, when the target server needs to deploy the first model, it can obtain N first parameter layers from the model warehouse server. In this way, the target server can load the first model based on the metadata recorded in each first parameter layer.

[0122] In some embodiments, it can be combined with distributed distribution technology, such as peer-to-peer (P2P) technology to implement the first parameter layer distribution to the target server, thereby further reducing the pressure of the single-point distribution model.

[0123] In some embodiments, it can be combined with container image storage technology to utilize the image distribution ecosystem to distribute the first parameter layer.

[0124] Step S320: When it is determined that the target server is to be upgraded to the fine-tuned first model, all the second parameter layers are sent to the target server.

[0125] In the implementation process, when the target server is to be upgraded to the fine-tuned first model, all second parameter layers generated by the fine-tuning can be obtained. In this way, since the target server has stored N first parameters, the fine-tuning model obtained by fine-tuning the first model can be loaded based on all second parameters.

[0126] In the embodiment of the present application, when it is determined that the target server is to deploy the first model, N first parameter layers are sent to the target server; when it is determined that the target server is to be upgraded to the fine-tuned first model, all second parameter layers are sent to the target server. In this way, when the target server needs to deploy a fine-tuned model, only the incremental part corresponding to the fine-tuned model can be distributed through shard distribution, thereby solving the distribution bandwidth and distribution delay problems.

[0127] Figure 4 A schematic diagram of a large model two-dimensional hierarchical storage provided in an embodiment of the present application, such as Figure 4 As shown, the schematic diagram includes: a first model (Model#1), a second model (Model#2) and a third model (Model#3), wherein:

[0128] The basic model Model#1 can be segmented and stored according to the model structure and the commonly used fine-tuning granularity. For example, for the LLama2 model, the Transformer Block unit can be used as the smallest granularity for segmentation. Each slice layer, such as Figure 4 The layers 1, 2, 3, ..., N shown are stored independently through a defined data structure.

[0129] When Model#2 is loaded on the target server, the hierarchical parameters of Model#1 can be reused. Supervised Fine-Tun-ing (SFT) fine-tuning is performed based on Model#1, and the output appended model structure is stored hierarchically.

[0130] Model#3 fine-tunes Model#2 with LoRA. When Model#3 is loaded on the target server, all layered parameters of Model#2 are loaded first, and the trained LoRA parameters are superimposed on the existing layers of Model#2 in the form of new layered storage patches.

[0131] In the implementation process, according to the above model storage example, Model#1's layer 1, layer 2, layer 3... layer N can be shared between different models (Model#1, Model#2 and Model#3); Model#2 layer 1, layer 2, layer 3... layer M can be shared between different models (Model#2 and Model#3). When the model is loaded, the order of the layer loading data is indexed by the parameter layer name Name on the vertical axis and by the revision parameter Revision on the horizontal axis.

[0132] The embodiments of the present application also provide an example of the above data storage structure.

[0133] Based on the above description of the Layer data storage structure, the large model can be divided into multiple layers (vertical division); each time the large model is fine-tuned, the incremental part is also described by Layer (horizontal division, revision control by Revision); thus realizing the division and independent distribution capabilities of the model itself and the model increment. When loading the model, all the layers that the model depends on can be obtained and loaded, and the layers are connected / fused in memory according to the Layer Name (Top / Bottom) and Revision to achieve full loading of the model.

[0134] Since the parameter changes after model fine-tuning are very small, the layers with Revision greater than or equal to 1 are much smaller in number and volume than the layers of the original model (Revision = 0), which can greatly improve the model distribution efficiency when updating and iterating large models.

[0135] In the embodiment of the present application, large model data is stored in layers, and a multi-level incremental storage logic is designed to divide model parameters in both depth and lateral directions, and perform 2D layered storage of the model. On the one hand, different layers of the model can be stored in slices; on the other hand, the model increments brought about by fine-tuning can also be stored in layers. The necessary data storage format for model layered storage is defined.

[0136] The beneficial technical effects are as follows:

[0137] The model can be distributed in shards to distribute only the incremental part, thus solving the distribution bandwidth and distribution delay problems. It can be combined with existing distributed distribution technologies, such as P2P technology, to further reduce the pressure of single-point distribution models. It can be combined with current container image storage technology to manage the model using the corresponding ecology of image warehouse and image distribution. Only by modifying the logic of model storage and loading, it can be compatible with current general training frameworks (Pytorch, Tensorflow, etc.).

[0138] Based on the foregoing embodiments, an embodiment of the present application provides a model storage device, which includes the modules included and can be implemented by a processor in an electronic device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.

[0139] Figure 5A schematic diagram of the structure of the model storage device provided in the embodiment of the present application is shown in FIG. Figure 5 As shown, the device 500 includes:

[0140] A first hierarchical storage module 510 is used to hierarchically store N first parameter layers of the first model, wherein the N first parameter layers are obtained by segmenting the first parameters of the first model based on the algorithm features of the first model, and N is an integer greater than or equal to 1;

[0141] An acquisition module 520 is used to acquire incremental parameters generated by fine-tuning the first model;

[0142] The second hierarchical storage module 530 is used to hierarchically store at least one second parameter layer obtained by dividing the incremental parameters, so as to store the fine-tuned model obtained by fine-tuning the first model based on N first parameter layers and all the second parameter layers.

[0143] In some embodiments, the acquisition module 520 is also used to adjust the first model using a first fine-tuning method to obtain a second model including M parameter layers, wherein the second model adds a first incremental parameter compared to the first model, and M is an integer greater than N; correspondingly, the second hierarchical storage module 530 is also used to divide the algorithm features based on the first incremental parameter, and the obtained at least one second parameter layer is stored in a hierarchical manner, and the M parameter layers include N first parameter layers and at least one second parameter layer.

[0144] In some embodiments, the metadata of the first parameter layer and the second parameter layer include: parameter layer name, input layer name, output layer name and parameter node information, wherein the parameter layer name is an index identifying the connection relationship of the target parameter layer; the input layer name is an index identifying the input parameter layer of the target parameter layer; and the output layer name is an index identifying the output parameter layer of the target parameter layer.

[0145] In some embodiments, the acquisition module 520 is also used to adjust the first model using a second fine-tuning method to obtain a third model including N parameter layers, wherein the third model increases the i-th second incremental parameter corresponding to the i-th first parameter layer of the first model, wherein i is an integer greater than or equal to 1 and less than or equal to N; correspondingly, the second hierarchical storage module 530 is also used to hierarchically store i second incremental parameters as i second parameter layers.

[0146] In some embodiments, the metadata of the first parameter layer and the second parameter include: a parameter layer name, a revision number, an input layer name, an output layer name and parameter node information, wherein the parameter layer name is an index identifying the connection relationship of the target parameter layer; the revision number is an index used to fuse the i-th second parameter layer with the i-th first parameter layer; the input layer name is an index identifying the input parameter layer of the target parameter layer; the output layer name is an index identifying the output parameter layer of the target parameter layer; the parameter node information is used to record the node information included in the parameter layer, so as to fuse the i-th second parameter layer with the i-th first parameter layer based on the node information.

[0147] In some embodiments, the node information includes a node description, a node connection structure, and a node operation, wherein the node description is used to record at least the operator type and parameters of the node; the node connection structure is used to record the connection relationship of the newly added node; and the node operation is used to record node operations including at least one of the following: creation, update, and deletion.

[0148] In some embodiments, the device also includes a first sending module and a second sending module, wherein the first sending module is used to send N first parameter layers to the target server when it is determined that the target server is to be deployed with the first model; and the second sending module is used to send all the second parameter layers to the target server when it is determined that the target server is to be upgraded to the fine-tuned first model.

[0149] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.

[0150] It should be noted that in the embodiment of the present application, if the above method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable an electronic device (which can be a mobile phone, a tablet computer, a laptop computer, a desktop computer, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.

[0151] Correspondingly, an embodiment of the present application provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the model storage method provided in the above embodiment are implemented.

[0152] Correspondingly, an embodiment of the present application provides an electronic device, Figure 6 A hardware entity diagram of an electronic device provided in an embodiment of the present application, such as Figure 6 As shown, the hardware entity of the device 600 includes: a memory 601 and a processor 602, wherein the memory 601 stores a computer program that can be run on the processor 602, and the processor 602 implements the steps in the model storage method provided in the above embodiment when executing the program.

[0153] The memory 601 is configured to store instructions and applications executable by the processor 602, and can also cache data to be processed or processed by the processor 602 and various modules in the electronic device 600 (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).

[0154] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0155] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned sequence numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.

[0156] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0157] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0158] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0159] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0160] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.

[0161] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly reflected in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable an electronic device (which can be a mobile phone, a tablet computer, a laptop computer, a desktop computer, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0162] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.

[0163] The features disclosed in several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.

[0164] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.

[0165] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A model storage method, the method include: The N first parameter layers of the first model are stored in layers, wherein the N first parameter layers are obtained by segmenting the first parameters of the first model based on the algorithm features of the first model, and N is an integer greater than or equal to 1; Obtaining incremental parameters generated by fine-tuning the first model; At least one second parameter layer obtained by dividing the incremental parameters is stored in layers, so as to implement storage of a fine-tuned model obtained by fine-tuning the first model based on N first parameter layers and all the second parameter layers.

2. The method according to claim 1, wherein obtaining and fine-tuning the incremental parameters generated by the first model, include: Using a first fine-tuning method to adjust the first model, obtaining a second model including M parameter layers, wherein the second model increases a first incremental parameter compared to the first model, and M is an integer greater than N; Correspondingly, storing the at least one second parameter layer obtained by dividing the incremental parameter in layers includes: The algorithm feature based on the first incremental parameter is segmented, and the obtained at least one second parameter layer is stored in layers, and the M parameter layers include N first parameter layers and at least one second parameter layer.

3. The method according to claim 2, wherein the metadata of the first parameter layer and the second parameter layer include: Parameter layer name, input layer name, output layer name and parameter node information, where: The parameter layer name is an index identifying the connection relationship of the target parameter layer; The input layer name is an index of the input parameter layer that identifies the target parameter layer; The output layer name is an index of an output parameter layer that identifies the target parameter layer.

4. The method according to claim 1, wherein obtaining and fine-tuning the incremental parameters generated by the first model, include: The first model is adjusted by using a second fine-tuning method to obtain a third model including N parameter layers, wherein the third model increases the i-th second incremental parameter corresponding to the i-th first parameter layer of the first model, wherein i is an integer greater than or equal to 1 and less than or equal to N; Correspondingly, storing the at least one second parameter layer obtained by dividing the incremental parameter in layers includes: The i second incremental parameters are stored in layers as i second parameter layers.

5. The method of claim 4, wherein the metadata of the first parameter layer and the second parameter include: Parameter layer name, revision number, input layer name, output layer name, and parameter node information, where: The parameter layer name is an index identifying the connection relationship of the target parameter layer; The revision number is an index used to fuse the i-th second parameter layer with the i-th first parameter layer; The input layer name is an index of the input parameter layer that identifies the target parameter layer; The output layer name is an index of the output parameter layer identifying the target parameter layer; The parameter node information is used to record the node information included in the parameter layer, so as to fuse the i-th second parameter layer and the i-th first parameter layer based on the node information.

6. The method according to claim 5, wherein the node information includes node description, node connection structure and node operation, in, The node description is used to record at least the operator type and parameters of the node; The node connection structure is used to record the connection relationship of the newly added nodes; The node operation is used to record at least one of the following node operations: creation, update and deletion.

7. The method according to any one of claims 1 to 6, further comprising: include: When it is determined that the target server is to deploy the first model, sending N first parameter layers to the target server; When it is determined that the target server is to be upgraded to the fine-tuned first model, all the second parameter layers are sent to the target server.

8. A model storage device, the device include: A first hierarchical storage module, used for hierarchically storing N first parameter layers of the first model, wherein the N first parameter layers are obtained by segmenting the first parameters of the first model based on the algorithm features of the first model, and N is an integer greater than or equal to 1; An acquisition module, used for acquiring incremental parameters generated by fine-tuning the first model; The second hierarchical storage module is used to hierarchically store at least one second parameter layer obtained by dividing the incremental parameters, so as to store the fine-tuned model obtained by fine-tuning the first model based on N first parameter layers and all the second parameter layers.

9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor implements the steps of the method according to any one of claims 1 to 7 when executing the program.

10. A storage medium storing executable instructions for causing a processor to execute the instructions to implement the steps of the method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Large model hierarchical storage method and device oriented to Pleashippability intelligent computing center

    CN120216462A