Model file issuing method, server, system and related equipment
By obtaining target weight information in the shared weight file, the problem of machine learning model files occupying a large amount of storage space is solved, and the effect of reducing storage costs is achieved.
Patent Information
- Application Number
- CN202411889366.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-20
AI Technical Summary
In the prior art, model files of machine learning models occupy a large amount of storage space, resulting in an increase in storage costs.
The issuance of the model file is achieved by obtaining the target weight information matching the target model specific information in the shared weight file, rather than obtaining the weight information from the model files of the machine learning model separately.
It avoids repeated storage of the same weight information, reduces the use of storage space, and reduces storage costs.
Smart Images

Figure CN119728672A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data application processing, and in particular to a method, server, system and related equipment for issuing a model file. Background Art
[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. These frameworks each have unique characteristics and advantages, and can meet different scenarios and needs. Therefore, developers can choose the appropriate framework for model development according to specific needs. This also leads to the possibility that the same inference function may have multiple model versions of different frameworks to meet the needs of different edge devices.
[0003] In order to meet the needs of edge devices, the server needs to store machine learning models corresponding to various frameworks and send them to edge devices when they need to be downloaded or upgraded. This means that the server needs to store a large number of model files of machine learning models with different frameworks but the same functions. The storage of these model files on the server takes up a lot of space resources and increases the storage cost of the server. Summary of the invention
[0004] The embodiments of the present application provide a method, server, system and related equipment for sending a model file, so as to at least solve the problem that the model files of the existing machine learning models occupy a large amount of storage space and increase storage costs.
[0005] In order to solve the above technical problems, this application is implemented as follows: In the first aspect, an embodiment of the present application provides a method for issuing a model file, comprising: in response 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 the machine learning model corresponding to the framework used by the edge device after removing the weight information; obtaining target weight information matching the target model specific information from a preset shared weight file, wherein the shared weight file includes 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.
[0006] In the second aspect, an embodiment of the present application provides a server, comprising: an information acquisition module, used to respond to a model file download request sent by an edge device, and obtain 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 the weight information; a weight acquisition module, used to obtain target weight information matching the target model specific information from a preset shared weight file, and the shared weight file includes weight information of machine learning models corresponding to multiple frameworks; a model determination module, used to determine the model file of the machine learning model based on the target model specific information and the target weight information; a model sending module, used to send the model file to the edge device.
[0007] In a third aspect, an embodiment of the present application provides a system for issuing a model file, including a server as described in the second aspect above, and an edge node that is communicatively connected to the server.
[0008] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the method described in the first aspect above are implemented.
[0009] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect above are implemented.
[0010] In a sixth aspect, an embodiment of the present application provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the steps of the method described in the first aspect above.
[0011] In an embodiment of the present application, in response to a model file download request sent by an edge device, target model specific information corresponding to the model file download request is obtained; target weight information matching the target model specific information is obtained from a preset shared weight file, and the shared weight file includes weight information of machine learning models corresponding to multiple frameworks; the model file of the machine learning model is determined according to the target model specific information and the target weight information; and the model file is sent to the edge device. In this way, by obtaining the target weight information matching the target model specific information in the shared weight file, rather than obtaining the weight information from the model file of the machine learning model separately, no matter which framework the machine learning model requested to be downloaded by the edge device belongs to, the same shared weight file can be accessed and used, thereby avoiding repeated storage of the same weight information, reducing storage space occupancy, and reducing storage costs.
[0012] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0014] Figure 1 A schematic diagram showing a flow chart of a method for issuing a model file provided in an embodiment of the present application; Figure 2 An example diagram of weight mapping provided by an embodiment of the present application is shown; Figure 3 An example diagram of quantization interval reorganization provided by an embodiment of the present application is shown; Figure 4 A schematic diagram showing the structure of a server provided in an embodiment of the present application is shown; Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0015] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0016] Machine learning frameworks such as TensorFlow, PyTorch, and Caffe are widely used in model development. Each of these frameworks has unique characteristics and advantages that can meet different scenarios and needs. Taking the Microsoft ONNX (Open Neural Network Exchange) Runtime framework, the Pytorch framework and the NCNN framework commonly used in academia as examples, the ONNX Runtime framework requires the use of model files in the ONNX format, the Pytorch framework uses model files in the pth format, and the NCNN framework requires the use of other model files in its corresponding format. This means that the server needs to save model files in the ONNX format, PyTorch's pth files, and NCNN's bin and param files at the same time. This diversity of model files causes the server to need to store a large number of machine learning models with different frameworks but the same functions, which takes up a lot of space resources and increases the storage cost of the server.
[0017] In response to the problems existing in the storage and distribution process of the model files of the above-mentioned machine learning models, an embodiment of the present application provides a method for distributing model files. This method obtains target weight information that matches the specific information of the target model from a shared weight file, rather than obtaining weight information from the model files of the machine learning model separately. Regardless of the framework to which the machine learning model requested to be downloaded by the edge device belongs, the same shared weight file can be accessed and used, thereby avoiding the need to repeatedly store the same weight information in machine learning models corresponding to multiple frameworks, reducing storage space occupancy, and reducing storage costs.
[0018] Figure 1 The flowchart of the method for issuing the model file provided in the embodiment of the present application is shown. The execution subject of the method may be a server, wherein the server may be a background server of a certain business, or a background server of a certain platform or application (for example, a cloud service platform, an edge device management system, etc.). As shown in the figure, the method 100 may include the following steps: Step 101: In response to a model file download request sent by an edge device, obtain target model specific information corresponding to the model file download request.
[0019] Among them, the target model specific information is 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 a tablet computer. The edge device can be a terminal device used by the user.
[0020] In a specific implementation, the edge device sends a model file download request of a machine learning model to the server. The machine learning model is such as an image classification model, an audio recognition model, a fault detection model, etc. The edge device uses a specific machine learning framework, such as a PyTorch framework, etc. The server responds to the model file download request sent by the edge device, parses the model file download request, obtains the framework information used by the edge device, and obtains the target model specific information corresponding to the model file download request based on the framework information. Among them, the target model specific information is the model structure information after removing the weight information under the framework used by the edge device. For example, the network structure of an image classification model, such as the hierarchical information of a convolutional neural network, but does not contain trained weight data. The target model specific information is the architecture of the machine learning model, which may include information such as the number of layers, the input and output dimensions of each layer, and the type of activation function.
[0021] Step 102: Obtain target weight information that matches the target model specific information from a preset shared weight file, wherein the shared weight file includes weight information of machine learning models corresponding to multiple frameworks.
[0022] In a specific implementation, the server obtains target weight information matching the target model architecture in the shared weight file A. The shared weight file A contains pre-trained weight information of machine learning models corresponding to multiple frameworks, such as TensorFlow, PyTorch, etc.
[0023] Step 103: Determine the model file of the machine learning model according to the target model specific information and the target weight information.
[0024] In a specific implementation, the server combines the acquired target model specific information with the target weight information in the shared weight file to construct a complete model file of the machine learning model.
[0025] Step 104: Send the model file to the edge device.
[0026] In a specific implementation, the server transmits the constructed model file to the edge device through the network. After receiving the model file, the edge device can directly use the model file to perform the corresponding task.
[0027] In this way, each edge device can receive a customized model based on the framework it uses, while sharing the same weight information. In this way, the server connected to the edge device only needs to save a shared weight file, and can issue the corresponding model file according to any machine learning framework deployed on the edge device, thereby significantly reducing the storage space occupied.
[0028] In a possible implementation, in the above step 101, in response to the model file download request sent by the edge device, obtaining the 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 framework information of a framework used by the edge device; obtain model-specific information corresponding to the framework indicated by the framework information from a 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, wherein the model file includes model-specific information corresponding to multiple frameworks.
[0029] In an embodiment of the present application, the edge device sends a model file download request to the server, and the model file download request may include framework information of the framework used by the edge device, for example, the framework type is PyTorch. After receiving the model file download request, the server parses the framework information in the model file download request, and obtains the target model specific information corresponding to the framework used by the edge device from the preset model file B according to the framework information. The target model specific information includes the model structure and other information, such as the model structure, such as the number of convolutional layers, pooling layers, etc.
[0030] In a possible implementation, in the above step 103, determining the model file of the machine learning model according to the target model specific information and the target weight information includes: Obtain weight position information corresponding to the target model specific information; insert the target weight information into the target model specific information according to the weight position information to obtain a model file of the machine learning model.
[0031] In an embodiment of the present application, the server can obtain the weight position file C corresponding to the target model specific information to obtain the weight position information, insert the corresponding target weight information into the target model specific information according to the weight position information, and obtain the model file of the machine learning model.
[0032] In a possible implementation, in the above step 101, before obtaining the target model specific information corresponding to the model file download request, the following further includes: Step 1011: Obtain machine learning models corresponding to multiple frameworks.
[0033] In the above step 1011, the machine learning models corresponding to the multiple frameworks are obtained, including: Obtain the machine learning model corresponding to the target framework; obtain the machine learning models corresponding to multiple frameworks by performing model conversion on the machine learning model corresponding to the target framework.
[0034] In specific implementations, the machine learning model of a target framework can be converted into machine learning models corresponding to other frameworks. Specifically, the conversion tools provided by the machine learning framework can be used to complete the model conversion. Through model conversion, it can be ensured that the same model can run under different frameworks, thus laying the foundation for subsequent weight sharing.
[0035] Step 1012: Store the weight information in the machine learning models corresponding to the multiple frameworks into a shared weight file.
[0036] In a specific implementation, weight information is extracted from the machine learning models corresponding to the converted multiple frameworks and saved as a separate shared weight file A. The shared weight file A includes weight information shared by all frameworks.
[0037] Here, since weight information is an important component of model parameters, it usually occupies most of the storage space of the model file. In the embodiment of the present application, weight information can be extracted and stored separately, so that weight sharing between different framework models can be achieved.
[0038] Step 1013: remove the weight information in the machine learning models corresponding to the multiple frameworks to obtain model-specific information corresponding to the multiple frameworks.
[0039] In the specific implementation, the weight information in the machine learning model corresponding to all frameworks is removed to generate a model file B lacking weight information, which includes model-specific information corresponding to multiple frameworks. At the same time, the location information of the weight information in the machine learning model is recorded so that the weight information can be accurately inserted into the correct position in the model-specific information when the model file is subsequently issued.
[0040] Storing a large number of machine learning models with the same function but in different frameworks will take up a lot 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 be reduced, which may affect the storage of other important data and applications. The embodiment of the present application can avoid the need to repeatedly store machine learning models with the same function by separating model-specific information from weight information, reduce the size of model files, and enable models of different frameworks to share the same weight files, thereby reducing storage space usage and storage costs.
[0041] In a possible implementation, in the above step 1012, storing the weight information in the machine learning models corresponding to the multiple frameworks into a shared weight file includes: The weight information in the machine learning model corresponding to the multiple frameworks is quantized to obtain a quantized value corresponding to each weight in the weight information; and the quantized value is stored in a shared weight file.
[0042] Since weights are usually stored in the form of floating-point numbers, which take up more storage space in computers, the embodiment of the present application quantizes the weight information in the machine learning models corresponding to multiple frameworks when storing weight information, obtains the quantized value corresponding to each weight in the weight information, and stores the quantized value in a shared weight file to reduce the storage space occupied by the server.
[0043] Wherein, in the above step 102, obtaining target weight information matching the target model specific information from a preset shared weight file includes: Obtain a target quantization value that matches the target model specific information from the shared weight file; convert the target quantization value into target weight information that matches the target model specific information according to a weight mapping table, wherein the weight mapping table includes quantization values corresponding to each weight in the weight information.
[0044] In an embodiment of the present application, after obtaining the target quantization value that matches the target model-specific information 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 issued.
[0045] In this way, even if the server stores the weights with lower precision, the edge device can still receive high-precision weight information.
[0046] In a possible implementation, the above-mentioned quantization processing of the weight information in the machine learning models corresponding to the multiple frameworks to obtain the quantization value corresponding to each weight in the weight information includes: The value interval of each weight in the weight information is evenly divided into quantization intervals whose number matches the preset quantization level, and each weight is mapped to a corresponding quantization interval; and the quantization value is determined according to the quantization interval corresponding to each weight.
[0047] In the embodiment of the present application, the quantization level is first determined. The quantization level is used to indicate the precision level required for the quantized weights, for example, quantizing a 32-bit floating point number (F32) to an 8-bit integer (INT8). Then, the value interval of each weight in the weight information is evenly divided into a number of quantization intervals that match the preset quantization level, and the quantization value is determined according to the quantization interval corresponding to each weight. Figure 2As shown in , assuming that the quantization level is to quantize F32 to INT8, the value interval between the maximum and minimum values of the weight is divided into 256 small intervals, and each INT8 value is mapped to all weights in a small interval.
[0048] Create a weight mapping table whose keys (i.e., quantized values) are all possible values of INT8 (from -128 to 127), and whose values are the weights mapped to these keys. This weight mapping table is used to represent the relationship between INT8 values and actual weights. This ensures that the quantized values can still be correctly mapped back to high-precision weights.
[0049] The above-mentioned determining the quantization value according to the quantization interval corresponding to each weight includes: According to the quantity distribution of the weights corresponding to the quantized values, the quantized intervals corresponding to the quantized values are reorganized to obtain reorganized quantized intervals; and according to the reorganized quantized intervals, the quantized values corresponding to the weights are determined.
[0050] In this way, it is possible to identify which quantization intervals can be adjusted or subdivided to avoid loss of precision.
[0051] The above-mentioned reorganization of the quantization intervals corresponding to the quantization values according to the quantity distribution of the weights corresponding to the quantization values to obtain the reorganized quantization intervals includes: Obtain a first quantization value in which the number of weights corresponding to each quantization value is lower than a first threshold; determine a second threshold according to a target number of the first quantization value; the second threshold is greater than the first threshold; determine a second quantization value in which the number of weights in each quantization value 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 a reorganized quantization interval.
[0052] In an exemplary embodiment, if Figure 3 As shown, count the number of weights corresponding to each INT8 value, and record the number of keys n without corresponding weight records, as well as the set A of these keys. At the same time, find the n keys with the largest number of mapped weights, record the set B of these keys, and their corresponding weight set X. For each key in set B, divide its mapped quantization interval 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. Map a key in set A to the upper limit to the midpoint of the new interval, and the original key to the lower limit to the midpoint of the new interval. In this way, more precision is allocated to the weight-dense interval, and the precision of INT8 is improved to INT16.
[0053] The embodiment of the present application provides a method for sending a model file, in response to a model file download request sent by an edge device, obtaining target model specific information corresponding to the model file download request; obtaining target weight information matching the target model specific information from a preset shared weight file, wherein the shared weight file includes weight information of machine learning models corresponding to multiple frameworks; determining the model file of the machine learning model according to the target model specific information and the target weight information; and sending the model file to the edge device. In this way, by obtaining the target weight information matching the target model specific information from the shared weight file, rather than obtaining the weight information from the model file of the machine learning model separately, no matter which framework the machine learning model requested to be downloaded by the edge device belongs to, the same shared weight file can be accessed and used, thereby avoiding repeated storage of the same weight information, reducing storage space occupancy, and reducing storage costs.
[0054] Figure 4 The schematic diagram of the structure of the server provided in the embodiment of the present application is shown. The server can implement the following Figure 1 In the embodiment shown, all or part of the content, the server 400 includes: The information acquisition module 410 is used to respond to the model file download request sent by the edge device and obtain the 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 the weight information; A weight acquisition module 420 is used to acquire target weight information that matches the target model specific information from a preset shared weight file, wherein the shared weight file includes weight information of machine learning models corresponding to multiple frameworks; A model determination module 430, configured to determine a model file of the machine learning model according to the target model specific information and the target weight information; The model sending module 440 is used to send the model file to the edge device.
[0055] In a possible implementation, the information acquisition module 410, when used to respond to a model file download request sent by an edge device and obtain target model specific information corresponding to the model file download request, is specifically used to: Obtaining a model file download request sent by an edge device, wherein the model file download request includes framework information of a framework used by the edge device; The model-specific information corresponding to the framework indicated by the framework information is obtained from a preset model file, and the model-specific information corresponding to the framework indicated by the framework information is determined to be the target model-specific information corresponding to the model file download request, wherein the model file includes model-specific information corresponding to multiple frameworks.
[0056] In a possible implementation, the model determination module 430, when used to determine the model file of the machine learning model according to the target model specific information and the target weight information, is specifically used to: Obtaining weight position information corresponding to the target model specific information; According to the weight position information, the target weight information is inserted into the target model specific information to obtain a model file of the machine learning model.
[0057] In a possible implementation, the server 400 further includes: Model acquisition module, used to obtain machine learning models corresponding to multiple frameworks; A weight processing module, used to store weight information in the machine learning models corresponding to the multiple frameworks into a shared weight file; The weight removal module is used to remove the weight information in the machine learning models corresponding to the multiple frameworks to obtain model-specific information corresponding to the multiple frameworks.
[0058] Among them, the model acquisition module, when used to obtain machine learning models corresponding to multiple frameworks, is specifically used to: Get the machine learning model corresponding to the target framework; By converting the machine learning model corresponding to the target framework, machine learning models corresponding to multiple frameworks are obtained.
[0059] In a possible implementation, the weight processing module, when used to store the weight information in the machine learning models corresponding to the multiple frameworks into the shared weight file, is specifically used to: Quantizing the weight information in the machine learning models corresponding to the multiple frameworks to obtain a quantized value corresponding to each weight in the weight information; The quantized values are stored in a shared weight file.
[0060] The weight acquisition module 420 is further used for: Acquire a target quantized value matching the target model specific information from the shared weight file; The target quantized value is converted into target weight information matching the target model specific information according to a weight mapping table, wherein the weight mapping table includes quantized values corresponding to each weight in the weight information.
[0061] In a possible implementation, the weight processing module, when used to quantize 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, is specifically used to: Evenly divide the value interval of each weight in the weight information into quantization intervals whose number matches the preset quantization level, and map each weight to a corresponding quantization interval; The quantization value is determined according to the quantization interval corresponding to each weight.
[0062] In a possible implementation, the weight processing module, when used to determine the quantization value according to the quantization interval corresponding to each weight, is specifically used to: According to the quantity distribution of the weights corresponding to the quantized values, the quantized intervals corresponding to the quantized values are reorganized to obtain the reorganized quantized intervals; According to the reorganized quantization interval, the quantization value corresponding to each weight is determined.
[0063] In a possible implementation, the weight processing module, when used to reorganize the quantization intervals corresponding to the quantization values according to the quantity distribution of the weights corresponding to the quantization values to obtain the reorganized quantization intervals, is specifically used to: Obtaining a first quantization value whose number of weights corresponding to each quantization value is lower than a first threshold; Determining a second threshold value according to a target number of the first quantization value; the second threshold value is greater than the first threshold value; Determine a second quantized value whose weight quantity among the quantized values is higher than the second threshold; 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, so as to obtain a reorganized quantization interval.
[0064] The embodiment of the present 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 responds to the model file download request sent by the edge device, and obtains the target model specific information corresponding to the model file download request; the weight acquisition module obtains the target weight information matching the target model specific information from the preset shared weight file, and the shared weight file includes the weight information of the machine learning model corresponding to multiple frameworks; the model determination module determines the model file of the machine learning model according to the target model specific information and the target weight information; the model sending module sends the model file to the edge device. In this way, by obtaining the target weight information matching the target model specific information in the shared weight file, instead of obtaining the weight information from the model file of the machine learning model separately, no matter which framework the machine learning model requested to be downloaded by the edge device belongs to, the same shared weight file can be accessed and used, thereby avoiding repeated storage of the same weight information, reducing the storage space occupied, and reducing storage costs.
[0065] The embodiment of the present application also provides a system for issuing a model file, including the above-mentioned server, and an edge node that is communicatively connected to the server.
[0066] Figure 5 The hardware structure diagram of the electronic device provided by the embodiment of the present application is shown. Referring to the figure, 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. Among them, the memory 540 may include a memory 541, such as a high-speed random access memory (Random-Access Memory, RAM), and may also include a non-volatile memory 542 (non-volatile memory), such as at least one disk storage, etc. Of course, the electronic device 500 may also include hardware required for other services.
[0067] The processor 510, the network interface 530 and the memory may be interconnected via an internal bus 520, which may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one bidirectional arrow is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0068] The memory 540 stores programs. Specifically, the programs may include program codes, and the program codes include computer operation instructions. The memory 540 may include a memory 541 and a non-volatile memory 542 , and provide instructions and data to the processor 510 .
[0069] The processor 510 reads the corresponding computer program from the non-volatile memory 542 into the memory and then runs it, forming a device for locating the target user at the logical level. The processor 510 executes the program stored in the memory and specifically performs: Figure 1 The method disclosed in the illustrated embodiment realizes the functions and beneficial effects of each method described in the foregoing method embodiments, which will not be described in detail here.
[0070] The above application Figure 1The method disclosed in the illustrated embodiment can be applied to the processor 510 or implemented by the processor 510. The processor 510 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 510. The above 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 gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0071] The computer device can also execute the methods described in the foregoing method embodiments, and realize the functions and beneficial effects of the methods described in the foregoing method embodiments, which will not be repeated here.
[0072] Of course, in addition to software implementation, the electronic device 500 of the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0073] The embodiment of the present application also provides a computer-readable storage medium, wherein the computer-readable medium stores one or more programs, and when the one or more programs are executed by an electronic device including multiple application programs, the electronic device executes Figure 1 The method disclosed in the illustrated embodiment realizes the functions and beneficial effects of each method described in the foregoing method embodiments, which will not be described in detail here.
[0074] The computer-readable storage medium includes a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0075] Furthermore, an embodiment of the present application also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, and when the program instructions are executed by a computer, the following process is implemented: Figure 1 The method disclosed in the illustrated embodiment realizes the functions and beneficial effects of each method described in the foregoing method embodiments, which will not be described in detail here.
[0076] The embodiments of the present application can be applied to various electronic device collaboration or interconnection scenarios, including: collaboration and interconnection between mobile phones and laptops / tablet computers; collaboration and interconnection between mobile terminals and smart TVs / displays; collaboration and interconnection between mobile phones or tablet computers and in-car entertainment systems; collaboration and interconnection between mobile terminals and smart conference systems, etc., so as to meet the needs of users in various scenarios such as smart homes, smart offices, and smart travel.
[0077] In short, the above is only a preferred embodiment of the present application and does not limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0078] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0079] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. 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 technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0080] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0081] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
Claims
1. A method for issuing a model file, characterized in that: include: In response 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 information of a machine learning model corresponding to a framework used by the edge device after weight information is removed; Obtaining target weight information matching the target model specific information from a preset shared weight file, wherein the shared weight file includes weight information of machine learning models corresponding to multiple frameworks; Determining a model file of the machine learning model according to the target model specific information and the target weight information; The model file is sent to the edge device.
2. The method according to claim 1, characterized in that: The step of obtaining target model specific information corresponding to the model file download request in response to the model file download request sent by the edge device includes: Obtaining a model file download request sent by an edge device, wherein the model file download request includes framework information of a framework used by the edge device; The model-specific information corresponding to the framework indicated by the framework information is obtained from a preset model file, and the model-specific information corresponding to the framework indicated by the framework information is determined to be the target model-specific information corresponding to the model file download request, wherein 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 according to the target model specific information and the target weight information includes: Obtaining weight position information corresponding to the target model specific information; According to the weight position information, the target weight information is inserted into the target model specific information to obtain a model file of the machine learning model.
4. The method according to claim 1, characterized in that: Before obtaining the target model specific information corresponding to the model file download request, the method further includes: Get machine learning models corresponding to multiple frameworks; Storing weight information in the machine learning models corresponding to the multiple frameworks into 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.
5. The method according to claim 4, characterized in that The obtaining of machine learning models corresponding to multiple frameworks includes: Get the machine learning model corresponding to the target framework; By converting the machine learning model corresponding to the target framework, machine learning models corresponding to multiple frameworks are obtained.
6. The method according to claim 4, characterized in that The storing the weight information in the machine learning models corresponding to the multiple frameworks into a shared weight file includes: Quantizing the weight information in the machine learning models corresponding to the multiple frameworks to obtain a quantized value corresponding to each weight in the weight information; The quantized values are stored in a shared weight file.
7. The method according to claim 6, characterized in that The step of obtaining target weight information matching the target model specific information from a preset shared weight file includes: Acquire a target quantized value matching the target model specific information from the shared weight file; The target quantized value is converted into target weight information matching the target model specific information according to a weight mapping table, wherein the weight mapping table includes quantized values corresponding to each weight in the weight information.
8. The method according to claim 6, characterized in that The 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: Evenly divide the value interval of each weight in the weight information into quantization intervals whose number matches the preset quantization level, and map each weight to a corresponding quantization interval; The quantization value is determined according to the quantization interval corresponding to each weight.
9. The method according to claim 7, characterized in that: The step of determining the quantization value according to the quantization interval corresponding to each weight includes: According to the quantity distribution of the weights corresponding to the quantized values, the quantized intervals corresponding to the quantized values are reorganized to obtain the reorganized quantized intervals; According to the reorganized quantization intervals, the quantization values corresponding to the respective weights are determined.
10. The method according to claim 9, 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 the quantization values to obtain the reorganized quantization intervals includes: Obtaining a first quantization value whose number of weights corresponding to each quantization value is lower than a first threshold; Determining a second threshold value according to a target number of the first quantization value; the second threshold value is greater than the first threshold value; Determine a second quantized value whose weight quantity among the quantized values is higher than the second threshold; 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, so as to obtain a reorganized quantization interval.
11. A server, characterized in that: include: An information acquisition module, configured to obtain target model specific information corresponding to a model file download request in response to a model file download request sent by an edge device; wherein the target model specific information is information of a machine learning model corresponding to a framework used by the edge device after weight information is removed; A weight acquisition module, used to obtain target weight information matching the target model specific information from a preset shared weight file, wherein the shared weight file includes weight information of machine learning models corresponding to multiple frameworks; A model determination module, used to determine a model file of the machine learning model according to 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.
12. The server according to claim 11, characterized in that The information acquisition module, when used to respond to a model file download request sent by an edge device and obtain target model specific information corresponding to the model file download request, is specifically used to: Obtaining a model file download request sent by an edge device, wherein the model file download request includes framework information of a framework used by the edge device; The model-specific information corresponding to the framework indicated by the framework information is obtained from a preset model file, and the model-specific information corresponding to the framework indicated by the framework information is determined to be the target model-specific information corresponding to the model file download request, wherein the model file includes model-specific information corresponding to multiple frameworks.
13. The server according to claim 11, characterized in that: The model determination module, when used to determine the model file of the machine learning model according to the target model specific information and the target weight information, is specifically used to: Obtaining weight position information corresponding to the target model specific information; According to the weight position information, the target weight information is inserted into the target model specific information to obtain a model file of the machine learning model.
14. The server according to claim 11, characterized in that: Also includes: Model acquisition module, used to obtain machine learning models corresponding to multiple frameworks; A weight processing module, used to store weight information in the machine learning models corresponding to the multiple frameworks into a shared weight file; The weight removal module is used to remove the weight information in the machine learning models corresponding to the multiple frameworks to obtain model-specific information corresponding to the multiple frameworks.
15. A system for issuing model files, characterized in that: It comprises a server as described in any one of claims 11 to 14, and an edge node communicatively connected with the server.
16. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the method according to any one of claims 1 to 10 are implemented.
17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.
18. A computer program product, characterized in that The computer program product comprises a computer program stored on a non-transitory computer-readable storage medium, wherein the computer program comprises program instructions, and when the program instructions are executed by a computer, the computer is caused to perform the steps of the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Model structure storage method and construction method of deep learning model and related device
CN116187412A
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