A parameter-efficient protein language model design method based on self-supervised learning and Kronecker integral decomposition
Through self-supervised learning and Kronecker integral decomposition technology, the number of parameters and memory requirements of the protein language model are greatly reduced, which solves the problem of existing protein language models with many parameters and large resource usage, and achieves the goal of maintaining modeling capabilities while maintaining modeling capabilities. Provide efficient support for protein prediction tasks.
Patent Information
- Application Number
- CN202311439766.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-31
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2043-10-31
AI Technical Summary
Existing protein language models have many parameters, require large GPU memory, and are inconvenient to deploy, making it difficult to reduce resource requirements while maintaining modeling capabilities.
The method of self-supervised learning and Kronecker integral decomposition is used to represent the weight matrix of the fully connected layer as the sum of multiple small matrices, and singular value decomposition is performed through the Eckhart-Young theorem, the model parameters are initialized, and the matrix parameters are shared to reduce the number of parameters.
It significantly reduces the number of parameters and memory requirements of the model, while maintaining strong modeling capabilities and providing embedded features rich in biological information for protein structure prediction, folding identification and function prediction.
Smart Images

Figure CN117352049B
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of computational biology and relates to a protein language model design method, in particular to a parameter efficient protein language model design method based on self-supervised learning and Kronecker integral decomposition. Background Art
[0002] Proteins are multifunctional biomolecules composed of 20 amino acids, which play an irreplaceable role in many biological processes. With the rapid development of protein sequencing technology, the number of protein sequences has increased exponentially. In particular, large-scale protein sequence data contains important biological and evolution-related information. In recent years, the success of large models such as BERT, RoBERTa, GPT-3, GPT-4, and ChatGPT in the field of natural language has confirmed that self-supervised learning is a powerful tool for extracting information from unlabeled sequence data. If amino acids are regarded as characters or words and protein sequences are regarded as sentences, the protein sequence database can be regarded as a life language library. Therefore, self-supervised learning techniques in the field of natural language can be applied to protein sequence databases to learn biological information in sequence data.
[0003] Based on self-supervised learning technology and transformer models, several pre-trained protein language models have been proposed. The two most representative protein language models are ESM-1b [Rives, A., et al., Biological structure and function emerge from scaling unsupervised learning to 250 million protein sequences. Proceedings of the National Academy of Sciences, 2021. 118 (15): p. e2016239118.] and ProtTrans [Elnaggar, A., et al., ProtTrans: Towards Cracking the Language of Lifes Code Through Self-Supervised Deep Learning and High Performance Computing. IEEE Trans Pattern Anal Mach Intell, 2021. 14 (8).]. Multiple experiments have confirmed that the embedded features derived from pre-trained protein language models can significantly improve the performance of downstream tasks such as protein secondary structure prediction, protein folding recognition, and protein contact prediction. Recently, ESM-2 [Lin, Z., et al., Evolutionary-scale prediction of atomic-level protein structure with a language model. Science, 2023. 379 (6637): p. 1123-1130.] further demonstrated that large models can provide better embedding representations for protein structure prediction. In particular, the esm2_t48_15B_UR50D model with 15 billion parameters has reached a size of 60.52GB. Even a Tesla V100 with 32GB of video memory cannot run the model independently. Therefore, in order to facilitate deployment, it is necessary to develop a parameter-efficient lightweight protein language model while maintaining modeling capabilities to reduce the demand for resources such as video memory. Summary of the invention
[0004] In view of the shortcomings of existing protein language models, such as large number of parameters, large GPU memory requirements and inconvenient deployment, this paper proposes a parameter-efficient protein language model design method based on self-supervised learning and Kronecker integral decomposition. This method can not only ensure the modeling ability of the transformer model, but also significantly reduce the number of model parameters by expressing the weight matrix of the fully connected layer as the sum of multiple Kronecker products.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] On the one hand, the present invention provides a parameter-efficient protein language model design method based on self-supervised learning and Kronecker integral decomposition, comprising:
[0007] Step 1: Use the UniRef50 dataset as training data and perform training data preprocessing;
[0008] Step 2: Construct a small batch of data for self-supervised learning based on the preprocessed training data;
[0009] Step 3: Design a parameter-efficient protein language model based on Kronecker integral decomposition;
[0010] Step 4: Initialize model parameters;
[0011] Step 5: Train the protein language model based on self-supervised learning.
[0012] Furthermore, the training data preprocessing includes:
[0013] For protein sequences longer than 510, only the first 510 amino acid residues are retained, and all non-standard amino acids B, J, O, U and Z in the protein sequence are replaced by X.
[0014] Furthermore, the step 2 comprises:
[0015] First, randomly sample N protein sequences from the training data to form a small batch, calculate the maximum length maxL of the N protein sequences, and then add markers before and after each protein sequence <cls>and <eos>, so that the length of the longest protein sequence in the mini-batch reaches maxL+2, and then the protein sequences in the mini-batch are randomly masked.
[0016] Furthermore, the protein language model is composed of multiple transformer blocks stacked together, and the output of the last transformer block is fed into a fully connected layer and Softmax for multi-class classification. Each transformer block consists of a multi-head attention module and a feedforward module. The multi-head attention module uses a rotational position embedding method to introduce relative position information for queries and keys. The feedforward module includes a feedforward network, which is composed of two layers of fully connected layers and a nonlinear activation function.
[0017] Furthermore, the multi-head attention module and the feed-forward module both adopt residual connection and layer normalization.
[0018] Furthermore, the weight matrix of each fully connected layer is represented as the sum of the Kronecker products of multiple small matrices:
[0019] make represents the weight matrix of the fully connected layer, which can be expressed based on the Kronecker product as:
[0020]
[0021] in, and is the parameter matrix that needs to be learned, both p and q can be hyperparameters divisible by , m represents the number of control parameter matrices.
[0022] Furthermore, for multiple transformer blocks, in order to further reduce the number of parameters, all fully connected layers at the same position can share the matrix parameter set
[0023] Furthermore, the step 4 comprises:
[0024] For each fully connected layer, firstly based on the uniform distribution Generate a random matrix Then initialize based on W and
[0025]
[0026] in represents the square of the matrix Frobenius norm;
[0027] Transform the above formula:
[0028]
[0029] The matrix It is constructed by permuting the matrix W. vec(.) means converting the matrix into a vector in row-first order.
[0030] According to the Eckhart-Young theorem, the above optimization problem is solved. If the matrix The singular value decomposition of The singular values are σ i , and σ1≥σ2≥…≥σ min{p,q} , vector u i 、v i They are σ i The left singular vector and right singular vector of the matrix A i and B i The initial value of is:
[0031]
[0032] where φ(·) represents the transformation of a vector into a matrix of the corresponding shape in row-major order.
[0033] Furthermore, in step 5, the loss function of training the protein language model is:
[0034]
[0035] in Represents a given small batch of input data The corresponding label matrix and binary masking matrix; Y ij and M ij They are and The elements in Y ij represents the label corresponding to the jth position in the i-th sequence in the mini-batch, M ij = 1 means that the jth position in the i-th sequence in the mini-batch is masked, M ij = 0 means that the jth position in the i-th sequence in the mini-batch is not masked; N is the batch size; L is the length of the largest protein chain; Represents the probability tensor output by the model after X is input into the protein language model.
[0036] The present invention also proposes an application of a parameter-efficient protein language model obtained based on any of the above methods in protein structure prediction, protein folding recognition and protein function prediction.
[0037] Compared with the prior art, the present invention has the following beneficial effects:
[0038] The present invention discloses a parameter-efficient protein language model design method based on self-supervised learning and Kronecker integral decomposition. Based on the powerful modeling ability of the transfomer model, the method adopts self-supervised learning technology to learn useful biological information from large-scale protein sequence data. In particular, in order to reduce the demand for video memory of the protein language model for easy deployment, the present invention first represents the weight matrix of the fully connected layer as the sum of the Kronecker products of multiple small matrices, and then designs a singular value decomposition method based on the Eckhart-Young theorem to initialize the small matrix parameter set. The design method proposed by the present invention can significantly reduce the number of parameters while maintaining the modeling ability of the protein language model. In addition, the pre-trained protein language model obtained based on the present invention can provide embedded features rich in biological information for tasks such as protein structure prediction, protein folding recognition and protein function prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 A basic flow chart of a parameter-efficient protein language model design method based on self-supervised learning and Kronecker integral decomposition according to an embodiment of the present invention;
[0040] Figure 2 Schematic diagram of the network architecture of the parameter-efficient protein language model according to an embodiment of the present invention. DETAILED DESCRIPTION
[0041] The present invention will be further explained below with reference to the accompanying drawings and specific embodiments:
[0042] like Figure 1 As shown, a parameter-efficient protein language model design method based on self-supervised learning and Kronecker integral decomposition includes:
[0043] Step 1: Preprocessing of training data. The present invention uses the non-redundant protein sequence dataset UniRef50 (https: / / ftp.uniprot.org / pub / databases / uniprot / uniref / uniref50 / uniref50.fasta.gz) as training data, which is obtained by clustering the UniRef100 dataset based on a 50% sequence consistency threshold. At present, the UniRef50 dataset contains more than 60 million protein sequences, each of which is composed of 20 standard amino acids (A, C, D, E, F, G, H, I, K, L, M, N, P, Q, R, S, T, V, W and Y) and 6 non-standard amino acids (B, J, O, U, X and Z). The length of a protein sequence can reach tens, hundreds, thousands or even tens of thousands. In order to train a protein language model, the UniRef50 dataset needs to be preprocessed. First, for protein sequences with a length greater than 510, only the first 510 amino acid residues are retained. This is because longer sequences not only require more video memory, but also increase the time for forward and backward propagation. Secondly, all non-standard amino acids B, J, O, U, and Z in the protein sequence are replaced by X. This is because non-standard amino acids appear very rarely, and merging all non-standard amino acids into one token type does not reduce the performance of the model.
[0044] Step 2: Construct a mini-batch for self-supervised learning. In order to perform self-supervised learning based on the preprocessed UniRef50 dataset, it is necessary to first randomly sample N protein sequences from the dataset to form a mini-batch, and then randomly mask the protein sequences in the mini-batch. The goal of self-supervised learning is to predict the masked amino acid category based on the unmasked contextual information in the amino acid sequence. In particular, the mini-batch requires that all protein sequences have the same length. To this end, first calculate the maximum length maxL of the N protein sequences, and then add tokens in front and behind each protein sequence. <cls>and <eos>In this way, the length of the longest protein sequence in the mini-batch reaches maxL+2. For other protein sequences, we fill them with multiple <pad>So that its length also reaches maxL+2. The setting based on step 2 ensures that the maximum value of the mini-batch length dimension is 512. In addition, for each protein sequence, the present invention randomly selects 20% of the positions for masking. In particular, if the token corresponding to the masked position is not an amino acid, it is not masked. For the masked amino acid, in 90% of the cases it is replaced by <mask>, which was replaced by a random amino acid of a different type than it in 10% of cases.
[0045] Step 3: Design a parameter-efficient protein language model based on Kronecker integral decomposition. Figure 2 The protein language model network architecture used in the present invention is given. Figure 2 It can be seen that the protein language model is mainly composed of n stacked transformer blocks. Each transformer block consists of a multi-head attention module and a feedforward module. For the multi-head attention module, it uses a rotation position embedding method to introduce relative position information for the query Q and key K. In particular, compared with other position embedding methods, the rotation position embedding has a stronger length extrapolation ability. For the feedforward module, the feedforward network can be constructed by stacking two layers of fully connected layers and nonlinear activation functions. In addition, both the multi-head attention module and the feedforward module use residual connections and layer normalization. The output of the last transformer block is fed into the fully connected layer FC and Softmax for multi-class classification of 21 categories. Obviously, the parameters of the protein language model are mainly concentrated in the fully connected layer.
[0046] In order to obtain a parameter-efficient protein language model, the present invention represents the weight matrix of each fully connected layer as the sum of the Kronecker products of multiple small matrices. The advantage of this representation is that it can significantly reduce the number of model parameters while maintaining the modeling capability of the model. Specifically, let represents the weight matrix of a fully connected layer, it can be expressed as follows based on the Kronecker product:
[0047]
[0048] in, and is the parameter matrix to be learned. Here, we assume that both p and q can be hyperparameterized For example, when the values of p and q are 1024, and the values of r and m are 32, the Kronecker integral decomposition can reduce the number of parameters of the weight matrix W to 1 / 16 of the original. In addition, the number of parameters of the protein language model can be further reduced by parameter sharing. For n transformer blocks, all fully connected layers at the same position can share the matrix parameter set This can reduce the number of parameters by almost half, and each fully connected layer only needs to save and learn the matrix parameter set
[0049] Step 4: Initialize model parameters. For the designed parameter-efficient protein language model, the parameters in the embedding layer and normalization layer can be initialized using the default method in the deep learning framework PyTorch or TensorFlow. For the fully connected layer after the introduction of the Kronecker integral decomposition, the matrix parameter set and Design an effective initialization method. To this end, for each fully connected layer, the present invention firstly uses a uniformly distributed Generate a random matrix Then initialize based on W and Specifically, the parameter matrix group The initialization can be expressed as the following generalized Kronecker decomposition problem:
[0050]
[0051] in Represents the square of the matrix Frobenius norm. For the above formula, it can be further transformed into the following form:
[0052]
[0053] The matrix It is constructed by permuting the matrix W. vec(.) means converting the matrix into a vector in row-priority order.
[0054] According to the Eckhart-Young theorem, the above optimization problem is solved. If the matrix The singular value decomposition of The singular values are σ1≥σ2≥…≥σ min{p,q} , then the matrix A i and B i The initial value of is:
[0055]
[0056] where φ(·) represents the transformation of the vector into a matrix of the corresponding shape in row-major order. For the shared matrix parameter set In the case of The initial value is then averaged based on the number of shares.
[0057] Step 5: Train the protein language model based on self-supervised learning. For a given mini-batch input data Let the corresponding label matrix and binary masking matrix be and where Y ij ∈[0,1,...,20],M ij = 1 means that the jth position in the i-th sequence in the mini-batch is masked; otherwise, M ij = 0. Assume that after X is input into the protein language model, the probability tensor output by the model is The loss function for training the protein language model can be defined as:
[0058]
[0059] Based on this loss function, we use the optimizer Lion recently proposed by Google to train the protein language model. Compared with the optimizer AdamW, Lion not only requires less video memory, but also has better generalization ability and faster computing speed. During training, the mini-batch size is set to 2048 and the learning rate is set to 1e-5. In order to obtain parameter-efficient protein language models of different sizes, training can be performed based on m equal to 16, 32, 64 and 128 respectively. For the model obtained through training, its last two layers of FC and Softmax will be deleted. The model after deleting the last two layers is usually called a pre-trained protein language model, which can be used for many downstream tasks such as protein tertiary structure prediction, protein secondary structure prediction, protein folding recognition, protein localization prediction and protein function prediction.
[0060] The present invention also proposes an application of a parameter-efficient protein language model obtained based on any of the above methods in protein structure prediction, protein folding recognition and protein function prediction.
[0061] The above is only a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.< / mask> < / pad> < / eos> < / cls> < / eos> < / cls>
Claims
1. A parameter-efficient protein language model design method based on self-supervised learning and Kronecker integral decomposition, characterized in that: include: Step 1: Use the UniRef50 dataset as training data and perform training data preprocessing; Step 2: Construct a small batch of data for self-supervised learning based on the preprocessed training data; Step 3: Design a parameter-efficient protein language model based on Kronecker integral decomposition; the protein language model is composed of a plurality of transformer blocks stacked together, the output of the last transformer block is fed into a fully connected layer and Softmax for multi-class classification, each transformer block is composed of a multi-head attention module and a feedforward module, the multi-head attention module uses a rotation position embedding method to introduce relative position information for queries and keys, the feedforward module includes a feedforward network, and the feedforward network is composed of stacking two layers of fully connected layers and a nonlinear activation function; The weight matrix of each fully connected layer is represented as the sum of the Kronecker products of multiple small matrices: make represents the weight matrix of the fully connected layer, which can be expressed based on the Kronecker product as: in, and is the parameter matrix that needs to be learned, both p and q can be hyperparameters divisible, m represents the number of control parameter matrices; Step 4: Initialize model parameters; The step 4 comprises: For each fully connected layer, firstly based on the uniform distribution Generate a random matrix Then initialize based on W and in represents the square of the matrix Frobenius norm; Transform the above formula: The matrix It is constructed by permuting the matrix W. vec(.) means converting the matrix into a vector in row-first order. According to the Eckhart-Young theorem, if the matrix The singular value decomposition of The singular values are σ i , and σ1≥σ2≥…≥σ min{p,q} , vector u i 、v i They are σ i The left singular vector and right singular vector of the matrix A i and B i The initial value of is: Where φ(·) represents the transformation of a vector into a matrix of corresponding shape in row-major order; Step 5: Train the protein language model based on self-supervised learning.
2. The method for designing a parameter-efficient protein language model based on self-supervised learning and Kronecker integral decomposition according to claim 1, characterized in that: The training data preprocessing includes: For protein sequences longer than 510, only the first 510 amino acid residues are retained, and all non-standard amino acids B, J, O, U and Z in the protein sequence are replaced by X.
3. The method for designing a parameter-efficient protein language model based on self-supervised learning and Kronecker integral decomposition according to claim 1, characterized in that: The step 2 comprises: First, randomly sample N protein sequences from the training data to form a small batch, calculate the maximum length maxL of the N protein sequences, and then add markers before and after each protein sequence <cls>and <eos> , so that the length of the longest protein sequence in the mini-batch reaches maxL+2, and then the protein sequences in the mini-batch are randomly masked.< / eos> < / cls> 4. The method for designing a parameter-efficient protein language model based on self-supervised learning and Kronecker integral decomposition according to claim 1, characterized in that: The multi-head attention module and feed-forward module both use residual connection and layer normalization.
5. The method for designing a parameter-efficient protein language model based on self-supervised learning and Kronecker integral decomposition according to claim 1, characterized in that: For multiple transformer blocks, in order to further reduce the number of parameters, all fully connected layers at the same position can share the matrix parameter set 6. The method for designing a parameter-efficient protein language model based on self-supervised learning and Kronecker integral decomposition according to claim 1, characterized in that: In step 5, the loss function of training the protein language model is: in Represents a given small batch of input data The corresponding label matrix and binary masking matrix; Y ij and M ij They are and The elements in Y ij represents the label corresponding to the jth position in the i-th sequence in the mini-batch, M ij = 1 means that the jth position in the i-th sequence in the mini-batch is masked, M ij = 0 means that the jth position in the i-th sequence in the mini-batch is not masked; N is the batch size; L is the length of the largest protein chain; Represents the probability tensor output by the model after X is input into the protein language model.
7. A method for applying the parameter-efficient protein language model obtained by the method according to any one of claims 1 to 6 to protein structure prediction, protein folding recognition and protein function prediction.
