A large model compression method and system based on KAN network

By replacing the MLP structure in the language model with a KAN network, and using B-spline functions and L1 regularization terms to induce sparsity, the problems of uninterpretability and reduced generalization ability in large language model compression are solved, and a compact, Efficient model compression, suitable for BERT, GPT and other models.

CN118673969BActive Publication Date: 2024-10-29SHANDONG INSPUR SCI RES INST CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411146611.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-21
Publication Date
2024-10-29
Estimated Expiration
2044-08-21

AI Technical Summary

Technical Problem

Existing compression methods for large language models have problems such as poor compression generalization, uncontrollable effects, uninterpretable processes and reduced generalization capabilities, mainly due to the uninterpretability of the multi-layer perceptron (MLP) architecture.

Method used

A compression method based on the KAN network is adopted, by replacing the MLP structure in the language model with a three-layer KAN network. Each edge is associated with a learnable unary function, parameterized using a B-spline function, and L1 regularization is introduced during training. The optimization term induces sparsity, removes edges with weights less than the threshold, and approximates the B-spline activation function as a piecewise function to obtain a compression model.

Benefits of technology

While maintaining model performance, it significantly reduces the amount of parameters and inference calculations, provides higher modularity, interpretability and controllability, and is suitable for the compression of large language models, especially as a replacement for MLP.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118673969B_ABST
    Figure CN118673969B_ABST
Patent Text Reader

Abstract

The present invention proposes a large model compression method and system based on a KAN network, which belongs to the field of artificial intelligence technology. The multi-layer perceptron structure in a language model is replaced by a three-layer KAN network, wherein the first layer is composed of edges from input to hidden units, the second layer is composed of edges between hidden units, and the third layer is composed of edges from hidden units to outputs. Each edge is associated with a learnable unary function, and these functions are parameterized using B-splines. During model training, the sparsity of the KAN network is induced by introducing an L1 regularization term in the loss function, so that the weights of many edges tend to zero. After training, the edges with weights less than a threshold are removed, and the B-spline activation function is approximated as a piecewise function, so as to obtain a compact and efficient compression model. The model performance can be maintained while significantly reducing the amount of parameters and the amount of inference calculation, and the model can be widely used in the compression of various large language models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of artificial intelligence, and in particular relates to a large model compression method and system based on a KAN network. Background Art

[0002] In recent years, deep learning technology has made significant progress in natural language processing, computer vision, speech recognition and other fields. Large language models represented by Transformer, such as BERT, GPT-3, Llama, etc., have demonstrated excellent performance in tasks such as machine translation, text generation, and question-answering systems. However, these high-performance language models often contain hundreds of millions of parameters and extremely complex network structures, which brings huge resource overhead to the storage, training and reasoning of the models. Taking GPT-3 as an example, the huge computing resource consumption has seriously hindered the widespread application of large language models, especially in resource-constrained scenarios such as mobile devices and IoT.

[0003] In order to alleviate the redundancy problem of large language models, academia and industry have proposed many model compression methods, which can be mainly divided into four categories:

[0004] Pruning: Reduce the size of the model by removing unimportant connections or neurons in the network. Typical pruning algorithms include magnitude pruning, lottery ticket hypothesis, etc.

[0005] Quantization: Convert model weights from floating-point numbers to low-bit fixed-point numbers to compress storage space.

[0006] Knowledge Distillation: Use the soft targets of the large model to guide the training of the small model, so as to obtain a small model with performance close to that of the large model.

[0007] Matrix Decomposition: Decompose a large weight matrix into the product of multiple small matrices to reduce the number of parameters. Typical methods include low-rank decomposition and tensor decomposition.

[0008] Although the above methods have alleviated the redundancy problem of large language models to a certain extent, they still have some common limitations:

[0009] Poor compression generalization: Different compression methods are suitable for different model structures, and it is difficult to find a universal compression solution that is suitable for all models.

[0010] The compression effect is uncontrollable: Many compression methods require a lot of parameter adjustments and repeated trial and error to find a balance between high compression rate and low performance loss, and lack theoretical guidance.

[0011] The compression process is not interpretable: the internal structure and behavior of the model are changed after compression, but such changes are often opaque, making it difficult to explain the relationship between the model before and after compression.

[0012] The generalization ability of the compressed model is reduced: Model compression is essentially a process of information loss, which can easily make the compressed model overly dependent on training data and reduce its generalization ability.

[0013] The fundamental reason for these limitations is that most existing language models are based on the Multilayer Perceptron (MLP) architecture. As a "black box" model, MLP has highly complex internal structures and parameters and lacks clear physical meaning, making it difficult to perform fine-grained analysis and regulation. Although some methods have recently emerged to approximate MLP using interpretable models such as decision trees and automata, they are essentially post-hoc approximations of MLP after training rather than fundamentally changing the uninterpretability of MLP. In fact, such methods are not more advantageous than traditional compression methods in terms of the trade-off between compression rate and accuracy. Summary of the invention

[0014] In view of the problems in the prior art, the present invention provides a large model compression method and system based on a KAN network. The technical solution adopted in this application is:

[0015] In a first aspect, the present invention provides a large model compression method based on a KAN network, comprising:

[0016] Step 1: Replace the multi-layer perceptron structure in the language model with a three-layer KAN network. The first layer consists of edges from input to hidden units, the second layer consists of edges between hidden units, and the third layer consists of edges from hidden units to outputs. Each edge is associated with a learnable unary function.

[0017] Step 2: Use B-spline function to parameterize the univariate function in the KAN network;

[0018] Step 3: During model training, the L1 regularization term is introduced into the loss function to constrain the coordinates of the control points of the B-spline function and induce the sparsity of the KAN network;

[0019] Step 4: After training, remove the edges whose weights are less than the threshold in the KAN network to obtain a sparse network structure;

[0020] Step 5: Perform piecewise function approximation on the B-spline activation function of the remaining edges in the sparse KAN network to obtain a compressed language model;

[0021] Step 6: Use the compressed language model to fine-tune and test on downstream tasks.

[0022] Furthermore, in step 1, the first layer of the KAN network contains n×m edges, the second layer contains m×n edges, and the third layer contains n×k edges, where n is the input dimension, m is the hidden layer width, and k is the output dimension.

[0023] Furthermore, in step 2, the B-spline function uses cubic spline, and the number of control points is 10.

[0024] Furthermore, the L1 regularization term is the sum of the absolute values ​​of the coordinates of the control points of the B-spline function in each layer of the KAN network, which is added to the original loss function to obtain the total training target.

[0025] Furthermore, in step 4, the weight threshold is determined by searching on the validation set.

[0026] Furthermore, in step five, the piecewise function includes a low-order polynomial, an exponential function, a logarithmic function, a trigonometric function, etc., and the number of segments is 1 / 4 to 1 / 2 of the number of B-spline control points.

[0027] In a second aspect, the present invention provides a large model compression system based on a KAN network, comprising:

[0028] The model structure replacement module is configured to: replace the multi-layer perceptron structure in the language model with a three-layer KAN network, where the first layer consists of edges from input to hidden units, the second layer consists of edges between hidden units, and the third layer consists of edges from hidden units to outputs, and each edge is associated with a learnable unary function;

[0029] The function parameterization module is configured to: parameterize the univariate function in the KAN network using the B-spline function;

[0030] The sparse training module is configured to: introduce an L1 regularization term into the loss function during model training to constrain the coordinates of the control points of the B-spline function and induce the sparsity of the KAN network;

[0031] The model pruning module is configured to: after training, remove the edges with weights less than a threshold in the KAN network to obtain a sparse network structure;

[0032] The function approximation module is configured to: perform piecewise function approximation on the B-spline activation functions of the remaining edges in the sparse KAN network to obtain a compressed language model;

[0033] The fine-tuning and testing module is configured to use the compressed language model to perform fine-tuning and testing on downstream tasks.

[0034] In a third aspect, the present invention provides a computer-readable storage medium, the computer-readable storage medium comprising a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute the large model compression method based on the KAN network of the first aspect.

[0035] In a fourth aspect, the present invention provides an electronic device comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the electronic device is triggered to execute the large model compression method based on the KAN network of the first aspect.

[0036] Compared with the prior art, the advantages and positive effects of the present invention are:

[0037] The present invention replaces the multi-layer perceptron (MLP) structure in the language model with a three-layer KAN network, wherein the first layer consists of edges from input to hidden units, the second layer consists of edges between hidden units, and the third layer consists of edges from hidden units to output. Each edge is associated with a learnable unary function, which is parameterized using B-splines. During model training, the sparsity of the KAN network is induced by introducing an L1 regularization term in the loss function, so that the weights of many edges tend to zero. After training, edges with weights less than a threshold are removed, and the B-spline activation function is approximated as a piecewise function to obtain a compact and efficient compression model. The present invention can significantly reduce the amount of parameters and inference calculations while maintaining model performance, and can be widely used in the compression of various large language models, such as BERT, GPT, Llama, etc. Compared with the traditional MLP compression method, the present invention utilizes the natural sparsity and interpretability of the KAN network, and provides a new paradigm of language model compression that is more flexible, efficient, and controllable. While maintaining the powerful learning ability of MLP, it can provide higher modularity, interpretability, and controllability, thereby facilitating the implementation of model compression. It is very suitable as an alternative to MLP for the compression of large language models. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0039] Figure 1 The present invention is a flowchart of a large model compression method based on a KAN network. DETAILED DESCRIPTION

[0040] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described below in conjunction with the accompanying drawings and embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0041] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways than those described herein. Therefore, the present invention is not limited to the specific embodiments of the following disclosure.

[0042] Embodiment 1, as Figure 1 As shown, this embodiment provides a large model compression method based on a KAN network, specifically a large model compression method based on a Kolmogorov-Arnold network (KAN), which greatly reduces model parameters and calculation amount while maintaining the performance and generalization ability of the model as much as possible.

[0043] The core idea of ​​this invention is to replace the multi-layer perceptron (MLP) component in a large deep learning model with a KAN network, and to make the model sparse by using the sparsity, interactivity, interpretability and function approximation of the KAN network. The KAN network is a multi-layer network structure based on the Kolmogorov-Arnold representation theorem. According to this theorem, any continuous multivariate function can be expressed as a superposition of a finite number of univariate functions:

[0044]

[0045] in and are all one-dimensional continuous functions, n is the dimension of x, Q is a finite integer related to n, specifically, Q=2n+1. Inspired by this, the present invention uses a two- to three-layer KAN network to replace the MLP architecture widely used in large model structures:

[0046] In the KAN network, each layer consists of a set of edges rather than nodes in traditional neural networks. Specifically:

[0047] The first layer consists of edges, each edge connects an input to an output and with a learnable unary function Associated.

[0048] The second layer consists of m edges, each of which receives the sum of the outputs of the corresponding n edges in the first layer and passes a learnable unary function Produces the final output.

[0049] Described in mathematical language, for an input vector , the output of the qth second layer edge of the KAN network is:

[0050]

[0051] in is the connection weight from the first layer to the second layer. Unlike Kolmogorov’s theorem, and are all learnable activation functions, not predetermined. The final output of the KAN network is the sum of the outputs of all second-layer edges:

[0052]

[0053] This "layer" or "edge" design distinguishes the KAN network from traditional neural networks and brings unique advantages such as greater expressiveness and better interpretability.

[0054] However, in order to further improve the expressiveness and flexibility of the KAN network, the present invention can introduce an optional third layer after the second layer. The third layer is added to cover more complex situations. The original theorem only requires two layers, but there is no restriction on the smoothness of the function. In the machine learning task, the function must be smooth. In order to make the function smooth, a third layer is required. The third layer is also composed of a set of edges, each edge receives the output of the second layer and applies a learnable unary function Make the transformation.

[0055] Specifically, assuming that there are r edges in the third layer, the output of the rth edge in the third layer is:

[0056]

[0057] in is the connection weight from the second layer to the third layer.

[0058] After the third layer is introduced, the final output of the KAN network becomes the sum of the outputs of all third-layer edges:

[0059]

[0060] On this basis, the present invention further utilizes sparse training technology to induce the structural sparsity of the KAN network during the training process. Specifically, Regularization term:

[0061]

[0062] in:

[0063] is the regularization strength coefficient, which controls the degree of sparsification.

[0064] is the connection weight from the first layer to the second layer, that is, the function The piecewise linear function parameters of .

[0065] is the output function of the second layer The piecewise linear function parameters of .

[0066] K is the number of segments of the spline function.

[0067] m is the number of neurons in the second layer.

[0068] n is the dimension of the input.

[0069] The role of this L1 regularization term is to encourage the network to learn a sparse connection structure. Specifically:

[0070] For the connection weights from the first layer to the second layer , L1 regularization will lead to many becomes zero, causing the corresponding connections to be pruned. This achieves the sparseness of the first layer of the network.

[0071] For the output function parameters of the second layer , L1 regularization will lead to many becomes zero, which causes the output of the corresponding second-layer neurons to be always zero. This achieves the sparseness of the second layer of the network.

[0072] During the training process, this L1 regularization term is added to the original loss function to form a new objective function:

[0073]

[0074] in, is the loss function of the original large language model, is the L1 regularization term above, is the final loss function of the combination.

[0075] By minimizing this total loss function, the network will learn a structure that is as sparse as possible while fitting the data.

[0076] Considering the activation function of the KAN network and All are univariate functions, and the present invention uses B-spline functions to parameterize them:

[0077]

[0078] in:

[0079] K is the number of control points of the B-spline function.

[0080] d is the degree of the B-spline function, usually 3 (cubic B-spline) or 4 (quartic B-spline).

[0081] is the kth d-order B-spline basis function, which is a d-order piecewise polynomial function of x.

[0082] and It is the coordinate of the control point of the B-spline function and also the parameter that the network needs to learn.

[0083] The B-spline function has the following advantages:

[0084] Smoothness: The B-spline function is d-1 times continuously differentiable, so the resulting curve is very smooth. This can help the network learn a smoother function mapping.

[0085] Local support: Each B-spline basis function is non-zero only in a limited interval. This means that changing a control point will only affect the shape of the function in its local neighborhood. This property is conducive to the sparsity and interpretability of the network.

[0086] Shape flexibility: By adjusting the position and number of control points, the B-spline function can fit a variety of complex curve shapes. This gives the KAN network great flexibility to adapt to different data patterns.

[0087] During training, the network optimizes the coordinates of the control points and To learn the optimal shape of the activation function. At the same time, the present invention can also apply L1 regularization to the control point coordinates to encourage the generation of sparse B-spline functions:

[0088]

[0089] By using the B-spline function, the present invention allows the KAN network to learn a smoother, more flexible, and more interpretable activation function, while also enjoying the benefits of model compression and computational acceleration brought about by sparsification, which further improves the effectiveness and applicability of the method of the present invention.

[0090] Crucially, due to the core parameter of the KAN network - the learnable activation function and They are all one-dimensional functions. The present invention can approximate them into functions with simpler calculations after sparse training to reduce the calculation overhead during inference. Specifically:

[0091] For activation functions parameterized with B-spline functions:

[0092]

[0093] The present invention can convert the B-spline function into a piecewise function after sparse training, and each piecewise function can be a combination of a polynomial, an exponential function, a logarithmic function, a trigonometric function, etc.:

[0094]

[0095] in:

[0096] is the kth d-order B-spline basis function.

[0097] and are the coordinates of the control points of the B-spline function.

[0098] I is the number of knots of the B-spline function.

[0099] is the ith node interval.

[0100] and It is the function within the ith node interval, which can be a combination of polynomial, exponential function, logarithmic function, trigonometric function, etc.

[0101] is an indicative function, when The value is 1 when , otherwise it is 0.

[0102] In contrast, the MLP network is a black box structure, and the present invention does not know the connection function of the internal hidden layer. The KAN network provides the present invention with specific functions and combinations of each layer, allowing the present invention to perform manual or automatic function approximation operations, which greatly reduces the amount of calculation and makes the model further sparse.

[0103] Since the activation function and hidden layer function and parameters can be set manually, the controllability of the model is greatly increased. Other sparsification methods, such as the expert allocation and parameter activation of the hybrid expert model, are also black box logic, and the present invention does not know the internal logic; while this method can manually determine the function to be approximated or sparsified, making the process more controllable.

[0104] Step 1: Replace MLP with KAN network. MLP structure is widely used in BERT model, mainly in the following parts:

[0105] Word Embedding Layer: Maps each word in the vocabulary into a dense vector.

[0106] Feedforward Neural Network Layer: In each encoder block and decoder block of the Transformer, there is a feedforward layer consisting of two MLPs.

[0107] Output layer: Converts the output of the last Transformer block into a probability distribution over the target vocabulary.

[0108] For these MLPs, the present invention uses a three-layer KAN network with the following structure to replace them:

[0109] The first layer consists of n×m edges, connecting the n-dimensional x to the m-dimensional hidden state vector. Each edge connects an input to an output and with a learnable unary function Associated.

[0110] The second layer consists of m×n edges, each of which receives the sum of the outputs of the n edges corresponding to the first layer and passes a learnable unary function Produces output.

[0111] The third layer consists of n×k edges, each of which receives an output from the second layer and passes a learnable function Output to one of the corresponding k outputs.

[0112] Where n is the input dimension of MLP and m is the width of its hidden layer. Assuming that the structure of the original MLP is [n, m, n], the replaced KAN network can be expressed as:

[0113]

[0114] Step 2: Train the sparse KAN network. During the pre-training and fine-tuning phase of BERT, the present invention uses the replaced KAN structure for training. At the same time, an L1 regularization term is added to the loss function to induce the sparsity of the KAN network:

[0115]

[0116] Where L is the total number of layers of the KAN network in BERT, , are the input and hidden layer width of the l-th layer KAN, , , They are the coordinates of the B-spline control points of the three-layer edges of the l-th layer KAN.

[0117] In the BERT model after KAN replacement, the sparsification loss term of each KAN network layer l can be written as:

[0118]

[0119] in:

[0120] It is the overall sparsification strength coefficient, which controls the proportion of sparsification loss in the total loss function. The larger the value, the higher the degree of sparsification, but it may also affect the performance of the model, so a trade-off needs to be made. Set to 0.1.

[0121] and are the hidden layer width and input dimension of the l-th layer KAN network respectively.

[0122] , , They are the control point coordinates of the B-spline function on the edges of the three layers (first layer, second layer, and third layer) of the lth KAN network, and are also the parameters to be optimized.

[0123] L1 regularization encourages sparsity by taking the absolute value of each control point coordinate and summing them:

[0124] |a| means taking the absolute value of a. During the optimization process, it adds a constant gradient direction to the loss function, making the optimization algorithm tend to compress the parameters to 0.

[0125] right indivual Find the L1 norm and force many edge weights of the first layer to become 0, that is, delete the connection between the input x_p and the hidden unit.

[0126] right Find the L1 norm and make some edge weights of the second layer 0, that is, delete the connection between hidden units.

[0127] right Find the L1 norm to make the edge weights of the third layer sparse, which is equivalent to deleting the hidden units to the output connection.

[0128] Add the L1 loss terms of each layer to get the sparsification loss of the entire BERT model after replacing the KAN network:

[0129]

[0130] Where c is the number of layers in the network, l is the lth layer of the network, is the sparsification loss term of the network.

[0131] Where L is the total number of KAN networks in BERT. This term will be added as a regularization term to the loss function of BERT pre-training and fine-tuning:

[0132]

[0133] in It is the original loss function of the BERT model. is the sparsification loss term of the network, is the final term after combining with the original model.

[0134] After the training is completed, the KAN weight matrix obtained by the present invention , , will be sparse, that is, there are a large number of zero elements. This creates conditions for subsequent model pruning and compression. The present invention uses sparsity to remove edges with smaller weights (less than a certain threshold) in the KAN network. ), resulting in a more compact network structure without greatly affecting the model performance.

[0135] Step 3: B-spline parameterization of the activation function. For each KAN network’s activation function , , ,The present invention uses cubic B-spline function (d=3) for parameterization, and the number of control points K is 10:

[0136]

[0137]

[0138]

[0139] By adjusting the control point coordinates in L1 regularization , , By constraining the training, a sparse B-spline activation function can be obtained during the training process.

[0140] Step 4: Model sparseness. After training, for each KAN network’s three-layer edge, according to the weights obtained by L1 regularization, remove the connections whose absolute value is less than the threshold \epsilon to obtain a sparse network structure. The threshold \epsilon can be determined by searching on the validation set.

[0141] Step 5: Activation function approximation: for each edge remaining after the KAN network is sparsed, approximate its corresponding B-spline activation function , , is a piecewise function:

[0142]

[0143]

[0144]

[0145] The functions f_{qpi}, g_{qi}, h_{ri} in each interval [t_i, t_{i+1}) can be fitted with low-order polynomials or other simple functions according to the shape of the B-spline function. The number of intervals I can be taken as 1 / 4 to 1 / 2 of the number of original B-spline control points K. This step can further reduce the amount of calculation during inference.

[0146] Step 6: Application of the compressed model: fine-tune and test the compressed BERT model on downstream tasks (such as classification, sequence labeling, question answering, etc.) to evaluate its performance.

[0147] This example describes in detail how to replace the MLP in BERT with a KAN network and compress it using techniques such as sparse regularization, B-spline parameterization, and function approximation, which can significantly reduce the number of parameters and computational overhead during inference while maintaining model performance. This compression method is universal and can be applied to various large MLP-based language models, such as GPT, Llama, and Yi.

[0148] In practical applications, some modifications and optimizations can be made to this embodiment according to specific tasks:

[0149] The number of layers and width of the KAN network (i.e., m and n in step 1) are varied to balance performance and compression ratio.

[0150] Try different B-spline parameterization schemes, such as adjusting the number of control points K, the degree of spline function d, etc., to find the best smoothness and sparsity.

[0151] In the function approximation of step 5, a more appropriate piecewise function type is selected according to the actual shape of the B-spline function.

[0152] Combined with other model compression technologies, such as quantization, pruning, knowledge distillation, etc., the model size can be further reduced.

[0153] In summary, this embodiment provides a new language model compression method based on the KAN network. By cleverly utilizing the constructiveness of the Kolmogorov-Arnold theorem, the black box MLP is transformed into an interpretable, compressible, and computationally efficient structured network, providing new ideas for the application of large language models in resource-constrained scenarios.

[0154] Embodiment 2, the present invention provides a large model compression system based on a KAN network, comprising:

[0155] The model structure replacement module is configured to: replace the multi-layer perceptron structure in the language model with a three-layer KAN network, where the first layer consists of edges from input to hidden units, the second layer consists of edges between hidden units, and the third layer consists of edges from hidden units to outputs, and each edge is associated with a learnable unary function;

[0156] The function parameterization module is configured to: parameterize the univariate function in the KAN network using the B-spline function;

[0157] The sparse training module is configured to: introduce an L1 regularization term into the loss function during model training to constrain the coordinates of the control points of the B-spline function and induce the sparsity of the KAN network;

[0158] The model pruning module is configured to: after training, remove the edges with weights less than a threshold in the KAN network to obtain a sparse network structure;

[0159] The function approximation module is configured to: perform piecewise function approximation on the B-spline activation functions of the remaining edges in the sparse KAN network to obtain a compressed language model;

[0160] The fine-tuning and testing module is configured to use the compressed language model to perform fine-tuning and testing on downstream tasks.

[0161] Embodiment 3, the present invention provides a computer-readable storage medium, the computer-readable storage medium includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute the large model compression method based on the KAN network of embodiment 1.

[0162] Embodiment 4, the present invention provides an electronic device, comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the electronic device is triggered to execute the large model compression method based on the KAN network of Embodiment 1.

[0163] The electronic device may include: a processor, a memory and a communication unit. These components communicate via one or more buses. Those skilled in the art will appreciate that the structure of the electronic device does not limit the embodiments of the present invention, and it may be a bus structure or a star structure, or a combination of certain components, or different component arrangements.

[0164] The communication unit is used to establish a communication channel so that the electronic device can communicate with other devices, receive user data sent by other devices or send user data to other devices.

[0165] The processor is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It runs or executes software programs and / or modules stored in the memory, and calls data stored in the memory to perform various functions of the electronic device and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor can only include a central processing unit (CPU). In an embodiment of the present invention, the CPU can be a single computing core or multiple computing cores.

[0166] The memory is used to store the execution instructions of the processor. The memory can be implemented by any type of volatile or non-volatile storage device or a combination of them, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0167] When the execution instructions in the memory are executed by the processor, the electronic device is enabled to execute part or all of the steps of Embodiment 1.

[0168] The above description is only a preferred embodiment of the present invention and does not limit the present invention in other forms. Any technician familiar with the profession may use the technical content disclosed above to change or modify it into an equivalent embodiment with equivalent changes and apply it to other fields. However, any simple modification, equivalent change and modification made to the above embodiment based on the technical essence of the present invention without departing from the content of the technical solution of the present invention still falls within the protection scope of the technical solution of the present invention.

Claims

1. A large model compression method based on KAN network, characterized in that: include: Step 1: Replace the multi-layer perceptron structure in the language model with a three-layer KAN network. The first layer consists of edges from input to hidden units, the second layer consists of edges between hidden units, and the third layer consists of edges from hidden units to outputs. Each edge is associated with a learnable unary function. Step 2: Use B-spline function to parameterize the univariate function in the KAN network; Step 3: During model training, the L1 regularization term is introduced into the loss function to constrain the coordinates of the control points of the B-spline function and induce the sparsity of the KAN network; Step 4: After training, remove the edges whose weights are less than the threshold in the KAN network to obtain a sparse network structure; Step 5: Perform piecewise function approximation on the B-spline activation function of the remaining edges in the sparse KAN network to obtain a compressed language model; Step 6: Use the compressed language model to fine-tune and test on downstream tasks.

2. According to the large model compression method based on KAN network in claim 1, it is characterized in that: In step 1, the first layer of the KAN network contains n×m edges, the second layer contains m×n edges, and the third layer contains n×k edges, where n is the input dimension, m is the hidden layer width, and k is the output dimension.

3. The large model compression method based on KAN network according to claim 1 is characterized in that: In step 2, the B-spline function uses cubic spline and the number of control points is 10.

4. The large model compression method based on KAN network according to claim 1 is characterized in that: The L1 regularization term is the sum of the absolute values ​​of the coordinates of the control points of the B-spline function in each layer of the KAN network, which is added to the original loss function to obtain the total training target.

5. The large model compression method based on KAN network according to claim 1 is characterized in that: In step 4, the weight threshold is determined by searching on the validation set.

6. The large model compression method based on KAN network according to claim 1 is characterized in that: In step five, the piecewise functions include low-order polynomials, exponential functions, logarithmic functions and trigonometric functions, and the number of segments is 1 / 4 to 1 / 2 of the number of B-spline control points.

7. A large model compression system based on KAN network, characterized in that: include: The model structure replacement module is configured to: replace the multi-layer perceptron structure in the language model with a three-layer KAN network, where the first layer consists of edges from input to hidden units, the second layer consists of edges between hidden units, and the third layer consists of edges from hidden units to outputs, and each edge is associated with a learnable unary function; The function parameterization module is configured to: parameterize the univariate function in the KAN network using the B-spline function; The sparse training module is configured to: introduce an L1 regularization term into the loss function during model training to constrain the coordinates of the control points of the B-spline function and induce the sparsity of the KAN network; The model pruning module is configured to: after training, remove the edges with weights less than a threshold in the KAN network to obtain a sparse network structure; The function approximation module is configured to: perform piecewise function approximation on the B-spline activation functions of the remaining edges in the sparse KAN network to obtain a compressed language model; The fine-tuning and testing module is configured to use the compressed language model to perform fine-tuning and testing on downstream tasks.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute the large model compression method based on the KAN network as described in any one of claims 1-6.

9. An electronic device, characterized in that: It comprises a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the electronic device is triggered to execute the large model compression method based on the KAN network as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Small sample SAR image target detection method based on pruning element learning

    CN114677592A

  • Language model compression method based on uncertainty estimation knowledge distillation

    CN114819148A

  • Neural network acceleration and embedding compression systems and methods with activation sparsification

    US20190392323A1