Model file distribution methods, servers, systems, and related equipment
By obtaining target weight information from a shared weight file, the problem of increased storage costs caused by the diversity of machine learning models is solved, and storage space optimization is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE INTERNET CO LTD
- Filing Date
- 2024-12-20
- Publication Date
- 2026-04-21
AI Technical Summary
The diversity of machine learning models leads to increased server storage costs and consumes a large amount of storage space.
By obtaining target weight information that matches the specific information of the target model from the shared weight file, the same weight information is avoided from being stored repeatedly, thus reducing the storage space occupied.
This reduced storage costs and decreased the storage space required by the server.
Smart Images

Figure CN119728672B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data application and processing technology, and in particular to a method for distributing model files, a server, a system, and related equipment. Background Technology
[0002] With the rapid development of machine learning technology, various machine learning frameworks such as TensorFlow, PyTorch, and Caffe are widely used in model development. Each of these frameworks has unique characteristics and advantages, capable of meeting different scenarios and needs. Therefore, developers can choose the appropriate framework for model development based on specific requirements. This also results in the possibility of multiple model versions using different frameworks for the same inference function, to adapt to the needs of different edge devices.
[0003] To meet the needs of edge devices, servers need to store machine learning models for various frameworks and distribute them when edge devices need to download or upgrade. This means that servers need to store a large number of model files for machine learning models with the same functionality but different frameworks. Storing these model files on the server consumes a significant amount of space resources, increasing server storage costs. Summary of the Invention
[0004] This application provides a method, server, system, and related equipment for distributing model files, in order to at least solve the problem that existing machine learning model files occupy a large amount of storage space and increase storage costs.
[0005] To solve the above-mentioned technical problems, this application is implemented as follows:
[0006] In a first aspect, embodiments of this application provide a method for distributing model files, comprising: responding to a model file download request sent by an edge device, obtaining target model-specific information corresponding to the model file download request; wherein, the target model-specific information is the information of a machine learning model corresponding to a framework used by the edge device after removing weight information; obtaining target weight information matching the target model-specific information from a preset shared weight file, the shared weight file including weight information of machine learning models corresponding to multiple frameworks; determining the model file of the machine learning model based on the target model-specific information and the target weight information; and sending the model file to the edge device.
[0007] Secondly, embodiments of this application provide a server, including: an information acquisition module, configured to acquire target model-specific information corresponding to the model file download request in response to a model file download request sent by an edge device; wherein the target model-specific information is the information of a machine learning model corresponding to a framework used by the edge device after removing weight information; a weight acquisition module, configured to acquire target weight information matching the target model-specific information from a preset shared weight file, the shared weight file including weight information of machine learning models corresponding to multiple frameworks; a model determination module, configured to determine the model file of the machine learning model based on the target model-specific information and the target weight information; and a model sending module, configured to send the model file to the edge device.
[0008] Thirdly, embodiments of this application provide a model file distribution system, including a server as described in the second aspect above, and edge nodes that communicate and connect with the server.
[0009] Fourthly, embodiments of this application provide an electronic device including a processor and a memory, wherein the memory stores a program or instructions executable on the processor, and the program or instructions, when executed by the processor, implement the steps of the method described in the first aspect above.
[0010] Fifthly, embodiments of this application provide a computer-readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect above.
[0011] In a sixth aspect, embodiments of this application provide a computer program product, the computer program product including a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions, which, when executed by a computer, cause the computer to perform the steps of the method described in the first aspect above.
[0012] In this embodiment, in response to a model file download request sent by an edge device, target model-specific information corresponding to the download request is obtained; target weight information matching the target model-specific information is obtained from a preset shared weight file, which includes weight information for machine learning models corresponding to multiple frameworks; the model file of the machine learning model is determined based on the target model-specific information and the target weight information; and the model file is sent to the edge device. Thus, by obtaining target weight information matching the target model-specific information from a shared weight file, instead of obtaining weight information separately from the model files of the machine learning models, the same shared weight file can be accessed and used regardless of which framework the machine learning model requested for download by the edge device belongs to. This avoids repeatedly storing the same weight information, reduces storage space usage, and lowers storage costs.
[0013] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0014] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0015] Figure 1 A flowchart illustrating the model file distribution method provided in an embodiment of this application is shown.
[0016] Figure 2 An example diagram of the weight mapping provided in an embodiment of this application is shown;
[0017] Figure 3 An example diagram of quantization interval recombination provided in an embodiment of this application is shown;
[0018] Figure 4 A schematic diagram of the server structure provided in an embodiment of this application is shown;
[0019] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0020] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0021] Machine learning frameworks such as TensorFlow, PyTorch, and Caffe are widely used in model development. Each framework has unique characteristics and advantages, meeting diverse scenarios and needs. Taking Microsoft's ONNX (Open Neural Network Exchange) Runtime framework, the academically common PyTorch framework, and the NCNN framework as examples, the ONNX Runtime framework requires model files in ONNX format, the PyTorch framework uses pth format model files, and the NCNN framework requires model files in other formats corresponding to its own. This means that the server needs to simultaneously store ONNX format model files, PyTorch pth files, and NCNN format bin and param files, etc. This diversity of model files leads to the server needing to store a large number of machine learning models with the same functionality from different frameworks, consuming significant space resources and increasing server storage costs.
[0022] To address the problems existing in the storage and distribution of model files for machine learning models mentioned above, this application provides a method for distributing model files. This method obtains target weight information that matches specific information of the target model from a shared weight file, instead of obtaining weight information from the model files of the machine learning models separately. Regardless of which framework the machine learning model requested by the edge device belongs to, it can access and use the same shared weight file, thereby avoiding the need to repeatedly store the same weight information in machine learning models corresponding to multiple frameworks, reducing storage space occupation, and lowering storage costs.
[0023] Figure 1 The diagram illustrates a flowchart of a method for distributing model files according to an embodiment of this application. The executing entity of this method can be a server, which can be a backend server for a specific business function, or a backend server for a platform or application (e.g., a cloud service platform, an edge device management system, etc.). As shown in the figure, method 100 may include the following steps:
[0024] Step 101: In response to the model file download request sent by the edge device, obtain the target model-specific information corresponding to the model file download request.
[0025] The target model-specific information refers to the information of the machine learning model corresponding to the framework used by the edge device after removing the weight information; the edge device is a physical device close to the server or user in the edge computing architecture. The edge device can be a device such as a personal computer, or a mobile terminal device such as a mobile phone or tablet computer. The edge device can be a terminal device used by the user.
[0026] In practice, the edge device sends a request to the server to download the model file of a machine learning model, such as an image classification model, an audio recognition model, or a fault detection model. The edge device uses a specific machine learning framework, such as PyTorch. The server responds to the download request by parsing it, obtaining the framework information used by the edge device, and then retrieving the target model-specific information corresponding to the download request. This target model-specific information is the model structure information under the framework used by the edge device, after removing weight information. For example, the network structure of an image classification model, such as the layer information of a convolutional neural network, but excluding the trained weight data. The target model-specific information is the architecture of the machine learning model, which may include the number of layers, the input and output dimensions of each layer, and the type of activation function.
[0027] Step 102: Obtain target weight information that matches the specific information of the target model from a preset shared weight file. The shared weight file includes weight information of machine learning models corresponding to multiple frameworks.
[0028] In practice, the server retrieves target weight information that matches the target model architecture from shared weight file A. This shared weight file A contains weight information for pre-trained machine learning models corresponding to multiple frameworks, such as TensorFlow and PyTorch.
[0029] Step 103: Determine the model file of the machine learning model based on the target model-specific information and the target weight information.
[0030] In practice, the server combines the target model-specific information obtained with the target weight information in the shared weight file to construct a complete model file for the machine learning model.
[0031] Step 104: Send the model file to the edge device.
[0032] In practice, the server transmits the constructed model file to the edge device via the network. After receiving the model file, the edge device can directly use it to execute corresponding tasks.
[0033] In this way, each edge device can receive a customized model based on the framework it uses, while sharing the same weight information. The server connected to the edge device only needs to store one copy of the shared weight file, and can then distribute the corresponding model file based on any machine learning framework deployed on the edge device, thus significantly reducing storage space usage.
[0034] In one possible implementation, step 101 above, in response to a model file download request sent by the edge device, obtains target model-specific information corresponding to the model file download request, including:
[0035] Obtain a model file download request sent by an edge device, the model file download request including frame information of the frame used by the edge device; obtain model-specific information corresponding to the frame indicated by the frame information from a preset model file, and determine that the model-specific information corresponding to the frame indicated by the frame information is the target model-specific information corresponding to the model file download request, the model file including model-specific information corresponding to multiple frames.
[0036] In this embodiment, the edge device sends a model file download request to the server. This request may include framework information of the framework used by the edge device, such as the framework type being PyTorch. Upon receiving the download request, the server parses the framework information and retrieves target model-specific information corresponding to the framework used by the edge device from a preset model file B. This target model-specific information includes the model structure and other information, such as the number of convolutional layers and pooling layers.
[0037] In one possible implementation, step 103 above, determining the model file of the machine learning model based on the target model-specific information and the target weight information, includes:
[0038] Obtain the weight position information corresponding to the target model specific information; based on the weight position information, insert the target weight information into the target model specific information to obtain the model file of the machine learning model.
[0039] In this embodiment, the server can obtain the weight position file C corresponding to the specific information of the target model, obtain the weight position information, and insert the corresponding target weight information into the specific information of the target model according to the weight position information to obtain the model file of the machine learning model.
[0040] In one possible implementation, step 101 above, before obtaining the target model-specific information corresponding to the model file download request, further includes:
[0041] Step 1011: Obtain the machine learning models corresponding to multiple frameworks.
[0042] In step 1011 above, obtaining machine learning models corresponding to multiple frameworks includes:
[0043] Obtain the machine learning model corresponding to the target framework; by performing model transformation on the machine learning model corresponding to the target framework, obtain machine learning models corresponding to multiple frameworks.
[0044] In practice, a machine learning model from a specific target framework can be converted into machine learning models for various other frameworks. Specifically, conversion tools provided by the machine learning framework can be used to perform this conversion. Model conversion ensures that the same model can run on different frameworks, thus laying the foundation for subsequent weight sharing.
[0045] Step 1012: Store the weight information of the machine learning models corresponding to the multiple frameworks into a shared weight file.
[0046] In practice, weight information is extracted from the machine learning models corresponding to the multiple transformed frameworks and saved as a single shared weight file A. This shared weight file A contains weight information shared by all frameworks.
[0047] Here, since weight information is an important component of model parameters, it typically occupies a large portion of the model file's storage space. This embodiment of the application extracts and stores the weight information separately, enabling weight sharing between models from different frameworks.
[0048] Step 1013: Remove the weight information from the machine learning models corresponding to the multiple frameworks to obtain model-specific information corresponding to the multiple frameworks.
[0049] In practice, weight information is removed from all machine learning models corresponding to various frameworks, generating a model file B lacking weight information. This model file B includes model-specific information for multiple frameworks. Simultaneously, the position of the weight information within the machine learning model is recorded to ensure accurate insertion of the weight information into the correct positions within the model-specific information when subsequently distributing the model file.
[0050] Storing a large number of machine learning models with the same functionality but different frameworks consumes a significant amount of server space resources. Server space resources are limited; if a large amount of space is used to store duplicate models, the available space will decrease, which may affect the storage of other important data and applications. This application's embodiments, by separating model-specific information from weight information, can avoid the need to repeatedly store machine learning models with the same functionality, reduce the size of model files, and enable models with different frameworks to share the same weight files, thereby reducing storage space consumption and lowering storage costs.
[0051] In one possible implementation, step 1012 above, storing the weight information in the machine learning models corresponding to the multiple frameworks into a shared weight file, includes:
[0052] The weight information in the machine learning models corresponding to the multiple frameworks is quantized to obtain the quantized value of each weight in the weight information; the quantized value is stored in a shared weight file.
[0053] Since weights are typically stored as floating-point numbers, which consume significant storage space in computers, this embodiment quantizes the weight information in machine learning models corresponding to multiple frameworks to obtain quantized values for each weight. These quantized values are then stored in a shared weight file to reduce the amount of server storage space required.
[0054] In step 102 above, obtaining target weight information that matches the specific information of the target model from a preset shared weight file includes:
[0055] Obtain the target quantization value that matches the specific information of the target model from the shared weight file; convert the target quantization value into target weight information that matches the specific information of the target model according to the weight mapping table, wherein the weight mapping table includes the quantization value corresponding to each weight in the weight information.
[0056] In this embodiment of the application, after obtaining the target quantization value that matches the specific information of the target model from the shared weight file, the target weight information corresponding to the target quantization value is searched in the weight mapping table, and then the model file is distributed.
[0057] In this way, even if the server stores the weights with lower precision, the edge device can still receive high-precision weight information.
[0058] In one possible implementation, the above-mentioned quantization processing of the weight information in the machine learning models corresponding to the multiple frameworks to obtain the quantized value corresponding to each weight in the weight information includes:
[0059] The value range of each weight in the weight information is evenly divided into a number of quantization intervals that match the preset quantization level, and each weight is mapped to the corresponding quantization interval; the quantization value is determined according to the quantization interval corresponding to each weight.
[0060] In this embodiment, the quantization level is first determined. The quantization level indicates the required precision level for the quantized weights; for example, quantizing a 32-bit floating-point number (F32) into an 8-bit integer (INT8). Then, the value range of each weight in the weight information is evenly divided into a number of quantization intervals matching the preset quantization level. Based on the quantization intervals corresponding to each weight, the quantized value is determined. Figure 2 As shown in the diagram, assuming the quantization level is F32 quantized to INT8, the range between the maximum and minimum values of the weights is divided into 256 sub-intervals, and each INT8 value is mapped to all the weights in a sub-interval.
[0061] Create a weight mapping table where the keys (i.e., the quantized values) are all possible INT8 values (from -128 to 127), and the values are the weights mapped to those keys. This weight mapping table represents the relationship between INT8 values and actual weights. This ensures that the quantized values can still be correctly mapped back to high-precision weights.
[0062] Among them, determining the quantization value based on the quantization interval corresponding to each weight includes:
[0063] Based on the quantity distribution of the weights corresponding to each quantization value, the quantization intervals corresponding to the quantization values are reorganized to obtain the reorganized quantization intervals; based on the reorganized quantization intervals, the quantization values corresponding to each weight are determined.
[0064] This method can identify which quantization intervals can be adjusted or subdivided to avoid loss of accuracy.
[0065] The aforementioned method of reorganizing the quantization intervals corresponding to the quantization values based on the distribution of the weights corresponding to each quantization value to obtain the reorganized quantization interval includes:
[0066] Obtain a first quantization value whose number of weights corresponding to each quantization value is lower than a first threshold; determine a second threshold based on the target number of the first quantization value; the second threshold is greater than the first threshold; determine a second quantization value whose number of weights among the quantization values is higher than the second threshold; divide the quantization interval corresponding to the second quantization value into a first sub-interval and a second sub-interval, map the first quantization value to the first sub-interval, and map the second quantization value to the second sub-interval to obtain the recombined quantization interval.
[0067] In one exemplary embodiment, such as Figure 3As shown, the number of weights corresponding to each INT8 value is counted, and the number n of keys without corresponding weight records, along with the set A of these keys, is recorded. Simultaneously, the n keys with the largest number of mapped weights are identified, and their set B and corresponding weight set X are recorded. For each key in set B, its mapped quantization interval is divided into two parts: the first quantization interval is from the lower limit to the midpoint of the original interval, and the second quantization interval is from the midpoint to the upper limit of the original interval. A key in set A is mapped to the upper limit to the midpoint of the new interval, while the original key is mapped to the lower limit to the midpoint of the new interval. This allocates more precision to the weight-dense interval, increasing the precision of INT8 to INT16.
[0068] This application provides a method for distributing model files. In response to a model file download request sent by an edge device, the method obtains target model-specific information corresponding to the download request; retrieves target weight information matching the target model-specific information from a preset shared weight file, which includes weight information for machine learning models corresponding to multiple frameworks; determines the model file for the machine learning model based on the target model-specific information and the target weight information; and sends the model file to the edge device. By retrieving target weight information matching the target model-specific information from a shared weight file, instead of retrieving weight information separately from the model files of the machine learning models, the same shared weight file can be accessed and used regardless of the framework to which the machine learning model requested for download by the edge device belongs. This avoids redundant storage of the same weight information, reduces storage space usage, and lowers storage costs.
[0069] Figure 4 This illustration shows a schematic diagram of the structure of a server provided in an embodiment of this application, which can achieve the following: Figure 1 The server 400, comprising all or part of the contents shown in the embodiment, includes:
[0070] The information acquisition module 410 is used to respond to a model file download request sent by the edge device and acquire target model-specific information corresponding to the model file download request; wherein, the target model-specific information is the information of the machine learning model corresponding to the framework used by the edge device after removing weight information;
[0071] The weight acquisition module 420 is used to acquire target weight information that matches the specific information of the target model from a preset shared weight file, wherein the shared weight file includes weight information of machine learning models corresponding to multiple frameworks;
[0072] The model determination module 430 is used to determine the model file of the machine learning model based on the target model-specific information and the target weight information;
[0073] The model sending module 440 is used to send the model file to the edge device.
[0074] In one possible implementation, the information acquisition module 410, when acquiring target model-specific information corresponding to the model file download request in response to the model file download request sent by the edge device, is specifically used for:
[0075] Obtain a model file download request sent by an edge device, wherein the model file download request includes the framework information of the framework used by the edge device;
[0076] Obtain model-specific information corresponding to the framework indicated by the framework information from the preset model file, and determine that the model-specific information corresponding to the framework indicated by the framework information is the target model-specific information corresponding to the model file download request. The model file includes model-specific information corresponding to multiple frameworks.
[0077] In one possible implementation, the model determination module 430, when determining the model file of the machine learning model based on the target model-specific information and the target weight information, is specifically used for:
[0078] Obtain the weight position information corresponding to the specific information of the target model;
[0079] Based on the weight position information, the target weight information is inserted into the target model-specific information to obtain the model file of the machine learning model.
[0080] In one possible implementation, server 400 also includes:
[0081] The model acquisition module is used to acquire machine learning models corresponding to multiple frameworks.
[0082] The weight processing module is used to store the weight information of the machine learning models corresponding to the multiple frameworks into a shared weight file;
[0083] The weight removal module is used to remove weight information from the machine learning models corresponding to the multiple frameworks to obtain model-specific information corresponding to the multiple frameworks.
[0084] The model acquisition module, when used to acquire machine learning models corresponding to multiple frameworks, is specifically used for:
[0085] Obtain the machine learning model corresponding to the target framework;
[0086] By performing model transformation on the machine learning model corresponding to the target framework, machine learning models corresponding to multiple frameworks can be obtained.
[0087] In one possible implementation, the weight processing module, when storing the weight information from the machine learning models corresponding to the multiple frameworks into a shared weight file, specifically performs the following:
[0088] The weight information in the machine learning models corresponding to the multiple frameworks is quantized to obtain the quantized value of each weight in the weight information.
[0089] Store the quantized values in a shared weight file.
[0090] The weight acquisition module 420 is also used for:
[0091] Obtain the target quantization value that matches the specific information of the target model from the shared weight file;
[0092] According to the weight mapping table, the target quantized value is converted into target weight information that matches the specific information of the target model. The weight mapping table includes the quantized value corresponding to each weight in the weight information.
[0093] In one possible implementation, the weight processing module, when quantizing the weight information in the machine learning models corresponding to the multiple frameworks to obtain the quantized value corresponding to each weight in the weight information, specifically performs the following:
[0094] The value range of each weight in the weight information is evenly divided into a number of quantization intervals that match the preset quantization level, and each weight is mapped to the corresponding quantization interval.
[0095] The quantization value is determined based on the quantization interval corresponding to each weight.
[0096] In one possible implementation, the weight processing module, when determining the quantization value based on the quantization interval corresponding to each weight, specifically performs the following:
[0097] Based on the distribution of the number of weights corresponding to each quantization value, the quantization intervals corresponding to the quantization values are reorganized to obtain the reorganized quantization intervals;
[0098] Based on the recombined quantization range, determine the quantization value corresponding to each weight.
[0099] In one possible implementation, the weight processing module, when reorganizing the quantization intervals corresponding to the quantization values according to the quantity distribution of the weights corresponding to each quantization value, specifically performs the following:
[0100] The first quantized value whose weight is lower than the first threshold is obtained;
[0101] A second threshold is determined based on the target number of the first quantized value; the second threshold is greater than the first threshold.
[0102] Determine the second quantization value whose weight count is higher than the second threshold among all quantization values;
[0103] The quantization interval corresponding to the second quantization value is divided into a first sub-interval and a second sub-interval. The first quantization value is mapped to the first sub-interval, and the second quantization value is mapped to the second sub-interval to obtain the recombined quantization interval.
[0104] This application provides a server including an information acquisition module, a weight acquisition module, a model determination module, and a model sending module. The information acquisition module, in response to a model file download request sent by an edge device, acquires target model-specific information corresponding to the download request. The weight acquisition module acquires target weight information matching the target model-specific information from a preset shared weight file, whereby the shared weight file includes weight information for machine learning models corresponding to multiple frameworks. The model determination module determines the model file of the machine learning model based on the target model-specific information and the target weight information. The model sending module sends the model file to the edge device. Thus, by acquiring target weight information matching the target model-specific information from a shared weight file, instead of acquiring weight information separately from the model files of the machine learning models, the same shared weight file can be accessed and used regardless of the framework to which the machine learning model requested for download by the edge device belongs. This avoids redundant storage of the same weight information, reduces storage space usage, and lowers storage costs.
[0105] This application embodiment also provides a model file distribution system, including the aforementioned server and edge nodes that communicate and connect with the server.
[0106] Figure 5 This diagram illustrates the hardware structure of an electronic device implementing the embodiments of this application. Referring to the diagram, at the hardware level, the electronic device 500 includes a processor 510, and optionally includes an internal bus 520, a network interface 530, and a memory 540. The memory 540 may include main memory 541, such as high-speed random-access memory (RAM), and may also include non-volatile memory 542, such as at least one disk storage device. Of course, the electronic device 500 may also include other hardware required for other services.
[0107] The processor 510, network interface 530, and memory can be interconnected via an internal bus 520. This internal bus 520 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be categorized as an address bus, data bus, control bus, etc. For ease of illustration, only a single bidirectional arrow is used in this diagram, but this does not imply that there is only one bus or one type of bus.
[0108] Memory 540 stores programs. Specifically, the program may include program code, which includes computer operation instructions. Memory 540 may include main memory 541 and non-volatile memory 542, and provides instructions and data to processor 510.
[0109] Processor 510 reads the corresponding computer program from non-volatile memory 542 into memory and then runs it, forming a device for locating the target user at the logical level. Processor 510 executes the program stored in memory and specifically performs the following: Figure 1 The methods disclosed in the embodiments shown achieve the functions and beneficial effects of the methods described in the preceding method embodiments, and will not be repeated here.
[0110] The above is as stated in this application. Figure 1The methods disclosed in the illustrated embodiments can be applied to or implemented by processor 510. Processor 510 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by integrated logic circuits in the hardware of processor 510 or by instructions in software form. The processor 510 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.
[0111] The computer device can also execute the methods described in the preceding method embodiments and achieve the functions and beneficial effects of the methods described in the preceding method embodiments, which will not be repeated here.
[0112] Of course, in addition to software implementation, the electronic device 500 of this application does not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. In other words, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0113] This application also proposes a computer-readable storage medium that stores one or more programs, which, when executed by an electronic device including multiple applications, cause the electronic device to perform... Figure 1 The methods disclosed in the embodiments shown achieve the functions and beneficial effects of the methods described in the preceding method embodiments, and will not be repeated here.
[0114] The computer-readable storage medium mentioned above includes read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, etc.
[0115] Furthermore, embodiments of this application also provide a computer program product, the computer program product including a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions, which, when executed by a computer, implement the following process: Figure 1 The methods disclosed in the embodiments shown achieve the functions and beneficial effects of the methods described in the preceding method embodiments, and will not be repeated here.
[0116] The embodiments of this application can be applied to various scenarios of electronic device collaboration or interconnection, including: collaboration and interconnection between mobile phones and laptops / tablets; collaboration and interconnection between mobile terminals and smart TVs / monitors; collaboration and interconnection between mobile phones or tablets and in-vehicle entertainment systems; collaboration and interconnection between mobile terminals and smart conferencing systems, etc. This satisfies users' diverse needs in smart home, smart office, and smart travel scenarios.
[0117] In summary, the above description is merely a preferred embodiment of this application and does not limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
[0118] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0119] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can store information accessible to a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0120] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0121] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
Claims
1. A method for distributing model files, characterized in that, include: In response to a model file download request sent by an edge device, specific information about the target model corresponding to the model file download request is obtained; wherein, the specific information about the target model is the information of the machine learning model corresponding to the framework used by the edge device after removing weight information; Obtain target weight information that matches the specific information of the target model from a preset shared weight file, wherein the shared weight file includes weight information of machine learning models corresponding to multiple frameworks; Based on the target model-specific information and the target weight information, determine the model file of the machine learning model; Send the model file to the edge device; Prior to obtaining the target model-specific information corresponding to the model file download request, the method further includes: Obtain the machine learning model corresponding to the target framework; use a conversion tool to convert the machine learning model corresponding to the target framework to obtain machine learning models corresponding to multiple frameworks. The weight information of the machine learning models corresponding to the multiple frameworks is stored in a shared weight file; The weight information in the machine learning models corresponding to the multiple frameworks is removed to obtain model-specific information corresponding to the multiple frameworks.
2. The method according to claim 1, characterized in that, The step of responding to a model file download request sent by an edge device and obtaining target model-specific information corresponding to the model file download request includes: Obtain a model file download request sent by an edge device, wherein the model file download request includes the framework information of the framework used by the edge device; Obtain model-specific information corresponding to the framework indicated by the framework information from the preset model file, and determine that the model-specific information corresponding to the framework indicated by the framework information is the target model-specific information corresponding to the model file download request. The model file includes model-specific information corresponding to multiple frameworks.
3. The method according to claim 1, characterized in that, The step of determining the model file of the machine learning model based on the target model-specific information and the target weight information includes: Obtain the weight position information corresponding to the specific information of the target model; Based on the weight position information, the target weight information is inserted into the target model-specific information to obtain the model file of the machine learning model.
4. The method according to claim 1, characterized in that, The step of storing the weight information of the machine learning models corresponding to the multiple frameworks into a shared weight file includes: The weight information in the machine learning models corresponding to the multiple frameworks is quantized to obtain the quantized value of each weight in the weight information. Store the quantized values in a shared weight file.
5. The method according to claim 4, characterized in that, The step of obtaining target weight information that matches the specific information of the target model from a preset shared weight file includes: Obtain the target quantization value that matches the specific information of the target model from the shared weight file; According to the weight mapping table, the target quantized value is converted into target weight information that matches the specific information of the target model. The weight mapping table includes the quantized value corresponding to each weight in the weight information.
6. The method according to claim 4, characterized in that, The step of quantizing the weight information in the machine learning models corresponding to the multiple frameworks to obtain the quantized value corresponding to each weight in the weight information includes: The value range of each weight in the weight information is evenly divided into a number of quantization intervals that match the preset quantization level, and each weight is mapped to the corresponding quantization interval. The quantization value is determined based on the quantization interval corresponding to each weight.
7. The method according to claim 6, characterized in that, The step of determining the quantization value based on the quantization interval corresponding to each weight includes: Based on the distribution of the number of weights corresponding to each quantization value, the quantization intervals corresponding to the quantization values are reorganized to obtain the reorganized quantization intervals; Based on the recombined quantization range, determine the quantization value corresponding to each weight.
8. The method according to claim 7, characterized in that, The step of reorganizing the quantization intervals corresponding to the quantization values according to the quantity distribution of the weights corresponding to each quantization value to obtain the reorganized quantization interval includes: The first quantized value whose weight is lower than the first threshold is obtained; A second threshold is determined based on the target number of the first quantized value; the second threshold is greater than the first threshold. Determine the second quantization value whose weight count is higher than the second threshold among all quantization values; The quantization interval corresponding to the second quantization value is divided into a first sub-interval and a second sub-interval. The first quantization value is mapped to the first sub-interval, and the second quantization value is mapped to the second sub-interval to obtain the recombined quantization interval.
9. A server, characterized in that, include: The information acquisition module is used to respond to a model file download request sent by the edge device and acquire target model-specific information corresponding to the model file download request; wherein, the target model-specific information is the information of the machine learning model corresponding to the framework used by the edge device after removing weight information; The weight acquisition module is used to acquire target weight information that matches specific information of the target model from a preset shared weight file, wherein the shared weight file includes weight information of machine learning models corresponding to multiple frameworks; The model determination module is used to determine the model file of the machine learning model based on the target model-specific information and the target weight information; The model sending module is used to send the model file to the edge device; This also includes: The model acquisition module is used to acquire the machine learning model corresponding to the target framework; the conversion tool is used to convert the machine learning model corresponding to the target framework to obtain machine learning models corresponding to multiple frameworks. The weight processing module is used to store the weight information of the machine learning models corresponding to the multiple frameworks into a shared weight file; The weight removal module is used to remove weight information from the machine learning models corresponding to the multiple frameworks to obtain model-specific information corresponding to the multiple frameworks.
10. The server according to claim 9, characterized in that, The information acquisition module, when responding to a model file download request sent by an edge device and acquiring specific information about the target model corresponding to the model file download request, is specifically used for: Obtain a model file download request sent by an edge device, wherein the model file download request includes the framework information of the framework used by the edge device; Obtain model-specific information corresponding to the framework indicated by the framework information from the preset model file, and determine that the model-specific information corresponding to the framework indicated by the framework information is the target model-specific information corresponding to the model file download request. The model file includes model-specific information corresponding to multiple frameworks.
11. The server according to claim 9, characterized in that, The model determination module, when determining the model file of the machine learning model based on the target model-specific information and the target weight information, is specifically used for: Obtain the weight position information corresponding to the specific information of the target model; Based on the weight position information, the target weight information is inserted into the target model-specific information to obtain the model file of the machine learning model.
12. A model file distribution system, characterized in that, It includes the server as described in any one of claims 9 to 11, and edge nodes that communicate with and are connected to the server.
13. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a program or instructions that can run on the processor, the program or instructions being executed by the processor to implement the steps of the method according to any one of claims 1 to 8.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 to 8.
15. A computer program product, characterized in that, The computer program product includes a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions that, when executed by a computer, cause the computer to perform the steps of the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Model deployment and reasoning method and device, equipment and storage medium
CN118819659A
Apparatus for enabling the conversion and utilization of various formats of neural network models and method thereof
US20230214638A1