Data processing method, readable storage medium, program product and electronic equipment

By compressing the high-bit binary data of the artificial intelligence model and using efficient data processing methods when decompressing, the problem of excessive parameters of the artificial intelligence model is solved, saving storage space and improving decompression speed are achieved.

CN119623533APending Publication Date: 2025-03-14ARM TECH CHINA CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411680100.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

With the enhancement of the functions of the artificial intelligence model, the number of model parameters increases, resulting in excessive storage space of electronic devices, affecting device performance.

Method used

Through a data processing method, the high-bit binary data of the model parameters are compressed using compressed model parameters and lists, and the speed is increased when decompressed. By reading N-bit data and determining whether it is a preset value, it is determined whether the read data is a complete compressed model parameter.

Benefits of technology

Effectively reduces the use of storage space, improves the compression speed, and reduces the storage pressure and operation delay of the device.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119623533A_ABST
    Figure CN119623533A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, in particular to a data processing method, a readable storage medium, a program product and electronic equipment. The data processing method is applied to the electronic equipment, and the electronic equipment reads a complete compression model parameter corresponding to an actual model parameter and then decompresses the complete compression model parameter in the process of decompressing the compression model parameter by running an artificial intelligence model. Therefore, the read compression model parameters do not need to be decompressed every time the compression model parameters are read, so that the decompression speed of the electronic equipment on the compression model parameters is increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a data processing method, a readable storage medium, a program product, and an electronic device. Background Art

[0002] Electronic devices can achieve image processing, audio processing, etc. by deploying artificial intelligence models (such as neural network models, deep learning models, large language models, large models, etc.).

[0003] As the functions of artificial intelligence models are enhanced, the number of model parameters in the artificial intelligence models is also increasing. Electronic devices need to allocate a larger storage space to store the model parameters of the artificial intelligence models, which occupies a large amount of storage space of electronic devices. Summary of the invention

[0004] The embodiments of the present application provide a data processing method, a readable storage medium, a program product, and an electronic device. The data processing method can improve the decompression speed when decompressing data.

[0005] In a first aspect, an embodiment of the present application provides a data processing method, which is applied to a first electronic device, characterized in that the first electronic device stores compressed data of M model parameters corresponding to a first model and a first list, wherein the parameter value of the model parameter is represented by a-bit binary, the first list includes H different values ​​corresponding to the high b bits of the parameter values ​​of the M model parameters, the compressed data includes compressed model parameters of the parameter values ​​of each model parameter, the compressed model parameters are used to indicate the arrangement position of the parameter value of the corresponding model parameter in the first list, M, H, a and b are integers greater than 1, and b is less than or equal to a; and the method includes: detecting an instruction to run the first model; decompressing the compressed data to obtain the parameter value of each model parameter, and running the first model based on the parameter value of each model parameter obtained by decompression; wherein the M model parameters include the first model parameter, and decompressing the compressed data to obtain the parameter value of each model parameter, including: after obtaining all data of the first compressed model parameter corresponding to the first model parameter from the compressed data, obtaining the value of the first arrangement position indicated by all data of the first compressed model parameter from the first list, and determining the parameter value of the first model parameter based on the obtained value.

[0006] Exemplarily, in some embodiments of the present application, the first list may also be referred to as the first sequence list below, and the parameter value corresponding to the model parameter in the first model may be represented by an a-bit binary number. For example, an 8-bit binary number or a 4-bit binary number, etc. In the process of compressing the parameter value of the model parameter, all parameter values ​​may be compressed, or part of the parameter value may be compressed. For example, for an 8-bit binary number, the upper four bits may be compressed, so when the 8-bit parameter value is decompressed, the data that can be decompressed is the upper four bits of data, and the corresponding model parameter is obtained after the fourth bit of data and the lower four bits of data are combined. In other embodiments, it is also possible to start from the lower bits and perform compression on part of the parameter value of the model parameter, or compress part of the parameter value of the model parameter at a preset position.

[0007] When compressing a b-bit model parameter, b is a binary number that can represent a total of 2 values. b species, that is, H = 2 b , the number of times the H values ​​appear in the values ​​corresponding to the high b-bit data of the parameter values ​​of the M model parameters can be arranged from high to low to determine the first list. The arrangement position of the high b-bit data of the parameter value of the model parameter in the first list is compressed, and the compressed data and the low ab-bit data are used as the compressed model parameters of the model parameter. It can be understood that b can be equal to a, and when b is equal to a, it means that all the data of the model parameter is compressed.

[0008] In the process of decompressing compressed data, all the compressed model parameters can be decompressed after all the values ​​of the compressed model parameters corresponding to a model parameter are obtained. Therefore, there is no need to decompress each time a bit of compressed data is obtained, thereby improving the decompression speed.

[0009] The decompressed data is the arrangement position of the high b bits of the parameter value of the model parameter in the first list. The numerical value corresponding to the high b bits of the parameter value of the model parameter can be determined in the first list through the arrangement position, and then the parameter value of the model parameter can be determined, thereby completing the decompression.

[0010] In a possible implementation of the first aspect, the H different values ​​in the first list are arranged in descending order according to the number of times the H different values ​​appear in the M parameter values ​​corresponding to the M model parameters.

[0011] In a possible implementation of the first aspect above, all the compression model parameters of the first model parameter corresponding to b=a are obtained in the following manner: corresponding to the first compression model parameter being the first compression model parameter in the compressed data, starting from the Lth data of the compressed data, N bits of data are obtained each time, and when the N bits of data obtained for the hth time are not the preset value, the h×N bits of data starting from the Lth data are used as all the data of the first compression model parameter, wherein the Lth data in the compressed data is the first bit data of the compression model parameter corresponding to the M model parameters; corresponding to the first compression model being the Sth compression model parameter in the compressed data; after obtaining all the data of the S-1th compression model parameter, N data in the compressed data are obtained each time, and when the N bits of data obtained for the qth time are not the preset value, the q×N bits of data after the S-1th compression model parameter are used as all the data of the first compression model parameter; wherein S is an integer greater than 1, L and N are integers greater than or equal to 1, and h and q are integers greater than or equal to 0.

[0012] Exemplarily, in some embodiments of the present application, when b=a, all data of the parameter value of the model parameter are compressed, so the data decompressed from the compressed model parameter is the arrangement position of the parameter value of the model parameter in the first list.

[0013] During the decompression process, N bits of data can be read from the compressed data corresponding to the M model parameters each time. If the currently read N bits of data are preset data (hereinafter also referred to as preset prefixes), it can be determined that all the data of a compression model parameter has not been read. Until the read N bits of data are not preset data, the k N bits of data that have been read (k=h or k=q, and the k N bits of data that have been read do not include the decompressed data) can be used as all the data of the first compression model parameter. The first electronic device can decompress the k×N bits of data, and after decompression, it can continue to read N bits of data from the compressed data, thereby continuing to decompress the compressed data.

[0014] It can be understood that in the above data reading process, N bits of data are read each time, and decompression is performed only after all data of a compression model parameter are read. Compared with the solution of decompressing each compressed data bit, the decompression speed can be improved.

[0015] In a possible implementation of the first aspect, the H different values ​​are in the first list every 2 N-1 arrangement position corresponds to an arrangement position interval, and the first compression model parameter includes k×N bits of data, k=h or k=q; the value of the first arrangement position indicated by all the data of the first compression model parameter is obtained from the first list, and the parameter value of the first model parameter is determined based on the obtained value, including: determining the value of the parameter value of the first model parameter in the first arrangement position interval in the first list based on k, and determining the first arrangement position based on the last N bits of the first compression model parameter and the first arrangement position interval; using the value corresponding to the first arrangement position in the first list as the value of the parameter value of the first model parameter.

[0016] Exemplarily, in some embodiments of the present application, among the k×N-bit data that have been read, the k value is used to determine that the parameter value of the first model parameter corresponding to the first compression model parameter is in the first arrangement position interval in the first list, and the position of the parameter value of the first model parameter corresponding to the first compression model parameter in the first arrangement position interval can be determined based on the (k-1)×N-bit data to the k×N-bit data. In other words, the k value and the kth N-bit data can be used to determine that the parameter value of the first model parameter corresponding to the first compression model parameter is in the first arrangement position in the first list.

[0017] In a possible implementation of the first aspect, the first arrangement position is determined by the following formula:

[0018] lut=(k-1)×(2 N -1)+d

[0019] Among them, lut is the first arrangement position, (k-1)×(2 N -1) represents the starting position of the first arrangement position interval, and d is the offset of the first arrangement position determined based on the last N bits of data of the first compression model parameter relative to the starting position.

[0020] In some embodiments of the present application, there are 2 N -1 position, k×N bits of data can represent the value of the corresponding first model parameter in the kth arrangement position interval, then the (k-1)×(2 N -1) position may represent the starting position of the kth arrangement position interval, and d represents the offset of the position of the parameter value corresponding to the first model parameter in the first list relative to the starting position.

[0021] For example, corresponding to N=2, k=3, it can be determined that the parameter value of the first model parameter is located in the third arrangement position interval, and the starting position of the third arrangement position interval is (3-1)×(2 2-1)=6, if the offset d is 2, it can be determined that the parameter value of the first model parameter is at the 6th+2=8th position in the first list.

[0022] In a possible implementation of the first aspect above, the above corresponds to b being less than a; the compressed model parameter includes the low ab-bit data of the parameter value of the corresponding model parameter, and partially compressed data obtained by compressing the high b-bit data of the parameter value of the model parameter.

[0023] Exemplarily, in some embodiments of the present application, when b is less than a, it indicates that there are still low ab-bit data in the first model parameter that have not been compressed, and the first compressed model parameter may include the low ab-bit data of the parameter value of the first model parameter and partially compressed data after compressing the high b-bit data.

[0024] In a possible implementation of the first aspect above, all compression model parameters of the above-mentioned first model parameters are obtained in the following manner: corresponding to the first compression model parameter being the first compression model parameter in the compressed data, starting from the Lth bit of the compressed data, first obtain ab bits of data, and then obtain N bits of data each time, and when the N bits of data obtained for the hth time are not the preset value, the a-b+h×N bits of data starting from the Lth bit of the data are used as all the data of the first compression model parameter; wherein the Lth bit of data in the compressed data is the first bit of data of the compression model parameter corresponding to the M model parameters; corresponding to the first compression model being the Sth compression model parameter in the compressed data; after obtaining all the data of the S-1th compression model parameter, first obtain ab bits of data, and then obtain N bits of data each time, and when the N bits of data obtained for the qth time are not the preset value, the a-b+q×N bits of data after the S-1th compression model parameter are used as all the data of the first compression model parameter; wherein S is an integer greater than 1, L and N are integers greater than or equal to 1, and h and q are integers greater than or equal to 0.

[0025] Exemplarily, in some embodiments of the present application, the first compression model parameter includes both uncompressed low ab-bit data and compressed partial data corresponding to the high b-bit of the parameter value. Therefore, in the decompression process, the ab-bit data can be read first, and then the N-bit data can be read each time. Until the read N-bit data is not the preset data, it can be determined that the read ab-bit data and k×N-bit data (k=h or k=q, and the read data does not include the decompressed data) are the first compression model parameters. It can be understood that in other embodiments, the first compression model parameter corresponding to the first model parameter can also be the high b-bit partially compressed data in front, that is, q×N-bit data in front, and ab-bit uncompressed data in the back. Therefore, when acquiring data, it is also possible to first acquire N-bit data each time, and after the acquired N-bit data is not the preset value, acquire ab-bit data, thereby completing the acquisition of all data of the first compression model parameter. Or arrange the uncompressed ab-bit data and q×N-bit data in other ways.

[0026] In a possible implementation of the first aspect, the H different values ​​are in the first list every 2 N -1 arrangement position corresponds to an arrangement position interval, and the first compression model parameter includes k×N bit data, k=h or k=q; the value of the first arrangement position indicated by all the data of the first compression model parameter is obtained from the first list, and the parameter value of the first model parameter is determined based on the obtained value, including: determining the value corresponding to the high b bit data of the parameter value of the first model parameter in the first arrangement position interval in the first list based on k, and determining the first arrangement position based on the last N bits of the first compression model parameter and the first arrangement position interval; using the value corresponding to the first arrangement position in the first list as the value of the high b bit data of the parameter value of the first model parameter; determining the parameter value of the first model parameter based on the values ​​of the low ab bit data and the high b bit data of the parameter value of the first model parameter.

[0027] For example, in some implementations of the present application, the first compression model parameter includes uncompressed lower ab-bit data and k×N-bit partially compressed data, so in the decompression process, only the k×N-bit partially compressed data needs to be decompressed. After decompressing the k×N-bit data, the first arrangement position of the high b-bit value of the parameter value of the first model parameter can be determined in the first list, and the high b-bit value of the parameter value of the first model parameter can be determined based on the first arrangement position, and then the high b-bit data of the parameter value of the first model parameter can be determined, so that the complete parameter value of the first model parameter can be determined.

[0028] In a possible implementation of the first aspect, the N is determined by the following formula:

[0029] N = roundup (-log2 (n / M))

[0030] Among them, roundup() is the rounding method, n is the number of times the first value in the first list appears in the parameter values ​​of the M model parameters, and M is the total number of model parameters in the model parameters.

[0031] For example, in some embodiments of the present application, N is the number of compressed bits, and the above formula may be an information entropy formula or a Shannon information entropy formula. The higher the information entropy, the greater the uncertainty of the information, and the longer the average length of the required encoding. The above formula can be used to determine the optimal number of compressed bits N for the first model parameter, so that the compressed data occupies less space.

[0032] In a possible implementation of the first aspect above, the compressed data includes multiple frame data, and part of the data of the first compression model parameter is in the i-th frame data, and another part of the data of the first compression model parameter is in the i+1-th frame data, where i is an integer greater than 0; all the compression model parameters of the first model parameter are obtained in the following manner: based on the identification data in the i-th frame data, part of the data of the first compression model parameter is obtained from the i-th frame data, and another part of the data is obtained from the i+1-th frame data.

[0033] Exemplarily, in some embodiments of the present application, the compressed data can be divided into multiple frame data. When decompressing the compressed data, multiple frame data can be decompressed simultaneously by multiple processors, thereby further improving the decompression speed. However, some compression model parameters may be distributed in two consecutive frame data. Therefore, identification data can be added to each frame data, and the identification data is used to indicate how many bits of data at the end of the frame data need to be decompressed together with the next frame data. In this way, the part of the data can be stored in the cache. When the next frame data is to be decompressed, the part of the data can be obtained from the cache, thereby completing the decompression process.

[0034] In a second aspect, the present application provides an encoding method, which is applied to a second electronic device, characterized in that M model parameters are compressed, wherein the parameter value of the model parameter is represented by an a-bit binary, and the high b-bit data in the a-bit binary of the parameter value of the model parameter is compressed, M, a and b are integers greater than 1, and b is less than or equal to a, and the method includes: determining a first list according to the number of times H different values ​​corresponding to the high b bits of the parameter values ​​of the M model parameters appear in the high b-bit values ​​of the parameter values ​​of the M model parameters, wherein the arrangement order of the H different values ​​in the first list is arranged from high to low according to the number of times the H different values ​​appear in the high b-bit corresponding values ​​of the M parameter values ​​corresponding to the M model parameters, and H is an integer greater than 1; based on the number of times the first value in the first list appears, determining the number of compressed bits N, N is an integer greater than or equal to 1; based on the N-bit preset value of the first number and the N-bit position code, determining the first compressed data corresponding to the value arranged at position I in the first list; wherein the first number of preset data and the position indicated by the position code are determined in the following manner:

[0035] I mod(2 N -1) = d

[0036] rounddown(I / (2 N -1))=j;

[0037] Where mod is modulo, rounddown() is rounding down, I is the arrangement position in the first list, N is the number of compressed bits, d and j are integers greater than or equal to 0, corresponding to d=0, the first number is j-1, and the position indicated by the position code is 2 N -1, corresponding to d≠0, the first number is j, and the position indicated by the position code is d; corresponding to b being less than a, the lower ab bits of the parameter value of the model parameter and the first compressed data corresponding to the arrangement position of the upper b bits of the parameter value of the model parameter in the first list are used as the compressed model parameters of the model parameters; corresponding to b being equal to a, the first compressed data corresponding to the arrangement position of the parameter value of the model parameter in the first list are used as the compressed model parameters of the model parameters.

[0038] Exemplarily, in some embodiments of the present application, in the process of compressing model parameters, the data that needs to be compressed in the model parameters can be determined first. For example, the parameter value of the model parameter is represented by an a-bit binary number, and the compression process can only compress the high-b bits of the binary number. Exemplarily, b can be equal to a. When b=a, it indicates that all data of the parameter value of the model parameter is compressed.

[0039] It is understandable that in other embodiments, the parameter values ​​of the model parameters may be compressed starting from the lower b bits, or the parameter values ​​of the model parameters of a preset number of bits may be compressed.

[0040] When compressing a b-bit model parameter, b is a binary number that can represent a total of 2 values. b The number of occurrences of H values ​​in the values ​​corresponding to the high b-bit data of the parameter values ​​of the M model parameters is arranged from high to low to determine the first list. The arrangement position of the high b-bit data of the parameter values ​​of the model parameters in the first list is compressed, and the compressed data and the low ab-bit data are used as the compressed model parameters of the model parameters.

[0041] In the compression process, the compression is performed according to the arrangement position of the high b-bit data of the parameter value of the model parameter in the first list. The first compressed data of the high b-bit data can be represented by the preset data and position coding. A preset value can represent 2 N -1 arrangement position, then the value of the high b bits of data in the arrangement position I of the first list is divided by 2 N -1, it can be determined how many preset data are needed in the first compressed data. It can be understood that since the maximum data that d can represent is also 2 N -1, so I can divide 2 N -1, the first number of the corresponding preset data may be j-1, that is, the jth 2 N The position of -1 is represented by d. If I is not divisible by 2 N -1, the first number of preset data can be j, and the remaining positions are represented by d. In this way, the position of the parameter value of the high b-bit data in the first list can be determined based on the preset value of the first number and the position code. Then the preset value of the first number and the position code are used as the first compressed data of the high b-bit data, and the low ab-bit data of the first model parameter and the first compressed data are used as the compressed model parameters corresponding to the model parameters.

[0042] The second electronic device can store the corresponding compressed model parameters and the first list in the first electronic device after obtaining the compressed model parameters of the model parameters through the above encoding method, so that the first electronic device can decode the compressed model parameters to obtain the model parameters and run the first model when running the first model. When the first electronic device decodes the compressed model parameters and reads the compressed model parameters, it can read N bits of data each time and determine whether the N bits of data belong to the preset value. If it is the preset value, it continues to read the N bits of data until j or j-1 N bits of data are read, and then the N bits of data read are position codes. After the N bits of data read by the first electronic device are not the preset values, it can be determined that the read N bits of data are position codes. After the first electronic device reads the position code, it can determine that all the data of the compressed model parameters have been read, and then determine the position of the parameter value of the model parameter in the first list according to the j or (j-1) preset values ​​and the position code, and then determine the parameter value of the model parameter from the first list, and then complete the decompression of the compressed model parameters, obtain the parameter value of the model parameter, and run the first model.

[0043] The above-mentioned decompression process of the compressed model parameters is compressed after all the data of the compressed model parameters are read. Therefore, do not try to decompress the read data every time a compressed model parameter is read, thereby reducing unnecessary decompression processes and improving the decompression speed of the compressed model parameters.

[0044] In a third aspect, the present application provides an electronic device, the electronic device comprising: a memory for storing instructions; at least one processor for executing instructions so that the device implements the second aspect, the first aspect, and any possible implementation method of the first aspect. The beneficial effects that can be achieved in the third aspect can refer to the beneficial effects of the method provided in any implementation of the second aspect and the first aspect, and will not be repeated here.

[0045] In a fourth aspect, the present application provides a computer-readable storage medium, in which instructions are stored, and when the instructions are executed by a device, the computer implements the method provided in the second aspect, the first aspect, and any possible implementation of the first aspect. The beneficial effects that can be achieved in the fourth aspect can refer to the beneficial effects of the method provided in any implementation of the second aspect and the first aspect, and will not be repeated here.

[0046] In a fifth aspect, the present application provides a computer program product, which, when running on a device, enables the device to implement the method provided in the second aspect, the first aspect, and any possible implementation of the first aspect. The beneficial effects that can be achieved in the fifth aspect can refer to the beneficial effects of the method provided in any implementation of the second aspect and the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 A schematic diagram of deploying an artificial intelligence model on an electronic device is shown;

[0048] Figure 2 A schematic diagram of Huffman coding is shown;

[0049] Figure 3 A schematic diagram of decoding the compression model parameters of Huffman coding is shown;

[0050] Figure 4A According to some embodiments of the present application, a flowchart of an implementation of an encoding method is shown;

[0051] Figure 4B According to some embodiments of the present application, a schematic diagram of a process for encoding data to be encoded is shown;

[0052] Figure 5 According to some embodiments of the present application, a flowchart of an implementation of an electronic device running an artificial intelligence model is shown;

[0053] Fig. 6A According to some embodiments of the present application, a flowchart of an implementation of a decoding method is shown;

[0054] Figure 6B A schematic diagram of a decoding process is shown according to some embodiments of the present application;

[0055] Figure 7 According to some embodiments of the present application, a schematic diagram of framing compression model parameters is shown;

[0056] Figure 8 According to some embodiments of the present application, an encoding format of 8-bit data is shown;

[0057] Fig. 9 According to some embodiments of the present application, a schematic structural diagram of an electronic device 100 is shown. DETAILED DESCRIPTION

[0058] The illustrative embodiments of the present application include, but are not limited to, a data processing method, a readable storage medium, a program product, and an electronic device.

[0059] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0060] As described in the background, the model parameters of the artificial intelligence model deployed on the electronic device are relatively large, which will occupy a large amount of storage space of the electronic device. In some embodiments, in order to reduce the storage space occupied by the model parameters of the artificial intelligence model, the model parameters deployed on the electronic device can be quantized and compressed by using a coding method (such as Huffman coding, etc.) and then stored. When the electronic device runs the artificial intelligence model, the model parameters can be decompressed first, and then the artificial intelligence model can be run based on the decompressed model parameters.

[0061] The following describes a process for deploying an AI model for electronic devices.

[0062] For example, Figure 1 A schematic diagram of deploying an artificial intelligence model on an electronic device is shown.

[0063] It should be noted that the present application does not limit the specific form of the electronic device. The electronic device may be a mobile phone, a laptop computer, a tablet, a desktop computer, a large-screen device, a wearable device (for example, a watch, smart glasses, a helmet), an augmented reality (AR) / virtual reality (VR) device, a personal digital assistant (PDA), and the like.

[0064] For example, in some embodiments, take the deployment of an image processing model on an electronic device 100 as an example. Before the image processing model is deployed for the electronic device 100, the server 200 may encode the model parameters (hereinafter referred to as actual model parameters) in the image processing model through an encoder to obtain corresponding compressed model parameters (hereinafter referred to as compressed model parameters). Then, the compressed model parameters and the image processing model are deployed on the electronic device 100.

[0065] Before running the image processing model, the electronic device 100 can decode the compressed model parameters through a decoder to obtain corresponding actual model parameters. Then the electronic device runs the image processing model through the actual model parameters to implement the corresponding functions of the image processing model.

[0066] In some embodiments, the model parameters in the image processing model may be weight data, and the encoder may quantize and compress the weight data to generate corresponding compressed model parameters. It is understood that the space occupied by the model parameters in the image processing model is reduced after quantization and compression, so that the storage pressure of the memory of the electronic device 100 can be reduced.

[0067] In some embodiments, the encoder may use Huffman coding, thereby effectively reducing the storage space occupied by the model parameters. However, since Huffman coding is a variable-length coding (different compression model parameters have different encoding bits), it is usually necessary to check whether the currently read binary bits match a complete compression model parameter (hereinafter referred to as complete encoding data) in the Huffman tree (or Huffman table) during decompression. It can be understood that a complete encoding data is a compression model parameter obtained after an actual model parameter is Huffman encoded. That is to say, in the process of decompressing the compression model parameter, the electronic device (or the decoder of the electronic device) needs to find out from the Huffman tree whether there is an actual model parameter that matches the read binary bit data every time it reads a binary bit from the compression model parameter. Therefore, when the electronic device 100 decodes the compression model parameters based on Huffman coding compression, it needs to consume a lot of time to search the Huffman table, resulting in the electronic device 100 taking too long to decompress the model parameters, reducing the running speed of the artificial intelligence model.

[0068] For the sake of understanding, the following describes a process of encoding actual model parameters through Huffman coding to obtain compressed model parameters, and decoding the compressed model parameters.

[0069] First, the process of Huffman coding is introduced.

[0070] In the encoding process, the weight sequence table is first determined based on the frequency of occurrence of various values ​​in the actual model parameters. The higher the frequency of occurrence of a value, the higher the position of the corresponding value in the weight sequence table. For example, if the quantized model parameter is represented in 4 bits, then the model parameter has 2 4 = 16 values. Then the weight sequence table can record the order of the frequencies of the 16 values ​​appearing in the model parameters.

[0071] For example, Figure 2 A schematic diagram of Huffman coding is shown.

[0072] Reference Figure 2 , for the quantized actual model parameter "1341323141", the weight of each data item can be determined according to the frequency of occurrence of each data item. For example, there are four types of data in the actual model parameter: 1, 2, 3, 4, and the data volume is 10. Among them, the frequency of occurrence of data 1 is 4, the frequency of occurrence of data 2 is 1, the frequency of occurrence of data 3 is 3, and the frequency of occurrence of data 4 is 2. Then it can be determined that the weight of data 1 is 4 / 10=0.4, the weight of data 2 is 1 / 10=0.1, the weight of data 3 is 3 / 10=0.3, and the weight of data 4 is 2 / 10=0.2. After arranging the data according to the size of the weight, the weight sequence table A can be obtained.

[0073] Next, the process of determining the Huffman tree and the Huffman table based on the weight sequence list is introduced.

[0074] Continue to refer to Figure 2 After determining the weight sequence list, the weights of the two data arranged at the end can be added together to obtain a new weight, and then the weights can be arranged again. For example, the two data arranged at the end in weight sequence list A and the corresponding weights are data 2 (0.1) and data 4 (0.2). Then the weight after adding the weights of data 2 and data 4 is 0.3. After rearranging the weights, the weight sequence list B is obtained. Among them, data 2 and data 4 are nodes with a weight of 0.3.

[0075] Similarly, the two weights arranged at the end of weight sequence table B are added together to obtain a new weight, and then the weights are rearranged to obtain weight sequence table C. For example, weight 0.3 is added to weight 0.3 of data 3 to obtain weight 0.6, and weight 0.6 is arranged in front of weight 0.4 of data 1.

[0076] It can be understood that there are only two weights left in the weight sequence table C, and the root node can be set for these two weights to obtain the Huffman tree. After obtaining the Huffman tree, each data can be encoded. The encoding process, for example, starts from the root node, and the code is added by 0 when entering the left node, and the code is added by 1 when entering the right node. In this way, it can be determined that the Huffman code of data 1 is 1, the Huffman code of data 3 is 00, the Huffman code of data 4 is 010, and the Huffman code of data 2 is 011. Then the Huffman table of data and corresponding Huffman codes is obtained. It can be understood that in the Huffman table, the higher the weight of the data, the smaller the number of bits of the Huffman code corresponding to the data. For example, the weight of data 1 is 0.4, then the Huffman code has only 1 bit (bit), and the weight of data 2 is 0.1, and the Huffman code has 3 bits (bit). The higher the weight, the more frequent the corresponding data appears. Since the number of bits of the Huffman code of data with high weight is small, the Huffman code can reduce the size of the storage space occupied by the data.

[0077] After obtaining the Huffman table, the actual model parameter "1341323141" can be Huffman encoded, and the encoding result is: 1000101000110010101, a total of 19 bits of data. If the actual model parameter "1341323141" is stored in a 4-bit representation, the stored data is: 0001001101000001001100100011000101000001, a total of 40 bits of data. In this way, Huffman encoding can reduce the storage space occupied by the actual model parameters.

[0078] However, in the process of decoding the compression model parameters using Huffman coding, each time the electronic device reads a compression model parameter, it needs to search the Huffman table for an actual model parameter that matches the read compression model parameter, resulting in a relatively slow decoding process.

[0079] For example, Figure 3 A schematic diagram of decoding Huffman-coded compression model parameters is shown.

[0080] like Figure 3 As shown, during the decoding process, the electronic device needs to check from the Huffman table whether there is an actual model parameter that matches the compression model parameter that has been read each time it reads a compression model parameter. If so, it decodes and then continues to read the next compression model parameter for decoding. If not, it needs to continue to read the next compression model parameter and then check from the Huffman table whether the compression model parameter that has been read matches the actual model parameter. This cycle is repeated to achieve the decoding process.

[0081] For example, refer to Figure 3 , when decoding the Huffman code "10001", first read code 1, then look up the Huffman table to determine that code 1 corresponds to data 1, then decode and determine data 1. Then read code 0. If the number corresponding to code "0" cannot be found in the Huffman table, continue to read the next code, that is, code 0. At this time, the code that has been read is "00", then look up whether there is data corresponding to "00" in the Huffman table. For example, the data corresponding to "00" in the Huffman table is data 3, then "00" can be decoded to determine data 3, and then continue to read the next code, that is, code 0. If there is no data corresponding to code "0" in the Huffman table, continue to read code 1. If there is no data corresponding to "01" in the Huffman table, continue to read the next data until the decoding is completed.

[0082] It can be understood that in the above decoding process, the electronic device needs to look up the Huffman table every time it reads one compression model parameter. Therefore, when decoding, looking up the Huffman table takes up a lot of time, resulting in a high decoding delay.

[0083] In order to improve the decoding efficiency, an embodiment of the present application provides a data processing method. In the process of decoding the compressed model parameters corresponding to the actual model parameters, after reading the complete encoded data corresponding to an actual model parameter, the actual model parameter corresponding to the complete encoded data can be determined from a lookup table (as an example of the first list) (used to store the correspondence between a complete encoded data and the corresponding actual model parameter in the lookup table), without comparing the lookup table every time a compressed model parameter is read, thereby reducing the number of times the lookup table is compared and improving the decoding efficiency.

[0084] Specifically:

[0085] In the process of compressing the actual model parameters, the electronic device may first determine various values ​​of the actual model parameters (for example, the actual model parameters are represented by a-bit binary numbers, and the values ​​are 2 a The frequency of occurrence of various values ​​(of various kinds) is obtained according to the frequency of occurrence of various values, and various values ​​are obtained according to the order of occurrence frequency from high to low to obtain a first sequence table (as an example of a lookup table and a first list). Then, according to the list position of various values ​​of the actual model parameters in the first sequence table, the actual model parameters are encoded.

[0086] For example, in some embodiments, a may be the number of bits of the actual model parameter represented in binary form. For example, if the actual model parameter is represented in 4-bit binary form, a=4. In other embodiments, it may be a preset number of bits, for example, when the actual model parameter is represented in 8-bit binary form, a=8, and data with half the number of bits of 8 bits may be selected for compression, that is, 4 bits (as an example of b).

[0087] In some embodiments, the types of values ​​of the actual model parameters can also be determined based on the specific numerical values ​​of the actual model parameters. For example, when the actual model parameters are represented in 4-bit binary, there are 16 values ​​in total, but only 10 values ​​appear among all the numerical values ​​of the actual model parameters. In this case, only 10 data can be arranged in the first sequence table.

[0088] It can be understood that the first sequence table stores the correspondence between various values ​​of the actual model parameter and the position information of the value in the first sequence table. For example, for a value s of the actual model parameter, the first sequence table can store s and the position information of s in the first sequence table.

[0089] When encoding a numerical value in the actual model parameter, the position information of the numerical value in the first sequence list can be encoded to obtain a complete coded data. When the complete coded data is decoded, the obtained data is also the position information corresponding to an actual model parameter. According to the position information, the corresponding actual model parameter can be determined from the first sequence list. In other words, the numerical value of the actual model parameter corresponds to the position information of the numerical value in the first sequence list, and the encoding process is essentially the encoding of the position information. Therefore, the data corresponding to a complete coded data is the position information, and the corresponding actual model parameter can be determined according to the corresponding relationship between the position information and the actual model parameter (i.e., the first sequence list).

[0090] In the process of encoding the location information of the actual model parameters:

[0091] For example, in the actual model parameters, the position information of a piece of data to be encoded corresponds to a complete coded data with k×N bits. The higher the frequency of the data to be encoded in the actual model parameters (i.e., the earlier the position in the first sequence table), the smaller the corresponding k value. Among them, the last N bits of the complete coded data corresponding to a piece of data to be encoded are the position code (indicating 2 N -1 position), the data except the last N bits is the coding prefix. The position code and k can be used to determine the position of the to-be-coded data corresponding to the complete coded data in the first sequence table.

[0092] In some embodiments, the value represented by the N-bit binary number can have 2 N Each N bits of data in the encoding prefix can be 2 N The same preset value (hereinafter referred to as the preset prefix) in the values ​​​​can be 2 N For example, taking N=2 as an example, the values ​​corresponding to the 2-bit binary code are 2 2 =4, namely 00, 01, 10, 11, any one of 00, 01, 10, 11 can be used as the preset prefix (the following takes the preset prefix 11 as an example). If the complete coded data corresponding to the data to be coded has 6 bits, that is, k=3, then the value corresponding to the first (3-1)×2=4 compressed bits is the coding prefix, which is composed of two identical preset prefixes 11, that is, the coding prefix is ​​1111.

[0093] During the decoding of compressed model parameters:

[0094] In the process of decoding the compression model parameters, the electronic device reads N bits of data from the compression model parameters each time. When the read N bits of data are a preset prefix (indicating that the data read is data in the coding prefix), the electronic device continues to read N data until the read N bits of data are not the preset prefix (indicating that a complete coded data has been read). When the read N bits of data are not the preset prefix (indicating that the read N bits of data are position coded), the electronic device can determine the position information corresponding to the complete coded data based on the N bits of data and the corresponding coding prefix (the continuous preset prefix before the N bits of data), and determine the corresponding actual model parameters from the first sequence table based on the position information.

[0095] In this way, after acquiring a complete encoded data, the electronic device can decode the complete encoded data to obtain the position information, and then obtain the actual model parameters corresponding to the position information from the first sequence table, without having to search the first sequence table once every time a compressed model parameter is acquired to determine whether there is an actual model parameter that matches the compressed model parameter that has been read, thereby improving the decoding speed.

[0096] For example, in the decoding process, the position information corresponding to the complete coded data can be determined based on the kth and kth N-bit data in the complete coded data. The position information is the position value represented by the position code plus the position value represented by the code prefix (k-1)×(2 N -1), where the position information corresponds to the position value. It can be understood that in the N-bit binary code 2 N Among the preset representations in the representation, one representation is used to represent the preset prefix, and the remaining 2 N -1 position code is used to indicate the position value, where each preset prefix can represent the position value (2 N -1). It can be understood that since the position code can indicate 2 N -1 position value, if the position value corresponding to the position information exceeds 2 N -1, the position code alone cannot indicate the complete position information, so the position value corresponding to the position information exceeds 2. N -1 once, can be indicated by a coding prefix, so a coding prefix can indicate 2 N -1 position value. That is to say, the position information corresponding to a complete coded data is the sum of the position value represented by the coding prefix and the position code.

[0097] For example, in 2-bit binary code 2 2 In this representation, 11 is used to represent the preset prefix, and the position code can be 00, 01, 10, that is, it can be used to represent three position values. For example, the position value that 00 can represent is 1, the position value that 01 can represent is 2, and the position value that 10 can represent is 3. If the position code of a complete coded data is 01, it can be determined that the position value represented by 01 is 2, and the position value corresponding to the position information of the actual model parameter corresponding to the complete coded data 111101 in the first sequence table is 2+(3-1)×(2 2 -1)=8, that is, the position information is the 8th position in the first sequence list. In other words, the data corresponding to the 8th position in the first sequence list is the actual model parameter.

[0098] It can be understood that during the decoding process, each time an N-bit compression model parameter is read, if the N-bit compression model parameter is a preset prefix, the N-bit compression model parameter continues to be read until the k-th N-bit compression model parameter read is not the preset encoding prefix, then the read k×N conversion position information is converted, and the actual model parameter is determined from the first sequence table based on the position information.

[0099] In some embodiments, during the encoding process, the number of compressed bits N can be determined based on the ratio of the number of occurrences of the data to be encoded with the largest number of occurrences to the total number of all the data to be encoded in the actual model parameters. For example, the number of occurrences of the data to be encoded A is the highest, which is n times. There are M data to be encoded in the actual model parameters, and the number of compressed bits N can be obtained according to formula (1) and formula (2):

[0100] data_prob=n / M (1)

[0101] Among them, data_prob is the probability of occurrence of the data A to be encoded, n is the number of times the data A to be encoded appears, and M is the total number of data to be encoded in the actual model parameters.

[0102] N=roundup(-log2(data_prob)) (2)

[0103] Where N is the number of compressed bits, roundup() is rounding up, and data_prob is the probability of occurrence of the data A to be encoded. Formula (2) is information entropy, also known as Shannon information entropy, which is used to measure the uncertainty of information or the amount of information. The higher the information entropy, the greater the uncertainty of the information, and the longer the average length of the required code. According to information entropy theory, the optimal number of bits to encode a data is -log2(P), where P is the probability of occurrence of the data. For example, if the probability of occurrence of the data A to be encoded is data_prob, then N bits can be used to encode the data A to be encoded, that is, the number of compressed bits N can be determined based on the ratio of the data to be encoded that appears the most times to the total number of all the data to be encoded.

[0104] It can be understood that in the process of encoding the position information of the actual model parameters, the position value corresponding to the position information exceeds 2 N -1 once, can be indicated by a code prefix, the remaining position value does not exceed 2 N -1 can be represented by positional encoding.

[0105] For example, the data to be encoded is in the form of 4 bits and the number of compressed bits N is 2. The representation of 4 bits of data has a total of 2 4 = 16, and the maximum data that can be represented by a 2-bit compression bit in binary form is 4, so it can be determined that every 3 position values ​​are represented by a preset prefix, so the first sequence table can be divided into 6 levels. Among them, there are 0 preset prefixes in the first level, 1 preset prefix in the second level, 2 preset prefixes in the third level, 3 preset prefixes in the fourth level, 4 preset prefixes in the fifth level, and 5 preset prefixes in the sixth level. The position value represented by each preset prefix is ​​22 -1=3. It can be understood that in some other embodiments, if the number of compressed bits is 3, then every 7 position values ​​in the first sequence table can be regarded as a level, and the position value represented by each preset prefix is ​​7.

[0106] Exemplarily, the preset prefix can be selected from any one of the forms of N-bit binary representation. For example, when the number of compressed bits N=2, 11 is selected as the coding prefix. Taking the first sequence table from 0 to 15 as an example, which can be divided into 6 levels, the coding prefix of the first level can be 0 "11", that is, there is no coding prefix, only position coding, corresponding to positions 0 to 2. The coding prefix of the second level can be 1 "11", corresponding to positions 3 to 5, and the coding prefix of the third level can be 2 "11", that is, "1111", corresponding to positions 6 to 8. The coding prefix of the fourth level can be 3 "11", that is, "111111", corresponding to positions 9 to 11. The coding prefix of the fifth level can be 4 "11", that is, "11111111", corresponding to positions 12 to 14. The coding prefix of the sixth level can be 5 "11", that is, "1111111111", corresponding to the position 15.

[0107] Similarly, when the number of compressed bits is 3, the first level still has no coding prefix, corresponding to positions 0 to 6, the second level coding prefix is ​​"111", corresponding to positions 7 to 13, and the third level coding prefix is ​​"111111", corresponding to positions 14 and 15. It can be understood that the reason why the coding prefix is ​​determined based on the number of compressed bits is because the data decoding is read in units of the number of compressed bits during the decoding process. For example, when the number of compressed bits is 2, during the decoding process, two digits are read each time. If the two digits read are 11, it can be determined that the preset prefix is ​​read, and it is necessary to continue reading two bits of binary data until the two bits read are no longer 11, then it can be determined that the position code is read, and then the electronic device can determine that a complete coded data has been read, and the corresponding actual model parameters can be determined from the first sequence table.

[0108] It can be understood that, corresponding to the 4-bit encoding format, when the number of compressed bits N is 2, the number of bits of the complete encoded data corresponding to the first 3 bits of the to-be-encoded data in the first sequence table is only two, that is, there is no encoding prefix but only position encoding. And the frequency of occurrence of these three data is the highest, that is, the proportion of complete encoded data with only two bits is the largest. Therefore, compared with the 4-bit form of data representation, the overall storage space occupied by the compression model parameters of this scheme is smaller.

[0109] It can be understood that if the frequency of occurrence of various values ​​in the first sequence table is not much different, the calculated compression bit N may be 3. In this case, the position code has 23 -1=7 representation forms, then the number of bits of the complete encoded data corresponding to the first 7 bits of the data to be encoded in the first sequence table is only 3 bits, that is, the 7 types of data have no encoding prefix. In this way, when the frequency of occurrence of each data in the first sequence table is not much different, the proportion of the data to be encoded with only position encoding can also be increased, thereby reducing the storage space occupied by the encoding form of less than 4 bits.

[0110] In some embodiments, during the decoding process, the compression model parameters may be divided into multiple frames of data with a plurality of bits as one frame. During the decoding process, the electronic device may decode multiple frames of data simultaneously, further improving the decompression speed of the compression model parameters.

[0111] The following introduces the encoding methods proposed in some embodiments of the present application.

[0112] For example, Figure 4A According to some embodiments of the present application, a flowchart for implementing an encoding method is shown.

[0113] It can be understood that in some embodiments of the present application, the encoding method can be deployed in encoding devices such as servers. It should be noted that the encoding device in the embodiments of the present application can be called a terminal, a user terminal, a mobile terminal, a user equipment (UE), a terminal device, a mobile station, a mobile terminal (MT), etc. The terminal device can be a mobile phone, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc., which can encode the actual model parameters of the artificial intelligence model. It can be understood that the execution subjects of the following processes are all encoding devices. When introducing the following processes, the execution subjects of each process are not limited.

[0114] like Figure 4A As shown, the process includes:

[0115] S410, determining a first sequence table and a compression bit number N based on the frequencies of occurrence of various values ​​in the actual model parameters.

[0116] For example, in some embodiments of the present application, the frequencies of occurrence of various data to be encoded in the actual model parameters can be counted. Then, the first sequence table and the number of compressed bits are determined according to the frequencies of occurrence of various data to be encoded. The higher the frequency of occurrence of the data to be encoded, the closer the position in the first sequence table is, and the smaller the corresponding number of compressed bits.

[0117] For example, Figure 4B According to some embodiments of the present application, a schematic diagram of a process for encoding data to be encoded is shown.

[0118] like Figure 4B As shown, for each data to be encoded in the actual model parameters [0, 2, 1, 14, 0, 1, 15, 12, 0, 3, 12, 8, 1, 0, 2, 1, 0, 2, 3, 1, 4, 1, 0, 2, 3, 1, 0, 2, 1, 3, 0], the frequency of occurrence of various data to be encoded in the actual model parameters is counted to obtain a frequency table, and then the data are sorted according to the frequency of occurrence to obtain a first sequence table [1, 0, 2, 3, 15, 14, 12, 8, 4, 13, 11, 10, 9, 7, 6, 5].

[0119] It can be understood that there are still data to be encoded with a frequency of 0 in the first sequence table, which means that the corresponding data to be encoded does not appear in the actual model parameters. Figure 4B In the embodiment, the actual model parameters are as follows: the first sequence table only includes the to-be-encoded data that have appeared, and the to-be-encoded data with an appearance frequency of 0 can be discarded.

[0120] Then, the encoding device can determine the compression bit table based on the frequency of occurrence of each data in the first sequence table based on equations (1) and (2). In the compression bit table, the compression bit with the smallest value is the compression bit number N for encoding the data to be encoded this time, that is, N=2.

[0121] Taking the data 0 to be encoded as an example, the frequency of the data 0 to be encoded is 9, then according to formula (1), data_prob = 9 / 32 = 0.28125. According to formula (2), it can be determined that -log2(0.28125) = 1.8301, and then 1.8301 can be rounded to the nearest integer to determine bits = 2. Similarly, it can be determined that the number of compressed bits corresponding to the data 1 to be encoded is 2, the number of compressed bits corresponding to the data 2 to be encoded is 3, the number of compressed bits corresponding to the data 3 to be encoded is 3, and the number of compressed bits corresponding to the data 15 to the data 4 to be encoded is 5.

[0122] S420, obtaining compression model parameters based on the position information of the to-be-encoded data of the actual model parameters in the first sequence table, the number of compressed bits, and the preset prefix.

[0123] Exemplarily, in some embodiments of the present application, the encoding device may determine the complete encoded data corresponding to the data to be encoded based on the position information of the data to be encoded in the first sequence list (for example, the position of the data to be encoded in the first sequence list).

[0124] For example, after determining that the number of compressed bits N=2, it can be determined that the 2-bit compressed bit number has four representation forms: 00, 01, 10, and 11. Then, one representation form can be selected from the four representation forms as a preset prefix, and each preset prefix can represent a position value of 3. For example, in this embodiment, 11 is selected as the preset prefix, and the remaining three representation forms are position codes. For example, the position value corresponding to 00 is 1, the position value corresponding to 01 is 2, and the position value corresponding to 10 is 3.

[0125] Continue to refer to Figure 4B According to the position information of the data to be encoded in the first sequence table, it can be determined how many preset prefixes are needed for the position value corresponding to the position information in addition to being represented by the position code, and then the corresponding preset prefix is ​​added to the position value of the position information to generate a coding prefix, and the coding prefix and the position code are used as the complete coding data corresponding to the position information.

[0126] For example, for the data to be encoded 0, it is located in the second position in the first sequence table (that is, the position information is 2), and the corresponding position value is 2, and the position code can represent 3 position values. Therefore, the position corresponding to the data to be encoded 0 can be fully represented by the position code, that is, the position code is 01, and there is no need to add a coding prefix to the data to be encoded 0.

[0127] For the data to be encoded 8, which is located at the eighth position in the first sequence table, the corresponding position value is 8. The position code can represent 3 position values, so two preset prefixes are required to represent the position value of the data to be encoded 8. The position value represented by one preset prefix is ​​3, the position value represented by two preset prefixes is 6, and the remaining two position values ​​are represented by the position code, that is, the position code is 01. Therefore, the complete encoded data corresponding to the data to be encoded 8 is 111101.

[0128] Through the above encoding method, data at any position in the first sequence table can be encoded to obtain complete encoded data indicating position information. After encoding of each data to be encoded in the actual model parameters is completed, the corresponding compression model parameters can be obtained.

[0129] It can be understood that in other embodiments, the number of compression bits can also be other values, and the corresponding position code and preset prefix can also be expressed in different forms. The embodiments of the present application do not limit the form of the number of compression bits, position code and preset prefix.

[0130] It can be understood that in some embodiments of the present application, after the server or encoding device completes the encoding of the actual model parameters of the artificial intelligence model, the corresponding compressed model parameters can be sent to the electronic device, and the compressed model parameters occupy less storage space of the electronic device, thereby reducing the storage pressure of the electronic device. Before running the artificial intelligence model, the electronic device needs to decode the compressed model parameters to obtain the corresponding actual model parameters. The following introduces a process of running an artificial intelligence model by an electronic device.

[0131] For example, Figure 5 According to some embodiments of the present application, a flowchart for implementing an electronic device running an artificial intelligence model is shown.

[0132] It can be understood that in some embodiments of the present application, the artificial intelligence model can be deployed on an electronic device. It should be noted that the electronic device in the embodiments of the present application can also be referred to as a terminal, a user terminal, a mobile terminal, a user equipment (UE), a terminal device, a mobile station, a mobile terminal (MT), etc. The terminal device can be a mobile phone, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in a smart grid, a wireless terminal in transportation safety, a wireless terminal in a smart city, a wireless terminal in a smart home, etc., which can deploy an artificial intelligence model.

[0133] It can be understood that the executors of each of the following processes are electronic devices configured with artificial intelligence models. When introducing the following processes, there is no limitation on the executors of each process.

[0134] like Figure 5 As shown, the process includes:

[0135] S501: Detect an instruction to run a first model.

[0136] Exemplarily, in some embodiments of the present application, an artificial intelligence model is configured in the electronic device, and the artificial intelligence model may be, for example, an image processing model (for example, for optimizing the clarity of an image or extracting subjects such as people, animals, buildings, vehicles, and scenery in an image), an audio processing model (for example, for reducing the noise of audio, identifying information in audio, generating audio, etc.), etc. The electronic device may detect that the user has started an operation of the first model and is ready to run the first model.

[0137] S502: Obtain the corresponding compressed model parameters of the first model, and decode the compressed model parameters to obtain model parameter values ​​corresponding to the actual model parameters.

[0138] For example, in some embodiments of the present application, when deploying an artificial intelligence model for an electronic device, in order to reduce the storage pressure of the electronic device, the actual model parameters corresponding to the artificial intelligence model can be quantized and compressed, thereby reducing the storage space occupied by the actual model parameters, and a corresponding decoder can be deployed in the electronic device. After the electronic device detects an instruction to run the artificial intelligence model, the compressed model parameters corresponding to the actual model parameters can be decoded based on the decoder.

[0139] It can be understood that the encoding process can refer to Figure 4A The encoding process in the corresponding embodiment.

[0140] Exemplarily, during the encoding process, the encoding device can determine the first sequence table and the number of compressed bits based on the frequency of occurrence of each to-be-encoded data in the actual model parameters, and then perform encoding based on the number of compressed bits according to the position of each to-be-encoded data in the first sequence table, thereby obtaining the complete encoded data of the to-be-encoded data. After encoding of each to-be-encoded data in the actual model parameters is completed, the compressed model parameters corresponding to the actual model parameters can be obtained.

[0141] Exemplarily, during the decoding process, the electronic device may decode a complete coded data after reading the compressed model parameters, obtain the position information corresponding to the complete coded data, and then determine the corresponding actual model parameters from the first sequence table based on the position information.

[0142] For example, Fig. 6A According to some embodiments of the present application, a flowchart of an implementation of a decoding method is shown.

[0143] It can be understood that the execution subject of each of the following processes is an electronic device, and when introducing the following processes, there is no limitation on the execution subject of each process.

[0144] like Fig. 6A As shown, the process includes:

[0145] S502A, read N-bit compression model parameters.

[0146] It can be understood that since the complete coded data corresponding to the data to be coded consists of k×N bits of data, the electronic device can read N bits of compression model parameters each time during the decoding process of the data to be coded for subsequent decoding, which can also increase the speed of reading the compression model parameters.

[0147] For example, Figure 6B A schematic diagram of a decoding process is shown according to some embodiments of the present application.

[0148] like Figure 6B As shown, for example, taking the actual model parameter as a 4-bit encoding form as an example (i.e., a=4), there are 16 types of data that can be represented by the 4-bit encoding form, and the first sequence table determined according to the frequency of occurrence of each to-be-encoded data in the actual model parameter is [1, 0, 2, 3, 15, 14, 18, 8, 4, 13, 11, 10, 9, 7, 6, 5]. In other words, the frequency of occurrence of the to-be-encoded data 1 is the highest, and the frequency of occurrence of the to-be-encoded data 5 is the lowest.

[0149] The corresponding compression model parameters are 011000111001, etc. In this embodiment, taking the compression bit number N=2 as an example, 2 bits of compression model parameters can be read each time during the decoding process.

[0150] It can be understood that in other embodiments, the number of compressed bits N can also be other data, and the embodiments of the present application do not limit the number of compressed bits.

[0151] S502B, determining that the read compression model parameter is a complete encoding data.

[0152] It can be understood that the last N bits of the complete coded data corresponding to the data to be coded are the position code, so the electronic device can determine whether the complete coded data corresponding to the data to be coded has been read based on whether the position code is read. Then the position code and the read code prefix are determined as the complete coded data corresponding to the data to be coded.

[0153] Exemplarily, in some embodiments of the present application, the preset prefix is ​​set to 11. If the electronic device only reads 2 compressed bits that are not 11, it means that the position code has been read, and it can be determined that the read encoded data is a complete encoded data corresponding to the data to be encoded.

[0154] For example, continue to refer to Figure 6B, the 2-bit code read by the electronic device for the first time is 01, then it can be determined that 01 is a position code, that is, the compression model parameter 01 that has been read is a complete encoding data corresponding to the data to be encoded, and 01 can be decoded by looking up the table. Then the electronic device can continue to read 2-bit data, for example, the 2-bit compression model parameter that continues to be read is 10, which is also a position code, and the electronic device can look up the table to decode 10. The 2-bit compression model parameter that the electronic device continues to read is 00, which is a position code, and 00 can be decoded by looking up the table.

[0155] S502C, determining that the read compression model parameter is not a complete encoding data.

[0156] Exemplarily, in some embodiments of the present application, if the N-bit data currently read by the electronic device is a preset prefix, it can be determined that the compression model parameters currently read by the electronic device are not a complete encoded data, and the electronic device needs to go to S502A to continue reading the N-bit compression model parameters.

[0157] For example, continue to refer to Figure 6B , the electronic device continues to read a 2-bit compression model parameter of 11, which is a preset prefix. The electronic device does not need to perform table lookup decoding, but continues to read the 2-bit compression model parameter. The 2-bit compression model parameter continued to be read is 10. The electronic device can determine that the read compression model parameter 1110 is a complete encoded data corresponding to the data to be encoded, and the electronic device can perform table lookup decoding on 1110.

[0158] S502D, determine the actual model parameters corresponding to the complete encoded data from the lookup table.

[0159] Exemplarily, during the decoding process, after the electronic device determines the complete coded data of a data to be coded, it can determine the position of the data to be coded in the first sequence table based on the coding prefix and the position coding of the complete coded data.

[0160] It can be understood that the number of bits of the complete coded data corresponding to a data to be coded is k×N, of which the first (k-1)×N bits of data are the coding prefix, which is composed of k-1 preset prefixes. The fewer the number of preset prefixes (the smaller k), the smaller the number of bits of the complete coded data corresponding to the data to be coded. The position value represented by a preset prefix is ​​2 N -1, therefore, the fewer the preset prefixes, the earlier the position of the data to be encoded in the first sequence list. The position information of the data to be encoded in the first sequence list is the position value corresponding to the position code + the position value corresponding to the preset prefix (k-1) × (2 N -1).

[0161] For example, refer to Figure 6B, when N=2, 11 is the preset prefix, then 00, 01, and 10 are used to represent three position values, respectively. In an embodiment of the present application, 00 is used to represent a position value of 1, 01 is used to represent a position value of 2, and 10 is used to represent a position value of 3. Then the position value corresponding to the read complete encoded data 01 after decoding is 2, corresponding to the second position in the first sequence table, which is data 0. Similarly, the position value corresponding to the complete encoded data 10 after decoding is 3, and the data corresponding to the third position in the first sequence table is data 2. The position value of the complete encoded data 00 after decoding is 1, and the data corresponding to position 1 in the first sequence table is data 1. The position value of the complete encoded data 1110 after decoding is 3+(2-1)×3=6, then the corresponding position in the first sequence table is 6, and the corresponding data is 14.

[0162] For example, in some embodiments, 00 can be used as a preset prefix, the position value corresponding to 01 is 1, the position value corresponding to 10 is 2, and the position value corresponding to 11 is 3. Then the position value corresponding to the complete coded data 000011 is 3+(3-1)×3=9, which corresponds to the 9th data in the first sequence table, that is, data 4.

[0163] In some other embodiments, the number of compressed bits is 3, and 111 is used as a preset prefix, 000 is used to represent the position data as 1, and then the binary bits are incremented by 1 one by one, and the position values ​​represented by the corresponding position-coded binary numbers are also incremented by 1 one by one. That is, the position value corresponding to 001 is 2, and the position value corresponding to 110 is 7. The k corresponding to the complete coded data 111010 is 2, and the position value corresponding to the position code 010 is 3. Then the position value of the data to be coded corresponding to the complete coded data 111010 in the first sequence list is 3+(2-1)×(2 3 -1)=10, that is, the data to be encoded is the 10th bit in the first sequence table, which is 13.

[0164] In some embodiments, the electronic device may also generate a corresponding coding prefix table according to the number of preset prefixes in the coding prefix, and the coding prefix table records the position value represented by each coding prefix. For example, taking N=2 as an example, the coding prefix table class_table is [3, 3, 3, 3, 3]. When the electronic device reads the compression model parameters, the count may be increased by 1 each time a preset prefix is ​​read. When determining the position of the to-be-encoded data corresponding to the complete encoded data in the first sequence table, the position may be determined by formula (3).

[0165]

[0166] Among them, lut indis the position information of the data to be encoded in the first sequence table, offset is the position value represented by the position code, level is the count of the preset prefix, and class_table is the encoding prefix table.

[0167] Taking the complete coded data as 1110 as an example, it can be determined that the level corresponding to 1110 is 1, and the offset is 3. Then the lut corresponding to 1110 is ind 3+3=6. That is, the sixth bit of data in the first sequence table is 14.

[0168] S502E, determine whether the compression model parameters have been read.

[0169] For example, in some embodiments of the present application, after the electronic device determines the actual model parameters corresponding to a complete encoded data, it can first determine whether the compressed model parameters have been read.

[0170] If the judgment result is yes, the decoding of the compressed model parameters is completed, so that the artificial intelligence model is run based on the decoded actual model parameters.

[0171] If the judgment result is no, then S502A is executed to read the N-bit compression model parameter, thereby continuing to add code to the compression model parameter.

[0172] It can be understood that through the above decoding process, the electronic device can read N bits of data each time, thereby improving the speed of reading the compression model parameters, and after the electronic device reads the compression model parameters each time, it is not necessary to search from the first sequence table whether there is a complete encoded data corresponding to the corresponding actual model parameter that matches the read compression model parameter. Instead, the electronic device only looks up the table after reading the complete encoded data corresponding to one of the data to be encoded in the actual model parameter each time. Therefore, the process of the electronic device looking up the table can be reduced, further improving the decoding speed of the electronic device.

[0173] S503: Run the first model based on the model parameter values ​​of the actual model parameters.

[0174] Illustratively, in some embodiments of the present application, after the electronic device completes decoding of the compressed model parameters, it can obtain actual model parameter values ​​of the actual model parameters, thereby running the first model based on the actual model parameter values ​​to implement the functions corresponding to the first model.

[0175] Through the above-mentioned process of configuring the artificial intelligence model, the electronic device does not need to store the complete actual model parameters corresponding to the artificial intelligence model, but stores the compressed model parameters after the encoding device encodes the actual model parameters. Therefore, the compressed model parameters will not take up much storage space of the electronic device, thereby reducing the storage pressure of the electronic device. In addition, in the process of decoding the compressed model parameters, the electronic device does not need to compare whether a complete encoded data has been read from the lookup table every time a compressed model parameter is read, thereby improving the decoding speed of the electronic device, and then improving the speed of the electronic device running the artificial intelligence model.

[0176] In some electronic devices, when encoding actual model parameters, the compressed model parameters can be divided into a frame according to a preset number of bits, thereby dividing the compressed model parameters into multiple frames. The electronic device can simultaneously decode multiple frames of compressed model parameters in parallel to further improve the decoding speed.

[0177] The following describes the process of parallel decoding by electronic devices.

[0178] For example, Figure 7 According to some embodiments of the present application, a schematic diagram of framing compression model parameters is shown.

[0179] like Figure 7 As shown, in the process of encoding the compression model parameters, the compression model parameters can be divided into one frame according to the preset number of frames. In this way, when decoding the compression model parameters, multiple frames of data can be decoded at the same time.

[0180] For example, in some embodiments of the present application, 256 bits of data are used as a frame, wherein the identification bit is used to indicate how many bits of data in the frame cannot be decoded. In some embodiments, the identification bit can be 5 bits of data. In other words, if 256 bits of data are used as a frame, then 251 bits of data in the 256 frames of data are compression model parameters.

[0181] It is understandable that the compression model parameters at the end of the 251-bit data of each frame may not constitute a complete compression model parameter. Figure 7 , in the Lth compression model parameter, the tail data is 1111, where 11 is a preset prefix. That is to say, the tail of the Lth compression model parameter only has at least a part of the coding prefix, and it cannot be decoded through the at least part of the coding prefix. Therefore, the bits that cannot be decoded at the tail of the Lth frame can be placed in the cache. When the electronic device decodes the compression model parameters of the L+1th frame, the tail of the Lth frame is read from the cache, and the entire decoding process can be completed in combination with the compression model parameters of the head of the L+1th frame (except the identification bit). In other words, the currently decoded data is the compression model parameters of the tail of the previous frame and the compression model parameters of the current frame except the tail data.

[0182] For example, the compression model parameter at the end of the Lth frame is 1111. Combined with the compression model parameter 00 at the head of the L+1th frame, it can be determined that the complete compression model parameter is 111100, corresponding to the data at the 7th position in the first sequence table.

[0183] In this way, the electronic device can read the compression model parameters of different frames simultaneously through multiple processors, thereby decoding the compression model parameters in parallel, further improving the decoding speed.

[0184] Next, the process of encoding high-bit data is introduced.

[0185] For example, Figure 8 According to some embodiments of the present application, an encoding format of 8-bit data is shown.

[0186] It can be understood that in some embodiments, the actual model parameters of the artificial intelligence model can be represented in the form of 8 bits. Since the effective values ​​of the actual model parameters of 8 bits are concentrated in the upper 4 bits, the lower 4 bits are relatively evenly distributed, and the compression effect on the lower 4 bits is poor. Therefore, when compressing 8-bit data, only the upper 4 bits (as an example of the upper b bits) can be compressed, and the lower 4 bits are directly inserted after the compressed upper 4 bits of the data stream. Figure 8 In a frame of data, the beginning part can be an identification bit, and the compressed high 4-bit data can be inserted after the low 4-bit data. In the decoding process, after reading the 4-bit data, it can be determined to start reading the high 4-bit compressed data. After reading the complete compressed data, decoding can be performed, and then 4-bit data is read as the low 4 bits, and then the compressed data corresponding to the high 4 bits is read, and then decoding is performed.

[0187] It is understood that in other embodiments, it is also possible to compress part of the parameter value of the actual model parameter starting from the low bit number, or compress part of the parameter value of the model parameter at the preset position. The embodiments of the present application do not limit the number of compressed bits and positions of the data of the actual model parameter.

[0188] The electronic devices involved in the above embodiments are introduced below.

[0189] For example, Fig. 9 According to some embodiments of the present application, a schematic structural diagram of an electronic device 100 is shown.

[0190] The electronic device 100 can be used to implement the test case generation method provided in the aforementioned embodiments.

[0191] like Fig. 9As shown, the electronic device 100 includes one or more processors 101, a system memory 102, a non-volatile memory (NVM) 103, a communication interface 104, an input / output device 105, and a system control logic 106 for coupling the processor 101, the system memory 102, the non-volatile memory 103, the communication interface 104 and the input / output (I / O) device 105. Among them:

[0192] The processor 101 may include one or more processing units, for example, a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processor (DSP), a microprocessor (MCU), an artificial intelligence (AI) processor or a programmable logic device (field programmable gate array, FPGA), a neural network processor (neural-network processing unit, NPU), etc. The processing module or processing circuit may include one or more single-core or multi-core processors. In some embodiments, the CPU can be used to optimize the neural network model to be run, and the NPU can be used to run the neural network model to be run. For example, a decoder can be configured in the CPU to decompress each compressed model parameter in the neural network model.

[0193] The system memory 102 is a volatile memory, such as a random-access memory (RAM), a double data rate synchronous dynamic random access memory (DDR SDRAM), etc. The system memory is used to temporarily store data and / or instructions. For example, in some embodiments, the system memory 102 can be used to store the aforementioned compression model parameters and the first sequence table, etc., and can also be used to store the instructions of the encoding method or decoding method provided in the aforementioned embodiments.

[0194] The non-volatile memory 103 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. In some embodiments, the non-volatile memory 103 may include any suitable non-volatile memory such as flash memory and / or any suitable non-volatile storage device, such as a hard disk drive (HDD), a compact disc (CD), a digital versatile disc (DVD), a solid-state drive (SSD), etc. In some embodiments, the non-volatile memory 103 may also be a removable storage medium, such as a secure digital (SD) memory card, etc. In other embodiments, the non-volatile memory 103 may be used to store instructions of the encoding method or decoding method provided in the aforementioned embodiments.

[0195] In particular, the system memory 102 and the non-volatile memory 103 may respectively include: a temporary copy and a permanent copy of the instruction 107. The instruction 107 may include: when executed by at least one of the processors 101, the electronic device 100 implements the encoding method or decoding method provided in each embodiment of the present application.

[0196] The communication interface 104 may include a transceiver for providing a wired or wireless communication interface for the electronic device 100, and then communicating with any other suitable device through one or more networks. In some embodiments, the communication interface 104 may be integrated into other components of the electronic device 100, for example, the communication interface 104 may be integrated into the processor 101. In some embodiments, the electronic device 100 may communicate with other devices through the communication interface 104, for example, the electronic device 100 may obtain coded data from other devices through the communication interface 104.

[0197] The input / output (I / O) device 105 may include input devices such as a keyboard, a mouse, etc., and output devices such as a display, etc. A user may interact with the electronic device 100 through the input / output (I / O) device 105 .

[0198] System control logic 106 may include any suitable interface controller to provide any suitable interface with other modules of electronic device 100. For example, in some embodiments, system control logic 106 may include one or more memory controllers to provide interfaces to system memory 102 and non-volatile memory 103.

[0199] In some embodiments, at least one of the processors 101 may be packaged together with the logic of one or more controllers for the system control logic 106 to form a system in package (SiP). In other embodiments, at least one of the processors 101 may also be integrated with the logic of one or more controllers for the system control logic 106 on the same chip to form a system-on-chip (SoC).

[0200] Understandably, Fig. 9 The structure of the electronic device 100 shown is only an example. In other embodiments, the electronic device 100 may include more or fewer components than shown, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0201] It is understandable that the electronic device 100 can be any electronic device, including but not limited to a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, etc., and the embodiments of the present application are not limited thereto.

[0202] The embodiments of the present application also provide a program product, which, when executed on an electronic device, can enable the electronic device to implement the methods provided in the aforementioned embodiments.

[0203] An embodiment of the present application further provides a readable storage medium, in which one or more programs are stored. When the one or more programs are executed by an electronic device, the electronic device implements the methods provided in the aforementioned embodiments.

[0204] The various embodiments of the mechanism disclosed in the present application can be implemented in hardware, software, firmware or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device and at least one output device.

[0205] Program code can be applied to input instructions to perform the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor, a microcontroller, an application specific integrated circuit, or a microprocessor.

[0206] Program code can be implemented with high-level programming language or object-oriented programming language to communicate with the processing system. When necessary, program code can also be implemented with assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.

[0207] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried by or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, the instructions may be distributed over a network or through other computer-readable media. Therefore, the machine-readable medium may include any mechanism for storing or transmitting information in a form readable by a machine (e.g., a computer), including but not limited to floppy disks, optical disks, optical discs, compact disc-read only memory (CD-ROMs), magneto-optical disks, read-only memory (ROM), random-access memory (RAM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic or optical cards, flash memory, or tangible machine-readable storage for transmitting information using the Internet in electrical, optical, acoustic or other forms of propagation signals (e.g., carrier waves, infrared signals, digital signals, etc.). Therefore, the machine-readable medium includes any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a form readable by a machine (e.g., a computer).

[0208] In the accompanying drawings, some structural or method features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be required. Instead, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a particular figure does not mean that such features are required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features.

[0209] It should be noted that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented as a combination of multiple physical units / modules. The physical implementation method of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed by the present application. In addition, in order to highlight the innovative part of the present application, the above-mentioned device embodiments of the present application do not introduce units / modules that are not closely related to solving the technical problems proposed by the present application, which does not mean that there are no other units / modules in the above-mentioned device embodiments.

[0210] It should be noted that in the examples and description of this patent, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including one" do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0211] Although the present application has been illustrated and described with reference to certain preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the scope of the present application.

Claims

1. A data processing method, applied to a first electronic device, characterized in that: The first electronic device stores compressed data of M model parameters corresponding to a first model and a first list, wherein the parameter value of the model parameter is represented by a-bit binary, the first list includes H different values ​​corresponding to the high b bits of the parameter values ​​of the M model parameters, the compressed data includes compressed model parameters of the parameter values ​​of each of the model parameters, the compressed model parameters are used to indicate the arrangement position of the corresponding parameter value of the model parameter in the first list, M, H, a and b are integers greater than 1, and b is less than or equal to a; and the method includes: detecting an instruction to run a first model; Decompressing the compressed data to obtain parameter values ​​of each of the model parameters, and running the first model based on the parameter values ​​of each of the model parameters obtained by decompression; The M model parameters include a first model parameter, and the compressed data is decompressed to obtain parameter values ​​of each of the model parameters, including: After obtaining all the data of the first compression model parameter corresponding to the first model parameter from the compressed data, the value of the first arrangement position indicated by all the data of the first compression model parameter is obtained from the first list, and the parameter value of the first model parameter is determined based on the obtained value.

2. The method according to claim 1, characterized in that The H different values ​​in the first list are arranged in descending order according to the number of times the H different values ​​appear in the M parameter values ​​corresponding to the M model parameters.

3. The method according to claim 2, characterized in that Corresponding to b=a, all the compressed model parameters of the first model parameters are obtained in the following way: The first compression model parameter corresponds to the first compression model parameter in the compressed data, Starting from the Lth bit of the compressed data, N bits of data are obtained each time, and when the N bits of data obtained at the hth time are not the preset value, h×N bits of data starting from the Lth bit of the compressed data are used as all the data of the first compression model parameter, wherein the Lth bit of the compressed data is the first bit of the compression model parameter corresponding to the M model parameters; The first compression model corresponds to the Sth compression model parameter in the compressed data; After all data of the S-1th compression model parameter is obtained, N data in the compression data are obtained each time, and when the N-bit data obtained for the qth time is not the preset value, the q×N-bit data after the S-1th compression model parameter is used as all data of the first compression model parameter; Wherein, S is an integer greater than 1, L and N are integers greater than or equal to 1, and h and q are integers greater than or equal to 0.

4. The method according to claim 3, characterized in that The H different values ​​are in the first list every 2 N -1 arrangement position corresponds to an arrangement position interval, and the first compression model parameter includes k×N bits of data, k=h or k=q; The acquiring the value of the first arrangement position indicated by all the data of the first compression model parameter from the first list, and determining the parameter value of the first model parameter based on the acquired value, includes: Determine a first arrangement position interval of the parameter value of the first model parameter in the first list based on k, and determine the first arrangement position based on the last N bits of the first compression model parameter and the first arrangement position interval; The value corresponding to the first arrangement position in the first list is used as the parameter value of the first model parameter.

5. The method according to claim 4, characterized in that The first arrangement position is determined by the following formula: lut=(k-1)×(2 N -1)+d Where lut is the first arrangement position, (k-1)×(2 N -1) represents the starting position of the first arrangement position interval, and d is the offset of the first arrangement position relative to the starting position determined based on the last N bits of data of the first compression model parameter.

6. The method according to claim 2, characterized in that corresponds to b being less than a; The compressed model parameters include low ab bit data of the corresponding parameter value of the model parameter, and partial compressed data obtained by compressing high b bit data of the parameter value of the model parameter.

7. The method according to claim 6, characterized in that All compression model parameters of the first model parameters are obtained by: The first compression model parameter corresponds to the first compression model parameter in the compressed data, Starting from the Lth bit of the compressed data, first obtain ab bits of data, and then obtain N bits of data each time, and when the N bits of data obtained for the hth time are not the preset value, a-b+h×N bits of data starting from the Lth bit of data are used as all data of the first compression model parameters; The Lth bit of data in the compressed data is the first bit of data of the compressed model parameter corresponding to the M model parameters; The first compression model corresponds to the Sth compression model parameter in the compressed data; After all the data of the S-1th compression model parameter is obtained, ab bits of data are obtained first, and then N bits of data are obtained each time. When the N bits of data obtained for the qth time are not the preset value, the a-b+q×N bits of data after the S-1th compression model parameter are used as all the data of the first compression model parameter; Wherein, S is an integer greater than 1, L and N are integers greater than or equal to 1, and h and q are integers greater than or equal to 0.

8. The method according to claim 7, characterized in that The H different values ​​are in the first list every 2 N -1 arrangement position corresponds to an arrangement position interval, and the first compression model parameter includes k×N bits of data, k=h or k=q; The acquiring the value of the first arrangement position indicated by all the data of the first compression model parameter from the first list, and determining the parameter value of the first model parameter based on the acquired value, includes: Determine a first arrangement position interval of the value corresponding to the high b bits of the parameter value of the first model parameter in the first list based on k, and determine the first arrangement position based on the last N bits of the first compression model parameter and the first arrangement position interval; Using the value corresponding to the first arrangement position in the first list as the value of the high b-bit data of the parameter value of the first model parameter; The parameter value of the first model parameter is determined based on the values ​​of the lower ab bits and the upper b bits of the parameter value of the first model parameter.

9. The method according to any one of claims 3 to 5 or 7 to 8, characterized in that N is determined by the following formula: N = roundup (-log2 (n / M)) Among them, roundup() is the rounding method, n is the number of times the value ranked first in the first list appears in the parameter values ​​of the M model parameters, and M is the total number of model parameters in the model parameters.

10. The method according to claim 1, characterized in that The compressed data includes a plurality of frame data, and a portion of the data of the first compression model parameter is in the i-th frame data, and another portion of the data of the first compression model parameter is in the i+1-th frame data, where i is an integer greater than 0; All compression model parameters of the first model parameters are obtained by: Based on the identification data in the i-th frame data, the part of the data of the first compression model parameter is obtained from the i-th frame data, and the other part of the data is obtained from the i+1-th frame data.

11. A coding method, applied to a second electronic device, characterized in that: M model parameters are compressed, wherein the parameter values ​​of the model parameters are represented by a-bit binary, and high-b-bit data in the a-bit binary of the parameter values ​​of the model parameters are compressed, M, a and b are integers greater than 1, and b is less than or equal to a, and the method includes: Determine a first list according to the number of times H different values ​​corresponding to the high b bits of the parameter values ​​of the M model parameters appear in the values ​​of the high b bits of the parameter values ​​of the M model parameters, wherein the H different values ​​in the first list are arranged in descending order according to the number of times the H different values ​​appear in the corresponding values ​​of the high b bits of the M parameter values ​​corresponding to the M model parameters, and H is an integer greater than 1; Determine the number of compressed bits N based on the number of occurrences of the value ranked first in the first list, where N is an integer greater than or equal to 1; Determine, based on a first number of N-bit preset values ​​and an N-bit position code, first compressed data corresponding to a value arranged at position 1 in the first list; The first number of the preset data and the position indicated by the position code are determined by: I mod(2 N -1)=d rounddown(I / (2 N -1))=j; Wherein, mod is modulo, rounddown() is rounding down, I is the arrangement position in the first list, N is the number of compressed bits, d and j are integers greater than or equal to 0, corresponding to d=0, the first number is j-1, and the position indicated by the position code is 2 N -1, corresponding to d≠0, the first number is j, and the position indicated by the position code is d; Corresponding to b being less than a, the lower ab bits of the parameter value of the model parameter and the first compressed data corresponding to the arrangement position of the values ​​of the upper b bits of the parameter value of the model parameter in the first list are used as the compressed model parameters of the model parameter, Corresponding to b being equal to a, the first compressed data corresponding to the arrangement position of the parameter value of the model parameter in the first list is used as the compressed model parameter of the model parameter.

12. An electronic device, characterized in that: The invention comprises: a memory for storing instructions; At least one processor is used to execute the instructions so that the electronic device implements the method according to any one of claims 1 to 11.

13. A computer-readable storage medium, characterized in that: The readable storage medium stores instructions, and when the instructions are executed on a computer, the computer is caused to execute the method according to any one of claims 1 to 11.

14. A computer program product, characterized in that When the computer program product is executed on a device, the device is caused to perform the method according to any one of claims 1 to 11.