Electronic device and control method thereof
By dividing and clustering the matrices in the artificial intelligence model, the quantification of the data of the artificial intelligence model is solved, and the problems of large data capacity and performance degradation of the artificial intelligence model are achieved, and the reduction of data capacity and maximum performance protection is achieved.
Patent Information
- Application Number
- CN201980054821.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2018-08-30
- Filing Date
- 2019-08-28
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2039-08-28
AI Technical Summary
Artificial intelligence models require a large amount of data, resulting in high storage requirements and large operational delays and energy consumption, and reduced data capacity after quantization but deteriorated performance.
By using electronic devices in the artificial intelligence model, the processor divides the rows and columns of the matrix, forms multiple groups, and clusters these groups into clusters through clusters, and then quantifies the data in the cluster to reduce the data capacity.
The data capacity of the artificial intelligence model is achieved, while minimizing performance degradation by reducing quantization errors.
Smart Images

Figure CN112585628B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to an electronic device and a control method thereof for compressing an artificial intelligence (AI) model in an artificial intelligence (AI) system that simulates functions such as cognition and determination of a human brain by using a machine learning algorithm such as deep learning and its application, and more specifically, to an electronic device and a control method thereof for quantizing an artificial intelligence model. Background Art
[0002] Recently, artificial intelligence systems that implement human-level intelligence are used in various fields. An artificial intelligence system refers to a system in which a machine can learn, determine, and become more intelligent by itself, unlike a traditional rule-based intelligent system. The artificial intelligence system shows a more improved recognition rate as it is used more and becomes able to more correctly understand user preferences. Therefore, the traditional rule-based intelligent system is gradually replaced by an artificial intelligence system based on deep learning.
[0003] Artificial intelligence technology includes machine learning (e.g., deep learning) and element technology that utilizes machine learning.
[0004] Machine learning refers to algorithmic technology that classifies / learns the characteristics of input data by the machine itself, and element technology refers to simulating the functions of the human brain (such as cognition and determination) by using machine learning algorithms (such as deep learning), and includes technical fields such as language understanding, visual understanding, inference / prediction, knowledge representation, and operation control.
[0005] Examples of various fields of application of artificial intelligence technology are as follows. Language understanding refers to the technology of recognizing human language / text and applying / processing language / text, and includes natural voice processing, machine translation, communication systems, query and response, speech recognition / synthesis, etc. Visual understanding refers to the technology of recognizing objects and processing them in a manner similar to human vision, and includes object recognition, object tracking, image search, human recognition, scene understanding, spatial understanding, image improvement, etc. Inference / prediction refers to the technology of determining information and then performing logical inference and prediction, and includes knowledge / probability-based inference, optimization prediction, preference-based planning, recommendation, etc. Knowledge representation refers to the technology of automatically processing human experience information into knowledge data, and includes knowledge construction (data generation / classification), knowledge management (data utilization), etc. Operation control refers to the technology of controlling the autonomous driving of vehicles and the movement of robots, and includes mobile control (navigation, collision, driving), operation control (behavior control), etc.
[0006] At the same time, the artificial intelligence model has the following problems: the artificial intelligence model requires a large amount of data, and therefore requires a high-capacity memory for storing data, and there are problems of operation delay and high energy consumption. On the contrary, in the case of quantizing the artificial intelligence model, the data capacity may be reduced, but there is a problem of performance degradation of the artificial intelligence model. Summary of the invention
[0007] Technical issues
[0008] An electronic device and a control method thereof are provided, which can reduce the data capacity of an artificial intelligence model while minimizing performance degradation.
[0009] Solution to the problem
[0010] Additional aspects will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the presented embodiments.
[0011] According to one aspect of the embodiment, an electronic device is provided, comprising: a storage device storing a matrix included in an artificial intelligence model; and a processor configured to: divide data included in at least a portion of a matrix by one of rows and columns of the matrix to form a plurality of groups, cluster the plurality of groups into a plurality of clusters based on the data included in each of the plurality of groups, and quantize data divided by the other of rows and columns of the matrix in the data included in each of the plurality of clusters.
[0012] At least one representative value can be obtained based on the size of the first data included in the first group and the size of the second data included in the second group in the groups included in each of the multiple clusters, and each of the first data and the second data can be converted into a binary code based on the at least one representative value, and each of the first data and the second data can be quantized, and the second data can be the other one of the rows and columns of the matrix that is the same as the first data.
[0013] The processor may determine the number of the at least one representative value based on the number of the plurality of groups included in each of the plurality of clusters.
[0014] The processor may map each of the plurality of groups in a multi-dimensional space based on data included in each of the plurality of groups, and cluster the plurality of groups into a plurality of clusters based on distances of the groups in the multi-dimensional space.
[0015] The processor may cluster the plurality of groups into a plurality of clusters based on a K-means algorithm (K-means algorithm).
[0016] The processor may obtain output data for input data based on the quantization matrix, and rearrange the output data based on clustering information, and the clustering information may be obtained based on an operation of clustering a plurality of groups into a plurality of clusters.
[0017] At least a portion of the matrix may be a sub-region of the matrix determined based on the other of a row and a column of the matrix.
[0018] According to another aspect of the embodiment, a control method is provided, comprising: dividing data included in at least a portion of a matrix included in an artificial intelligence model by one of rows and columns of the matrix to form a plurality of groups; clustering the plurality of groups into a plurality of clusters based on the data included in each of the plurality of groups; and quantizing data included in each of the plurality of clusters that is divided by the other of rows and columns of the matrix.
[0019] Quantization may include: obtaining at least one representative value based on the size of first data included in a first group and the size of second data included in a second group in the groups included in each of a plurality of clusters, and converting each of the first data and the second data into a binary code based on the at least one representative value, and quantizing each of the first data and the second data, and the second data is data that is the same as the first data in the other of the rows and columns of the matrix.
[0020] The quantizing may include determining the number of at least one representative value based on the number of the plurality of groups included in each of the plurality of clusters.
[0021] The clustering may include mapping each of the plurality of groups in a multi-dimensional space based on data included in each of the plurality of groups, and clustering the plurality of groups into a plurality of clusters based on distances of the groups in the multi-dimensional space.
[0022] The clustering may include: clustering the plurality of groups into a plurality of clusters based on a K-means algorithm.
[0023] The control method may further include: according to obtaining output data with respect to input data based on the quantization matrix, rearranging the output data based on clustering information, and the clustering information may be obtained based on an operation of clustering the plurality of groups into the plurality of clusters.
[0024] At least a portion of the matrix may be a sub-region of the matrix determined based on the other of a row and a column of the matrix.
[0025] According to another aspect of the embodiment, a non-transitory computer-readable recording medium storing a program is provided, which program performs an operation method when executed by an electronic device, the operation method including: dividing data included in a part of a matrix included in an artificial intelligence model by one of rows and columns of the matrix to form a plurality of groups; clustering the plurality of groups into a plurality of clusters based on the data included in each of the plurality of groups; and quantizing data divided by the other of rows and columns of the matrix in the data included in each of the plurality of clusters.
[0026] According to another aspect of the embodiment, there is provided an electronic device, comprising: a storage device storing a matrix included in an artificial intelligence model; and a processor configured to: divide the data in the matrix by rows to form a plurality of groups of data, cluster the plurality of groups into a first cluster and a second cluster based on the data included in the plurality of groups, and quantize the data in the first cluster by columns according to a representative value determined for each column according to the data in the column, and quantize the data in the second cluster by columns according to a representative value determined for each column according to the data in the column.
[0027] The processor may cluster the plurality of groups into a plurality of clusters by reordering at least one of the groups based on data included in the plurality of groups.
[0028] The representative values of each column of the first cluster may be different from each other, and the representative values of each column of the second cluster may be different from each other.
[0029] To quantize the data in the first cluster, data from at least two columns may be combined, and the combined data may be quantized with one representative value.
[0030] The number of representative values may be determined based on a threshold accuracy and / or a threshold quantization error.
[0031] Advantageous Effects of the Invention
[0032] According to the various embodiments of the present disclosure described above, the electronic device can reduce data capacity by quantizing an artificial intelligence model, and at the same time, minimize performance degradation by reducing errors attributed to quantization. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The above and other aspects, features and advantages of certain embodiments of the present disclosure may be more clearly understood through the following description in conjunction with the accompanying drawings, in which:
[0034] Figure 1a is a block diagram showing a configuration of an electronic device according to an embodiment;
[0035] Figure 1b is a block diagram showing a detailed configuration of an electronic device according to an embodiment;
[0036] Figure 2a is a diagram for illustrating an artificial intelligence model according to an embodiment;
[0037] Figure 2b is a diagram for illustrating an artificial intelligence model according to an embodiment;
[0038] Figure 3a is a diagram for illustrating a clustering method according to an embodiment;
[0039] Figure 3b is a diagram for illustrating a clustering method according to an embodiment;
[0040] Figure 3c is a diagram for illustrating a clustering method according to an embodiment;
[0041] Figure 4a is a diagram for illustrating a quantization method according to an embodiment;
[0042] Figure 4b is a diagram for illustrating a quantization method according to an embodiment;
[0043] Figure 4c is a diagram for illustrating a quantization method according to an embodiment;
[0044] Figure 5a is a diagram for illustrating a quantization method according to another embodiment of the present disclosure;
[0045] Figure 5b is a diagram for illustrating a quantization method according to another embodiment of the present disclosure;
[0046] Figure 5c is a diagram for illustrating a quantization method according to another embodiment of the present disclosure;
[0047] Figure 5d is a diagram for illustrating a quantization method according to another embodiment of the present disclosure;
[0048] Figure 5e is a diagram for illustrating a quantization method according to another embodiment of the present disclosure;
[0049] Figure 6a is a diagram for illustrating advantages according to clustering according to an embodiment;
[0050] Figure 6b is a diagram for illustrating advantages according to clustering according to an embodiment;
[0051] Figure 6c is a diagram showing a case where quantization is performed by using a matrix with reordering;
[0052] Figure 7a is a diagram for illustrating additional operations according to clustering according to an embodiment;
[0053] Figure 7b is a diagram for illustrating additional operations according to clustering according to an embodiment;
[0054] Figure 8a is a diagram for illustrating a method of dividing a matrix and quantizing the matrix according to an embodiment;
[0055] Figure 8b is a diagram for illustrating a method of dividing a matrix and quantizing the matrix according to an embodiment;
[0056] Figure 9a is a graph for illustrating word error rate (WER) and accuracy according to an embodiment;
[0057] Figure 9b is a graph for illustrating word error rate (WER) and accuracy according to an embodiment;
[0058] Fig.9c is a graph for illustrating word error rate (WER) and accuracy according to an embodiment;
[0059] Fig.10a is a diagram illustrating WER as a graph according to various embodiments of the present disclosure;
[0060] Fig.10b is a diagram illustrating WER as a graph according to various embodiments of the present disclosure;
[0061] Fig.10c is a diagram illustrating WER as a graph according to various embodiments of the present disclosure; and
[0062] Fig.11 is a flowchart for illustrating a control method of an electronic device according to an embodiment. DETAILED DESCRIPTION
[0063] Invention Mode
[0064] The exemplary embodiments of the present disclosure may be modified differently. Therefore, specific exemplary embodiments are shown in the drawings and described in detail in the detailed description. However, it should be understood that the present disclosure is not limited to specific exemplary embodiments, but includes all changes, equivalents and substitutions that do not depart from the scope and spirit of the present disclosure. In addition, well-known functions or configurations are not described in detail because they will unnecessarily obscure the present disclosure. As used herein, the terms "1st" or "first" and "2nd" or "second" may use corresponding components regardless of importance or order, and are used to distinguish one component from another without limiting the components.
[0065] Hereinafter, various embodiments of the present disclosure will be described in detail with reference to the accompanying drawings.
[0066] Figure 1a 1 is a block diagram illustrating a configuration of an electronic device 100 according to an embodiment of the present disclosure. Figure 1a As shown, the electronic device 100 includes a storage device 110 and a processor 120 .
[0067] The electronic device 100 may be a device for quantizing an artificial intelligence model. For example, the electronic device 100 is a device for quantizing a matrix included in the artificial intelligence model, and the electronic device 100 may be a server, a desktop PC, a laptop computer, a smart phone, a tablet PC, etc. In addition, in the artificial intelligence model, a plurality of matrices may be included, and the electronic device 100 may quantize some or all of the plurality of matrices. That is, the electronic device 100 may be any device that can reduce the size of the data of the artificial intelligence model by quantizing the artificial intelligence model. Here, the matrix may be, for example, a weight matrix.
[0068] The storage device 110 is provided separately from the processor 120 , and the storage device 110 may be implemented as, for example, a hard disk, a nonvolatile memory, a volatile memory, or the like.
[0069] The storage device 110 may store matrices included in the artificial intelligence model. Here, the matrix may be, for example, filter data, kernel data, etc. constituting the artificial intelligence model. In addition, the storage device 110 may store a plurality of matrices included in the artificial intelligence model.
[0070] Alternatively, the storage device 110 may store data that can be used for an artificial intelligence model, and the processor 120 may recognize the data stored in the storage device 110 as a matrix.
[0071] The processor 120 controls the overall operation of the electronic device 100 .
[0072] According to an embodiment of the present disclosure, the processor 120 may be implemented as a digital signal processor (DSP), a microprocessor and / or a time controller (TCON). However, the present disclosure is not limited thereto, and the processor 120 may include one or more of a central processing unit (CPU), a microcontroller unit (MCU), a microprocessing unit (MPU), a controller, an application processor (AP) or a communication processor (CP) and an ARM processor. In some embodiments, the processor 120 may include multiple components of any of the above working in conjunction with each other. In addition, the processor 120 may be implemented as a system on chip (SoC) or a large scale integration (LSI) in which a processing algorithm is stored, or implemented in the form of a field programmable gate array (FPGA).
[0073] The processor 120 may divide the data included in at least a portion of the matrix by one of the rows and columns of the matrix, and identify the divided data as a plurality of groups, cluster the plurality of groups into a plurality of clusters based on the data included in each of the plurality of groups, and quantize the data divided by the other of the rows and columns of the matrix in the data included in each of the plurality of clusters.
[0074] For example, the processor 120 may identify the data included in the 4×4 matrix as four 1×4 groups based on the rows of the matrix. Hereinafter, for ease of explanation, the 1×4 group in the first row of the 4×4 matrix is described as the first group, the 1×4 group in the second row is described as the second group, the 1×4 group in the third row is described as the third group, and the 1×4 group in the fourth row is described as the fourth group.
[0075] Then, the processor 120 may cluster the four groups into two clusters based on the data included in each group. For example, the processor 120 may cluster the first and third groups of the four groups into a first cluster, and cluster the second and fourth groups into a second cluster.
[0076] Then, the processor 120 may quantize the data included in the same column of the data included in the multiple groups included in each cluster. Here, the standard for performing quantization may be different from the standard for identifying the group. For example, in the case where the processor 120 divides the data included in at least a portion of the matrix in units of "columns" of the matrix and identifies the divided data as multiple groups, the processor 120 may quantize the data pairs included in the same "row" of the data included in the multiple groups included in each cluster. Alternatively, in the case where the processor 120 divides the data included in at least a portion of the matrix in units of "rows" of the matrix and identifies the divided data as multiple groups, the processor 120 may quantize the data pairs included in the same "column" of the data included in the multiple groups included in each cluster.
[0077] Explaining the quantization method in detail, the processor 120 may acquire at least one representative value based on the size of the first data included in the first group of the groups included in each of the plurality of clusters and the size of the second data included in the second group, and convert each of the first data and the second data into a binary code based on the at least one representative value, and quantize each of the first data and the second data. Meanwhile, the second data may be data in which the other of the rows and columns of the matrix is the same as that of the first data.
[0078] In the aforementioned embodiment, the processor 120 may quantize the first data belonging to the first group clustered as the first cluster, and quantize the second data in the same column as the first data in the data belonging to the third group clustered as the first cluster. For example, the processor 120 may quantize the first data in the data belonging to the first 1×4 group clustered as the first cluster, and quantize the first data in the data belonging to the third 1×4 group clustered as the first cluster. In addition, the processor 120 may quantize the second data in the data belonging to the first 1×4 group clustered as the first cluster, and quantize the second data in the data belonging to the third 1×4 group clustered as the first cluster.
[0079] By the above method, the processor 120 can quantize the data belonging to the first group clustered into the first cluster and the data belonging to the third group clustered into the first cluster, and can quantize a total of four data pairs. By the same method, the processor 120 can quantize the data belonging to the second group clustered into the second cluster and the data belonging to the fourth group clustered into the second cluster, and can quantize a total of four data pairs. Therefore, the processor 120 can quantize a total of eight data pairs to quantize multiple groups.
[0080] The processor 120 can quantize the first data and the second data based on the size of the first data and the second data. For example, if the first data is 3 and the second data is -1, the processor 120 can set the representative value to 2, and set the first data to 1, and set the second data to -1. That is, the processor 120 can set the first data 3 to 1, and when it is restored later, the first data 3 can be restored to 2 by using the representative value 2, and the second data -1 can be set to -1, and when it is restored later, the second data -1 can be restored to -2 by using the representative value 2. Therefore, when the first data is represented as 2 from 3 and the second data is represented as -2 from -1, a quantization error may occur. At the same time, if each data contained in the matrix has 32 bits, it means that the first data and the second data need a total of 64 bits, but after quantization with 1 bit, only 32 bits of representative values and 1 bit of the first data converted into binary code and 1 bit of the second data converted into binary code are needed, and therefore 34 bits are needed in total. That is to say, the data capacity can be reduced.
[0081] Meanwhile, the processor 120 may determine the number of at least one representative value based on the number of multiple groups included in each of the multiple clusters. In the aforementioned embodiment, two groups are included in the first cluster, and thus quantization is performed using one representative value. However, if 10 groups are included in a cluster, 10 data should be quantized, and in this case, if quantization is performed using one representative value, the quantization error becomes very large. Therefore, as more groups are included in a cluster, the processor 120 may increase the number of representative values.
[0082] The processor 120 can identify whether to maintain the threshold accuracy when changing the number of representative values, and determine the minimum number of the number of representative values through which the threshold accuracy is maintained as the number of representative values. For example, the processor 120 can adjust the number of representative values under the condition that the accuracy after quantization is maintained at 90% of the accuracy before quantization. For example, if quantization is performed with a number of representative values of five, the processor 120 can increase the number of representative values under the condition that the accuracy after quantization is less than 90% of the accuracy before quantization, and reduce the number of representative values under the condition that the accuracy after quantization is equal to or higher than 90% of the accuracy before quantization. The processor 120 can repeat the process and determine that if the number of representative values is equal to or greater than 7, the accuracy after quantization remains equal to or higher than 90% of the accuracy before quantization, and the number of representative values is determined to be 7.
[0083] At the same time, the processor 120 may map each of the multiple groups in the multidimensional space based on the data included in each of the multiple groups, and cluster the multiple groups into multiple clusters based on the distances between the groups in the multidimensional space. For example, the processor 120 may cluster the multiple groups into multiple clusters by applying the K-means algorithm to the data included in each of the multiple groups. However, the present disclosure is not limited thereto, and the processor 120 may cluster the multiple groups into multiple clusters by many different methods.
[0084] Meanwhile, if output data for input data is obtained based on the quantization matrix, the processor 120 may realign the output data based on clustering information. The clustering information may be information obtained based on an operation of clustering a plurality of groups into a plurality of clusters. For detailed description in this regard, reference will be made to Figure 7a and Figure 7b conduct.
[0085] In addition, at least a portion of the matrix may be a sub-region of the matrix identified based on other ones of the rows and columns of the matrix. Figure 8a and Figure 8b conduct.
[0086] Figure 1b 1 is a block diagram illustrating a detailed configuration of the electronic device 100 according to an embodiment of the present disclosure. Figure 1b, the electronic device 100 includes a storage device 110, a processor 120, a communicator 130, a user interface 140, a display 150, an audio processor 160, and a video processor 170. Figure 1b Of the components shown, Figure 1a Detailed description of overlapping parts will be omitted for the sake of brevity.
[0087] The processor 120 controls the overall operation of the electronic device 100 by using various programs stored in the storage device 110 .
[0088] Specifically, the processor 120 includes a RAM 121 , a ROM 122 , a main CPU 123 , a graphic processor 124 , first to nth interfaces 125 - 1 to 125 - n , and a bus 126 .
[0089] The RAM 121 , the ROM 122 , the main CPU 123 , the graphic processor 124 , the first to nth interfaces 125 - 1 to 125 - n , etc. may be connected to one another through a bus 126 .
[0090] The first to nth interfaces 125 - 1 to 125 - n may be connected to the above-mentioned various components. One of the interfaces may be a network interface connected to an external device through a network.
[0091] The main CPU 123 accesses the storage device 110 and performs booting by using the O / S stored in the storage device 110. Then, the main CPU 123 performs various operations by using various programs stored in the storage device 110 and the like.
[0092] The ROM 122 stores an instruction set for system startup and the like. When a turn-on instruction is input and power is supplied, the main CPU 123 copies an O / S stored in the storage device 110 in the RAM 121 and starts the system by executing the O / S according to the instruction stored in the ROM 122. When the startup is completed, the main CPU 123 copies various types of application programs stored in the storage device 110 in the RAM 121, and performs various operations by executing the application programs copied in the RAM 121.
[0093] The graphics processor 124 generates a screen including various objects such as icons, images, and texts by using an operation part (not shown) and a rendering part (not shown). The operation part (not shown) operates based on the received control command to display the attribute values of each object such as coordinate values, shape, size, and color according to the layout of the screen. In addition, the rendering part (not shown) generates a screen with various layouts including objects based on the attribute values operated at the operation part (not shown). The screen generated at the rendering part (not shown) is displayed in the display area of the display 150.
[0094] Meanwhile, the above operations of the processor 120 may be performed by a program stored in the storage device 110 .
[0095] The storage device 110 stores various data, such as an operating system (O / S) software module for operating the electronic device 100, an artificial intelligence module including an artificial intelligence model and a quantized artificial intelligence model, a quantization module for quantizing the artificial intelligence model, etc.
[0096] The communicator 130 may be a component that performs communication with various types of external devices according to various types of communication methods. The communicator 130 may include a WiFi chip 131, a Bluetooth chip 132, a wireless communication chip 133, an NFC chip 134, etc. The processor 120 may perform communication with various types of external devices by using the communicator 130.
[0097] The WiFi chip 131 and the Bluetooth chip 132 perform communication by using WiFi and Bluetooth methods, respectively. In the case of using the WiFi chip 131 or the Bluetooth chip 132, various types of connection information such as SSID and session key are first transmitted and received, and communication connection is performed by using the information, and various types of information can be transmitted and received thereafter. The wireless communication chip 133 refers to a chip that performs communication according to various communication standards, such as IEEE, Zigbee, 3rd generation (3G), 3rd generation partnership project (3GPP) and long term evolution (LTE). Meanwhile, the NFC chip 134 refers to a chip that operates in a near field communication (NFC) method, which uses a 13.56MHz band among various RF-ID bands such as 135kHz, 13.56MHz, 433MHz, 860MHz to 960MHz and 2.45GHz.
[0098] The processor 120 may receive a matrix included in an artificial intelligence module or an artificial intelligence model from an external device through the communicator 130, and store the received data in the storage device 110. Alternatively, the processor 120 may generate an artificial intelligence model by an artificial intelligence algorithm itself, and store the generated artificial intelligence model in the storage device 110. Here, the artificial intelligence model may include a matrix.
[0099] The user interface 140 receives various user interactions. Here, the user interface 140 can be implemented in various forms according to the embodiment of the electronic device 100. For example, the user interface 140 can be a button provided on the electronic device 100, a microphone for receiving a user's voice, a camera for detecting a user's action, etc. Alternatively, in the case where the electronic device 100 is implemented as a touch-based electronic device, the user interface 140 can be implemented in the form of a touch screen, which forms an interlayer structure with the touch pad. In this case, the user interface 140 can be used as the above-mentioned display 150.
[0100] The audio processor 160 is a component that performs audio data processing. At the audio processor 160, various types of processing such as decoding or amplification of audio data, noise filtering, etc. may be performed.
[0101] The video processor 170 is a component that performs video data processing. At the video processor 170, various types of image processing such as decoding, scaling, noise filtering, frame rate conversion, and resolution conversion of video data may be performed.
[0102] Through the method described above, the processor 120 may quantize the matrix included in the artificial intelligence model.
[0103] Hereinafter, the operation of the electronic device 100 will be described in more detail with reference to the accompanying drawings.
[0104] Figure 2a and Figure 2b is a diagram for illustrating an artificial intelligence model according to an embodiment of the present disclosure.
[0105] Figure 2a is a diagram showing an embodiment of an artificial intelligence model including three layers and two matrices, and the processor 120 can obtain the median value of Li by inputting the input value of Li-1 into W12, and obtain the final value of Li+1 by inputting the median value of Li into W23. However, Figure 2a The artificial intelligence model is schematically shown, and in fact, Figure 2a Compared to , more than three layers and more than two matrices may be included.
[0106] Figure 2bis a diagram showing an embodiment of a matrix, and the matrix may be in the form of m×n. For example, the matrix may be in the form of 10000×8000. In addition, the data in the matrix may be 32 bits respectively. That is, the matrix may include 10000×8000 data of 32 bits each. However, the present disclosure is not limited thereto, and the size of the matrix and the number of bits of each data may vary in various ways.
[0107] like Figure 2a and Figure 2b As shown, considering the size of each data included in the matrix, the number of data included in the matrix, and the number of matrices included in the artificial intelligence model, a very large storage space is required for storing the artificial intelligence model, and the operation of the artificial intelligence model may consume a lot of power. Therefore, the processor 120 can quantize the data of the matrix, thereby reducing the space required for the storage device and reducing the amount of operation.
[0108] Figure 3a to Figure 3c is a diagram for illustrating a clustering method according to an embodiment of the present disclosure.
[0109] First, in Figure 3a In the embodiment, for the convenience of explanation, it is explained that a 4×4 matrix includes 16 data and each data has 32 bits. For example, “a” may be one data having 32 bits, “b” may be another data having 32 bits, and so on.
[0110] The processor 120 may divide the 4×4 matrix by row units and identify the data included in the matrix into four groups 311 - 314 .
[0111] Processor 120 may then map each of the four groups in four-dimensional space and generate the corresponding groups by Figure 3b In addition, the processor 120 may cluster the groups within a short distance. For example, as in Figure 3c As in FIG. 1 , the processor 120 may cluster the first group 311 and the third group 313 into a first cluster, and cluster the second group 312 and the fourth group 314 into a second cluster. In addition, the processor 120 may change the position of the data in the matrix according to the clustering, such as Figure 3c As shown. This operation is called reordering, and reordering does not affect the amount of calculation and accuracy. In the following, for the sake of convenience of explanation, it will be explained that reordering is included in the clustering operation.
[0112] However, the present disclosure is not limited thereto, and the processor 120 may cluster the plurality of groups 311 - 314 into a plurality of clusters based on a K-means algorithm.
[0113] In addition, the processor 120 may cluster the first group 311 , the second group 312 , and the third group 313 into a first cluster, and cluster the fourth group 314 into a second cluster.
[0114] Meanwhile, advantages according to clustering will be described later.
[0115] Figures 4a to 4c is a diagram for illustrating a quantization method according to an embodiment of the present disclosure.
[0116] exist Figure 4a For the convenience of explanation, only the Figure 3c The data included in the first group 311 and the first cluster of the third group 313. Figure 4a As shown in , the processor 120 may respectively quantize data pairs 411 - 414 , the data pairs including first data of the first group 311 and second data of the third group 313 of the data included in the first cluster.
[0117] In order to explain the method of quantizing the first data pair 411, first assume quantization with 1 bit when a is 3 and i is -1. The processor 120 can obtain a representative value α based on a and i. For example, the processor 120 can obtain α by averaging the absolute value of a and the absolute value of i, and in the case of the aforementioned embodiment, α can therefore be 2. However, the present disclosure is not limited thereto, and the processor 120 can obtain α by many different methods.
[0118] Then, if Figure 4b As shown in , the processor 120 may quantize a and i to +1 and -1, respectively, based on α. That is, the processor 120 may convert α close to +α between +α and -α to +1, and convert i close to -α to -1. It should be noted that Figure 4b The arrows in are intended to indicate which of +α and -α the values of a and i are closest to.
[0119] As in Figure 4c As shown in , the processor 120 can convert a and i into +1 and -1 and α. According to the aforementioned embodiment, 3 can be quantized to 2, and -1 can be quantized to -2, and can be represented as a representative value 2 and binary data 1 and -1. In addition, a and i total 64 bits of data (each of which is 32 bits) can be converted into α total 34 bits of data, including α of 32 bits, and +1 and -1 each of which is 1 bit.
[0120] The processor 120 can use the same method to Figure 4aQuantization is performed on the second data pair 412, the third data pair 413, and the fourth data pair 414 shown in the figure. Here, the representative values of the first data pair 411 to the fourth data pair 414 may be different from each other. However, the present disclosure is not limited to this, and the processor 120 may combine some data pairs and quantize the combined data pairs by a representative value. For example, the processor 120 may quantize the first data pair 411 and the second data pair 412 by a representative value. In this case, the processor 120 may convert a total of 128 bits of data into a total of 38 bits of data. However, in this case, the quantization error may become larger, and the accuracy of the artificial intelligence model may deteriorate. Therefore, the processor 120 may perform quantization by combining multiple data pairs within the range of maintaining the accuracy of the artificial intelligence model, and thereby improve the quantization efficiency. The number of data pairs to be combined can also be determined based on the threshold accuracy.
[0121] Figures 4a to 4c The quantization method explained in can also be performed in the same manner with respect to the second cluster.
[0122] Figure 5a to Figure 5e is a diagram for explaining a quantization method according to another embodiment of the present disclosure.
[0123] exist Figure 5a In this example, for ease of explanation, it is assumed that the first cluster includes four groups. Figure 5a As shown in , the processor 120 may quantize 511 the data pairs included in the first column included in each group in the data included in the first cluster.
[0124] When 2-bit quantization is performed based on a, b, c, and d, the processor 120 may obtain representative values α1 and α2. Figure 5b As shown in , based on α1 and α2, the processor 120 may convert a into -α1+α2, b into α1+α2, c into α1-α2, and d into -α1-α2.
[0125] In addition, if Figure 5c As shown in , the processor 120 can convert a into (-1, 1), b into (1, 1), c into (1, -1), and d into (-1, -1). That is, the processor 120 can convert a, b, c, d, each of which is 32 bits, a total of 128 bits of data, into α1 and α2, each of which is 32 bits, and (-1, 1), (1, 1), (1, -1), (-1, -1), each of which is 2 bits, a total of 72 bits of data.
[0126] That is, since the processor 120 uses α1 and α2, the quantization error can be reduced more than the case of using α.
[0127] Here, the number of representative values may be determined based on the number of groups included in the cluster. That is, when more groups are included in the cluster, the processor 120 may increase the number of representative values and then perform quantization.
[0128] Alternatively, the processor 120 may identify whether the threshold accuracy is satisfied while sequentially increasing the number of representative values. Figure 5d In the example, if 3, 7, -1, -5 are quantized, the processor 120 may first obtain a representative value based on the absolute value of each of 3, 7, -1, -5. In this case, a representative value may be 4, and each of 3, 7, -1, -5 may be converted into binary data of 1, 1, -1, -1. Here, the entire quantization error may be Figure 5d The total length of the arrows in (i.e. 8). That is, the length of each rightward arrow is 1, and the length of each leftward arrow is 3, so that 1+3+1+3==8.
[0129] If the entire quantization error is less than the threshold error, the processor 120 may perform quantization through one representative value, and if the entire quantization error is equal to or greater than the threshold error, the processor 120 may perform quantization again through two representative values. In the case of performing quantization again, the processor 120 may set the one representative value initially obtained to α1, and obtain the average value of the quantization errors between each of 3, 7, -1, -5 and α1 as the representative value α2. That is, the processor 120 may obtain the quantization errors between each of 3, 7, -1, -5 and α1 as 1, 3, 3, 1, and obtain the average value of the quantization errors as 2 as the representative value α2. That is, α1 may be 4 and α2 may be 2. Then, as in Figure 5e In this case, the representative values may be 4 and 2, and 3, 7, -1, -5 may be quantized as (1, -1), (1, 1), (-1, 1), (-1, -1), respectively.
[0130] In the foregoing embodiment, if each of 3, 7, -1, -5 has 32 bits, a total of 132 bits are required before quantization. Figure 5d , a representative value of 32 bits and 4 bits of binary data are generated, and thus a total of 36 bits are required. Figure 5e2-bit quantization is performed as in , two representative values of 64 bits and 8-bit binary data are generated, and thus a total of 72 bits are required. Meanwhile, in the aforementioned embodiment, if 1-bit quantization is performed, the quantization error is 8, but if 2-bit quantization is performed, the quantization error is 4. Therefore, if the compression rate becomes higher, the accuracy may become lower, and if the accuracy becomes higher, the compression rate may become lower.
[0131] exist Figure 5d and Figure 5e In the embodiment of the present invention, up to 2-bit quantization is explained, but the processor 120 may obtain additional representative values to ensure greater accuracy. For example, after the processor 120 performs 2-bit quantization, if the overall quantization error is equal to or greater than the threshold error, the processor 120 may perform quantization again using three representative values. In this way, the number of representative values may be determined.
[0132] Figure 6a and Figure 6b is a diagram for illustrating advantages according to clustering according to an embodiment of the present disclosure.
[0133] Figure 6a is a diagram showing that the positions of data in the initial matrix are changed according to clustering. In the same manner as the above embodiment, it is assumed that the positions of the second and third groups have been changed, and for ease of explanation, only the first column will be explained.
[0134] Figure 6b The case where 1-bit quantization is performed by grouping the initial matrix without reordering it is shown. Figure 6b As can be seen from the top of FIG. 1 , the processor 120 can set α1 to 5 to quantize the data pairs of the first and second rows and convert the data pairs into 1 and 1. Then, as shown from Figure 6b As can be seen from the bottom of FIG. 1 , the processor 120 can set α2 to 3 so as to quantize the data pairs of the third and fourth rows and can convert the data pairs into 1 and −1.
[0135] Figure 6c The case where quantization is performed by using a matrix with reordering is shown. Figure 6c As can be seen from the top of FIG. 1 , the processor 120 can set α1′ to 2 to quantize the data pairs of the first and second rows and convert the data pairs into 1 and −1. Then, as shown from Figure 6c As can be seen from the bottom of FIG. 1 , the processor 120 may set α2′ to 6 so as to quantize the data pairs of the third and fourth rows and may convert the data pairs into 1 and −1.
[0136] Quantitative efficiency in Figure 6b and Figure 6c can be the same in . Specifically, Figure 6bThe top and bottom of the 64-bit data are converted into 34-bit data, and Figure 6c The top and bottom of the 64-bit data are also converted into 34-bit data.
[0137] Meanwhile, the quantization error is the difference between the original data value and the quantized value, and is Figure 6b and Figure 6c In each of , the quantization error is represented as an arrow. In addition, Figure 6c The total length of the arrows in (which is 4) is greater than Figure 6b The total length of the arrows in (which is 8) is short. That is, the processor 120 can reduce the quantization error by performing clustering and minimize the degradation of the accuracy of the artificial intelligence model according to the quantization.
[0138] Figure 7a and Figure 7b is a diagram for illustrating additional operations according to clustering according to an embodiment of the present disclosure.
[0139] Figure 7a The operation sequence by using the initial matrix without clustering is shown. Specifically, the processor 120 can output X, Y, Z by inputting the input data a, b, c into the first matrix, and output the final data A, B, C by inputting X, Y, Z into the second matrix.
[0140] Meanwhile, if the position of the data of the matrix is changed according to the clustering, the processor 120 may rearrange the output data based on the clustering information. Here, the clustering information may be information acquired based on an operation of clustering a plurality of groups into a plurality of clusters.
[0141] For example, Figure 7b As shown, if the position of w12 is swapped with the position of w13, the processor 120 can identify that X, Z, Y are output according to the operation of a, b, c and the first matrix, and X, Z, Y are converted into X, Y, Z, and X, Y, Z are input into the second matrix.
[0142] In addition, in the case where the second matrix is clustered after the first matrix, the processor 120 can only rearrange the outputs of A, B, C in the order changed according to the clustering of the second matrix, and for the outputs of X, Z, Y of the first matrix operation, the processor 120 can rearrange the columns of the second matrix in the order of X, Z, Y, and obtain the same result as the case of conversion into X, Y, Z.
[0143] Figure 8a and Figure 8b is a diagram for illustrating a method of dividing a matrix and quantizing the matrix according to an embodiment of the present disclosure.
[0144] So far, for the sake of convenience, the quantization method has been explained by using a small-sized matrix. However, in reality, the size of the matrix may be very large. For example, Figure 8a As shown, if the number of columns is 10, the distance between a and k may be very close, and thus the quantization efficiency may be high, but the distance between h and r may be far, and thus the quantization efficiency may be low.
[0145] Therefore, if Figure 8b As shown, the processor 120 may divide the matrix into two sub-regions based on columns, and perform clustering and quantization for each sub-region. In this way, the quantization efficiency may be further improved.
[0146] In addition, the processor 120 may divide the matrix into a plurality of sub-regions by various methods and improve quantization efficiency and accuracy for each case. In addition, the processor 120 may quantize the matrix by using one of various cases based on quantization efficiency and accuracy.
[0147] Meanwhile, since the method of combining operation results is a simple algorithm, a detailed explanation in this regard will be omitted.
[0148] Figures 9a to 9c is a graph for illustrating word error rate (WER) and accuracy according to an embodiment of the present disclosure.
[0149] Figure 9a The WER according to quantizing the matrix is described, and as the WER becomes lower, the performance becomes better. The table describes the number of clusters, and as the number of clusters increases, the quantization error decreases, and thus the WER becomes lower. In addition, "bit" indicates the number of representative values of each cluster, and as the number of representative values increases, the quantization error further decreases, and thus the WER becomes lower.
[0150] like Figure 9b As described, Figure 9b The WER for quantizing a matrix is described based on partitioning the matrix into four sub-regions. Figure 9b In the case of Figure 9a The situation is further improved.
[0151] Fig.9c It is a graph describing the efficiency according to the reordering, and when the K-means algorithm is used, the quantization error decreases, so the accuracy can be improved. In addition, the "number of tables" describes the number of clusters, and as the number of clusters increases, the quantization error decreases, and thus the accuracy can be improved.
[0152] Figures 10a to 10c is a diagram illustrating WER as a graph according to various embodiments of the present disclosure.
[0153] Figures 10a to 10c The cases where the number of representative values of each cluster is 1, 2, and 4 are shown, and as the number of representative values increases, the WER may become lower. Figures 10a to 10c In each of , as the “number of tables” describing the number of clusters increases, the WER may become lower.
[0154] In addition, Figures 10a to 10c In the present invention, the first WER (original) according to the conventional technique, the second WER (Kmeans) after clustering and quantization, and the Figure 8b The third WER (Kmeans column transposition) after the matrix is partitioned and the clustering and quantization of each of the partitioned matrices. Figures 10a to 10c As shown, generally, the third WER is lower than the second WER, and the second WER is lower than the first WER, so the WER is improved according to the present disclosure.
[0155] Fig.11 is a flowchart for illustrating a control method of an electronic device according to an embodiment of the present disclosure.
[0156] First, at operation S1110, data included in at least a portion of a matrix included in an artificial intelligence model is divided by one of a row and a column of the matrix and identified as a plurality of groups. Then, at operation S1120, based on the data included in each of the plurality of groups, the plurality of groups are clustered into a plurality of clusters. Then, at operation S1130, data divided by the other of a row and a column of the matrix in the data included in each of the plurality of clusters is quantized.
[0157] Here, in the quantization step S1130, based on the size of the first data included in the first group and the size of the second data included in the second group in each of the plurality of clusters, at least one representative value may be acquired, and based on the at least one representative value, each of the first data and the second data may be converted into a binary code, and each of the first data and the second data may be quantized. Here, the second data may be data whose other of the row and column of the matrix is the same as the first data.
[0158] In addition, in the quantization step S1130 , the number of at least one representative value may be determined based on the number of the plurality of groups included in each of the plurality of clusters.
[0159] Meanwhile, in the clustering step S1120 , each of the plurality of groups may be mapped in a multidimensional space based on data included in each of the plurality of groups, and the plurality of groups may be clustered into a plurality of clusters based on distances of the groups in the multidimensional space.
[0160] In addition, in the clustering step S1120, the multiple groups may be clustered into multiple clusters based on a K-means algorithm.
[0161] Meanwhile, the method may further include the following steps: according to obtaining output data for input data based on the quantization matrix, rearranging the output data based on clustering information. Here, the clustering information may be information obtained based on an operation of clustering a plurality of groups into a plurality of clusters.
[0162] Meanwhile, at least a portion of the matrix may be a sub-region of the matrix identified based on the other of a row and a column of the matrix.
[0163] According to the various embodiments of the present disclosure described above, the electronic device can reduce data capacity by quantizing an artificial intelligence model, and at the same time, minimize performance degradation by reducing errors attributed to quantization.
[0164] Meanwhile, above, quantization of one matrix has been described, but some or all matrices included in the artificial intelligence model may be quantized by the same method.
[0165] In addition, above, it has been described that the processor performs clustering based on rows, performs quantization based on columns, and divides the matrix into sub-regions based on columns, but the present disclosure is not limited thereto. For example, the processor may perform clustering based on columns, perform quantization based on rows, and divide the matrix into sub-regions based on rows.
[0166] Meanwhile, above, only the quantization method according to the alternating multi-bit quantization method is described, but the same technique can be applied to a variety of different quantization methods. That is, in the case of other quantization methods, data capacity can be reduced by clustering and reordering, and at the same time, performance degradation can be minimized by reducing the error attributed to quantization.
[0167] At the same time, according to an embodiment of the present disclosure, the various embodiments of the present disclosure described herein may be implemented as software including instructions stored in a machine-readable storage medium, which can be read by a machine (e.g., a computer). A machine refers to a device that calls instructions stored in a storage medium, and can operate according to the called instructions, and these devices may include an electronic device (e.g., electronic device A) according to the above-mentioned embodiment. In the case where a processor executes an instruction, the processor may perform the function corresponding to the instruction itself, or use other components under its control to execute the instruction. The instruction may include code generated or executed by a compiler or interpreter. A storage medium that can be read by a machine may be provided in the form of a non-temporary storage medium. Here, the term "non-temporary" only means that the storage medium does not include a signal and is tangible, and does not indicate whether the data is stored in the storage medium semi-permanently or temporarily.
[0168] In addition, according to an embodiment of the present disclosure, the method according to various embodiments described above may be provided when the method is included in a computer program product. A computer program product refers to a product, and the product can be traded between a buyer and a seller. The computer program product may be distributed online in the form of a machine-readable storage medium (e.g., a compact disc read-only memory (CD-ROM)), or may be read through an application store (e.g., Play Store TM). In the case of online distribution, at least a portion of the computer program product may be at least temporarily stored in a storage medium such as a manufacturer's server, an application store's server, and a memory of a relay server, or may be temporarily generated.
[0169] In addition, according to an embodiment of the present disclosure, the various embodiments described above can be implemented in a recording medium, which can be read by a computer or a computer-like device using software, hardware or a combination thereof. In some cases, the embodiments described in this specification can be implemented by the processor itself. According to software implementation, embodiments such as the programs and functions described in this specification can be implemented by separate software modules. Each of the software modules can perform one or more functions and operations described in this specification.
[0170] Meanwhile, computer instructions for executing the processing operations of the machine according to the various embodiments described above may be stored in a non-transitory computer-readable medium. When the instructions are executed by the processor of a specific machine, the computer instructions stored in such a non-transitory computer-readable medium perform processing operations at the machine according to the various embodiments described above executed by the specific machine. A non-transitory computer-readable medium refers to a medium that stores data semi-permanently and can be read by a machine, rather than a medium that temporarily stores data (such as a register, a cache, and a memory). As specific examples of non-transitory computer-readable media, there may be CDs, DVDs, hard disks, Blu-ray discs, USBs, memory cards, ROMs, and the like.
[0171] In addition, each component (for example, module or program) according to the various embodiments described above can be composed of a single object or multiple objects. In addition, in the above-mentioned corresponding subcomponents, some subcomponents can be omitted, or other subcomponents can be further included in various embodiments. Usually or in addition, some components (for example: module or program) can be integrated into objects, and the functions performed by each component are performed in the same or similar manner before integration. The operations performed by the modules, programs or other components according to various embodiments can be performed sequentially, in parallel, repeatedly or heuristically. Or, at least some operations can be performed or omitted in different orders, or other operations can be added.
[0172] Although the preferred embodiments of the present disclosure have been shown and described so far, the present disclosure is not limited to the above-mentioned specific embodiments, and it is obvious that various modifications can be made by a person skilled in the art of the present disclosure without departing from the gist of the present disclosure as claimed in the appended claims. In addition, it is intended that such modifications should not be interpreted independently of the technical ideas or prospects of the present disclosure.
Claims
1. An electronic device, comprising: A storage device for storing a matrix used for an artificial intelligence model; as well as The processor is configured as: dividing data included in at least a portion of the matrix based on one of rows and columns of the matrix to form a plurality of row-based groups or a plurality of column-based groups, mapping each of the plurality of groups in a multi-dimensional space based on data included in each of the plurality of groups, clustering the plurality of groups into a plurality of clusters based on distances between the groups in the multidimensional space, and In the first case where data is divided based on the rows of the matrix to form a plurality of row-based groups: quantizing the data divided by the columns of the matrix among the data included in each of the plurality of clusters based on at least one representative value, and In the second case where data is divided based on the columns of the matrix to form a plurality of column-based groups: Data divided by the rows of the matrix among the data included in each of the plurality of clusters is quantized based on at least one representative value.
2. The electronic device according to claim 1, The processor is configured to: acquiring at least one representative value based on a size of first data included in a first group and a size of second data included in a second group among the groups included in each of the plurality of clusters, converting each of the first data and the second data into a binary code based on the at least one representative value, and quantizing each of the first data and the second data, and Wherein in the first case, the second data is in the same column as the first data, and in the second case, the second data is in the same row as the first data.
3. The electronic device according to claim 2, wherein the processor is configured to: The number of the at least one representative value is determined based on the number of the plurality of groups included in each of the plurality of clusters.
4. The electronic device according to claim 1, The processor is configured to: Obtaining output data for input data according to a matrix based on quantization, rearranging the output data based on clustering information, and The clustering information is obtained based on an operation of clustering the plurality of groups into the plurality of clusters.
5. The electronic device according to claim 1, Wherein the at least a portion of the matrix is a sub-region of the matrix determined based on the other of a row and a column of the matrix.
6. A control method, comprising: Dividing data included in at least a portion of the matrix for the artificial intelligence model based on one of a row and a column of the matrix to form a plurality of row-based groups or a plurality of column-based groups; mapping each of the plurality of groups in a multi-dimensional space based on data included in each of the plurality of groups, clustering the plurality of groups into a plurality of clusters based on distances between the groups in the multidimensional space; as well as In the first case where data is divided based on the rows of the matrix to form a plurality of row-based groups: quantizing the data divided by the columns of the matrix among the data included in each of the plurality of clusters based on at least one representative value, and In the second case where data is divided based on the columns of the matrix to form a plurality of column-based groups: Data divided by the rows of the matrix among the data included in each of the plurality of clusters is quantized based on at least one representative value.
7. The control method according to claim 6, The quantification includes: acquiring at least one representative value based on a size of first data included in a first group and a size of second data included in a second group among the groups included in each of the plurality of clusters, converting each of the first data and the second data into a binary code based on the at least one representative value, and quantizing each of the first data and the second data, and Wherein in the first case, the second data is in the same column as the first data, and in the second case, the second data is in the same row as the first data.
8. The control method according to claim 7, The quantification includes: The number of the at least one representative value is determined based on the number of the plurality of groups included in each of the plurality of clusters.
9. The control method according to claim 6, further comprising: obtaining output data for input data according to a matrix based on quantization, rearranging the output data based on clustering information, The clustering information is obtained based on an operation of clustering the plurality of groups into the plurality of clusters.
10. The control method according to claim 6, Wherein the at least a portion of the matrix is a sub-region of the matrix determined based on the other of a row and a column of the matrix.
Citation Information
Patent Citations
Interactive visualizations of a convolutional neural network
US20180095632A1
Flexible neural network accelerator and methods therefor
US20180121796A1