A protein function prediction method based on an ESM-mamba hybrid architecture

By introducing a bidirectional Mamba state-space encoding layer into the ESM protein language model and performing progressive knowledge distillation training, the problems of high computational complexity and decreased representation ability of the Transformer model in long sequence processing are solved, and efficient protein function prediction is achieved.

CN123182770APending Publication Date: 2026-11-27NANJING UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611120845.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-27
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing Transformer-based protein language models suffer from high computational complexity and slow inference speed when dealing with long protein sequences, and their representational ability tends to decline after structural transfer, making them difficult to adapt to protein function prediction tasks.

Method used

We adopt an ESM-Mamba hybrid architecture, which introduces a bidirectional Mamba state space encoding layer into the pre-trained ESM protein language model and combines parameter transfer and progressive knowledge distillation training to gradually replace the self-attention layer with the Mamba state space layer, thereby maintaining the protein sequence representation ability while improving the efficiency of long sequence processing.

Benefits of technology

While maintaining the performance of protein function prediction, the efficiency of long sequence processing and inference is improved, the perturbation of the pre-trained representation space by structural substitution is reduced, and the stability and prediction efficiency of the model are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123182770A_ABST
    Figure CN123182770A_ABST
Patent Text Reader

Abstract

The application discloses a protein function prediction method based on an ESM-Mamba hybrid architecture, which is used to solve the problems of high computational time complexity of a protein language model based on a Transformer in long sequence processing and protein function prediction reasoning and easy decline of representation ability after structure migration. The method is based on a pre-training ESM model, retains part of the self-attention layer, and replaces the remaining layers with a bidirectional Mamba state space encoding layer to construct a hybrid architecture protein sequence encoder. In order to reduce the structure replacement disturbance, the feedforward network and layer normalization parameters in the original ESM layer are migrated, and the original ESM is used as a teacher model, combined with a mask language modeling loss and a knowledge distillation loss for progressive training. The trained model is applied to a protein function prediction task, improves the reasoning efficiency on the basis of maintaining the representation ability and prediction performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the fields of bioinformatics and deep learning technology, specifically relating to a protein function prediction method based on an ESM-Mamba hybrid architecture. Background Technology

[0002] Protein sequences contain information about structure, function, evolutionary relationships, and physicochemical properties. Effective modeling of protein sequences is a crucial foundation for protein function prediction. In recent years, protein language models based on large-scale protein sequence pre-training have been widely used. Among them, the ESM series models, which learn the contextual dependencies between amino acid residues through the Transformer self-attention mechanism, have demonstrated strong representation capabilities in protein function prediction tasks.

[0003] However, the Transformer self-attention mechanism has high computational complexity when handling long sequences. Protein sequences vary greatly in length, with some being quite long. In downstream inference tasks, Transformer-based protein language models tend to suffer from slow inference speed, high computational cost, and limited deployment efficiency. State-space models, such as Mamba, have good potential for modeling long sequences, but directly replacing the self-attention layer with a state-space layer can easily disrupt the original pre-trained representation space, leading to a decrease in representational ability and downstream performance.

[0004] Existing research has attempted to replace some Transformer attention layers with Mamba or linear recurrent structures in large natural language models, and combine knowledge distillation to maintain the original model's capabilities. However, these methods are mainly geared towards autoregressive text generation models and are difficult to directly adapt to protein language models that are based on bidirectional encoding and downstream prediction.

[0005] Against this backdrop, this invention proposes an ESM-Mamba hybrid architecture method for protein function prediction, which improves the efficiency of long sequence processing and function prediction inference while maintaining protein sequence characterization capabilities and protein function prediction performance as much as possible. Summary of the Invention

[0006] Objective: This invention addresses the problems of high time complexity and declining representational ability after structure transfer in existing Transformer-based protein language models for processing long protein sequences and predicting protein function. It proposes a protein function prediction method based on an ESM-Mamba hybrid architecture. This method introduces a bidirectional Mamba state-space encoding layer on top of a pre-trained ESM protein language model, and combines parameter transfer, stable initialization, and progressive knowledge distillation training to improve the efficiency of long sequence processing and function prediction inference while preserving protein sequence representation ability and protein function prediction performance as much as possible.

[0007] Technical solution: A protein function prediction method based on an ESM-Mamba hybrid architecture, comprising the following steps:

[0008] Step 1: Preprocess and encode protein sequence data: Obtain protein sequence data, clean the sequence, filter for homology similarity, truncate the length, and encode the tokens to obtain the protein sequence token representation;

[0009] Step 2: Construct an ESM-Mamba hybrid architecture protein language model: Load the pre-trained ESM protein language model, retain some self-attention coding layers according to the preset layer replacement strategy, and replace the remaining self-attention coding layers with bidirectional Mamba state space coding layers; at the same time, perform parameter transfer and stabilization initialization on the replaced model to obtain the ESM-Mamba hybrid architecture protein language model.

[0010] Step 3: For the ESM-Mamba hybrid architecture protein language model, a progressive knowledge distillation strategy is adopted for training: the original ESM protein language model is used as the teacher model, and the ESM-Mamba hybrid architecture protein language model is used as the student model. The student model is trained by combining masked language modeling loss and knowledge distillation loss, so that the student model can gradually adapt to the attention-state space hybrid structure while maintaining the original ESM representation ability.

[0011] Step 4: Save the trained model and test it on the protein function prediction task: Use the trained ESM-Mamba hybrid architecture protein language model as a protein sequence encoder to extract protein sequence representations and connect them to the function prediction module to complete the protein function prediction task test.

[0012] Furthermore, the implementation process of step 1 is as follows:

[0013] Acquire protein sequence data, including FASTA files, CSV files, or other data files containing amino acid sequences. Clean the protein sequences to remove illegal amino acid characters and non-compliant sequences; perform redundancy removal and homology similarity filtering on the protein sequences to reduce homology redundancy and data leakage risks between training data and target evaluation data; truncate the filtered protein sequences to a preset maximum length and perform word segmentation and encoding using the vocabulary corresponding to the ESM model to obtain protein sequence token representations.

[0014] Furthermore, the implementation process of step 2 is as follows:

[0015] The ESM-Mamba hybrid architecture protein language model is based on a pre-trained ESM protein language model and consists of a retained self-attention encoding layer, a replaced bidirectional Mamba state space encoding layer, a layer normalization module, a feedforward network module, and an output representation module. The pre-trained ESM protein language model contains N Transformer encoding layers, denoted as... , i∈{0,1,...,N-1}. Based on the preset layer replacement strategy, the N coding layers are divided into a set of self-attention-preserving layers. and Mamba replacement layer set In this model, the self-attention retention layer retains the original ESM model structure, while the Mamba replacement layer is replaced with a bidirectional Mamba state space encoding layer.

[0016] Furthermore, the preset layer replacement strategy retains the first and last self-attention encoding layers, and progressively replaces the intermediate layers at proportions of 25%, 50%, 75%, or all layers except the first and last layers; the Mamba replacement layer set in the later stage contains the Mamba replacement layer set in the previous stage, so that the model can inherit the trained parameters of the previous stage as the proportion of the state space encoding layer gradually increases.

[0017] Furthermore, the bidirectional Mamba state-space coding layer consists of an input layer normalization module, a forward Mamba module, a reverse Mamba module, a feature fusion module, a post-layer normalization module, a feedforward network module, and a residual connection module. The forward Mamba module models along the original direction of the protein sequence, while the reverse Mamba module models the hidden states of the protein sequence after flipping the sequence dimensions and then restores the modeling result by flipping it back. The outputs of the forward and reverse Mamba modules are fused with features and then residually connected to the input hidden states.

[0018] Furthermore, the feedforward network module maintains the same feedforward network structure as the corresponding layer of the original ESM model. During model construction, the feedforward network parameters and layer normalization parameters in the layer to be replaced in the original ESM model are migrated to the corresponding bidirectional Mamba state space encoding layer, and the output projection parameters of the forward and reverse Mamba modules are initialized to zero to reduce the perturbation of the pre-training representation space caused by the structural replacement. The hybrid architecture protein language model outputs a token-level hidden state representation of the protein sequence for subsequent training and protein function prediction.

[0019] Furthermore, the progressive knowledge distillation training process in step 3 is as follows:

[0020] 31. Perform dynamic masking on protein sequence tokens according to preset mask probabilities. Select the token to be predicted and exclude at least one special token from padding symbols, sequence start symbols, sequence end symbols and mask symbols to obtain mask language modeling training samples;

[0021] 32. Input the same masked language modeling training samples into the teacher model and student model respectively; where the teacher model is the original ESM protein language model, and the student model is an ESM-Mamba hybrid architecture protein language model, and obtain the output of the teacher model respectively. and student model output ;

[0022] 33. On the set M of masked token positions, output according to the student model. Calculate the mask language modeling cross-entropy loss with the real token label y. : Where CE(·) represents the cross-entropy loss;

[0023] 34. Set of non-filled token positions The knowledge distillation loss is calculated based on the output distributions of the teacher and student models. : Where T represents the distillation temperature coefficient, and KL(·) represents the Kullback-Leibler divergence;

[0024] 35. The total training loss L is modeled by the mask language and consists of cross-entropy loss. and knowledge distillation loss Weighted summation yields: ,in, The loss weight hyperparameter;

[0025] 36. Train the student model using the total training loss L, and perform progressive training from low to high according to the bidirectional Mamba state space coding layer replacement ratio; the student model parameters obtained from the previous training stage are used for the initialization of the student model in the next stage, so that the hybrid architecture protein language model gradually adapts to the attention-state space hybrid structure.

[0026] Furthermore, step 4 is implemented as follows:

[0027] The trained ESM-Mamba hybrid architecture protein language model is saved. The trained model is used as a protein sequence encoder to input downstream task data, extracting token-level hidden state representations of protein sequences. Pooling or feature fusion is performed on these token-level hidden state representations to obtain protein sequence-level representations. These protein sequence-level representations are then input into a function prediction module, outputting protein function prediction results. The downstream task is multi-label protein function prediction. Furthermore, task performance metrics and inference efficiency metrics are calculated on the downstream task to evaluate the representational ability and inference efficiency of the trained hybrid architecture protein language model.

[0028] Beneficial effects:

[0029] 1. This invention is based on a pre-trained ESM protein language model, introduces a bidirectional Mamba state space coding layer, and constructs an ESM-Mamba hybrid architecture protein language model, which can introduce a more efficient sequence modeling structure while maintaining the original protein sequence representation ability.

[0030] 2. This invention retains the first and last self-attention encoding layers and adopts a progressive layer replacement strategy, enabling the model to gradually transition from the original ESM structure to an attention-state space hybrid structure, thereby reducing the risk of decreased representational ability caused by a one-time structure replacement;

[0031] 3. This invention transfers the feedforward network parameters and layer normalization parameters of the layer to be replaced in the original ESM model to the corresponding bidirectional Mamba state space coding layer, and performs zero initialization on the output projection parameters of the bidirectional Mamba module, which can reduce the perturbation of the pre-trained representation space by the structural replacement and improve the stability of model transfer.

[0032] 4. This invention uses the original ESM protein language model as the teacher model, and combines masked language modeling loss and knowledge distillation loss to progressively train the ESM-Mamba hybrid architecture protein language model. This allows the student model to improve the efficiency of long sequence processing and functional prediction inference while maintaining the protein sequence representation ability and protein function prediction performance, and has good application value. Attached Figure Description

[0033] Figure 1 This is an overall flowchart of the protein function prediction method based on the ESM-Mamba hybrid architecture of this invention.

[0034] Figure 2 This is a structural diagram of the ESM-Mamba hybrid architecture protein language model of this invention.

[0035] Figure 3 This is a structural diagram of the bidirectional Mamba state space coding layer of the present invention.

[0036] Figure 4 This is a diagram illustrating the progressive knowledge distillation training strategy of this invention. Detailed Implementation

[0037] In the following description, specific details are set forth in order to provide a fuller understanding of the invention. However, it will be apparent to those skilled in the art that the invention can be practiced without one or more of these details. In other instances, certain technical features well-known in the art have not been described in detail to avoid obscuring the invention.

[0038] The present invention will now be described in further detail with reference to the accompanying drawings.

[0039] like Figure 1 As shown, this invention proposes a protein function prediction method based on an ESM-Mamba hybrid architecture, which aims to improve the efficiency of long protein sequence processing and function prediction inference while preserving the representational ability and protein function prediction performance of the pre-trained ESM protein language model as much as possible. The specific steps of this invention are as follows.

[0040] Step 1: Preprocess and encode the protein sequence data.

[0041] In this embodiment, the protein sequence data can come from FASTA files, CSV files, or other data files containing amino acid sequences. First, the protein sequences undergo basic cleaning to remove sequences containing illegal amino acid characters, sequences that do not meet length requirements, or sequences with abnormal formats. Then, the sequences are deredundanted and filtered for homology similarity to reduce homology redundancy and potential data leakage risks between pre-training data and target evaluation data. The cleaned and filtered sequences total approximately 400,000, which are truncated to a preset maximum length and input into the vocabulary converter corresponding to the ESM model to obtain protein sequence token representations.

[0042] When training a hybrid architecture protein language model, masked language modeling training samples are constructed based on protein sequence token representations. Specifically, these samples are trained according to a preset mask probability. Select the position to be predicted from non-special tokens, excluding special tokens such as padding symbols, sequence start symbols, sequence end symbols, and mask symbols; perform mask replacement, random token replacement, or keep the original token unchanged for the selected token positions, and set the unselected token labels as ignore markers so that they do not participate in the mask language modeling loss calculation.

[0043] Step 2: Construct an ESM-Mamba hybrid architecture protein language model.

[0044] like Figure 2 As shown, this invention constructs a hybrid architecture protein language model based on a pre-trained ESM protein language model. The pre-trained ESM model contains N Transformer encoding layers, denoted as... , i∈{0,1,...,N−1}. Based on the preset layer replacement strategy, each coding layer is divided into a set of self-attention-preserving layers. and Mamba replacement layer set For those belonging to The encoding layer retains the self-attention structure of the original ESM model unchanged; for those belonging to The original self-attention structure is replaced by a bidirectional Mamba state space coding layer.

[0045] In one specific implementation, the pre-trained ESM protein language model is a 30-layer ESM2 model, with encoding layers numbered from 0 to 29. Layers 0 and 29 serve as guard layers to maintain the self-attention structure. Intermediate layers are replaced using a progressive nested replacement method: the first stage replaces intermediate layers whose layer numbers satisfy i mod 4 = 3; the second stage replaces odd-numbered intermediate layers; the third stage replaces intermediate layers whose layer numbers do not satisfy i mod 4 = 0; and the fourth stage replaces all intermediate layers except layers 0 and 29. The Mamba replacement layer set of each subsequent stage contains the Mamba replacement layer set of the previous stage, thus achieving a gradual structural transformation from a low proportion to a high proportion.

[0046] Step 3: Construct a bidirectional Mamba state space coding layer.

[0047] like Figure 3 As shown, the bidirectional Mamba state-space coding layer includes an input layer normalization module, a forward Mamba module, a reverse Mamba module, a feature fusion module, a post-layer normalization module, a feedforward network module, and a residual connection module. The input hidden state is first processed by the input layer normalization module; then, the forward Mamba module performs state-space sequence modeling along the original direction of the protein sequence, and the reverse Mamba module first flips the protein sequence hidden state in the sequence dimension, then performs state-space sequence modeling, and finally flips the output result back to its original state.

[0048] The outputs of the forward and reverse Mamba modules are fused through addition to obtain the bidirectional state-space modeling result. This modeling result is then residually connected to the input hidden state, passed through a post-layer normalization module and a feedforward network module, and residually connected again to obtain the output of this layer. With this structure, the model can utilize the sequence modeling capabilities of the Mamba state-space module in a bidirectional contextual modeling scenario for protein sequences.

[0049] Step 4: Perform parameter migration and stability initialization.

[0050] To reduce the perturbation of the pre-trained representation space caused by structural replacement, this invention performs parameter migration and stabilization initialization when constructing the bidirectional Mamba state-space encoding layer. Specifically, the feedforward linear layer and normalization layer in the original ESM model to be replaced are migrated to the corresponding bidirectional Mamba state-space encoding layer and initialized with the original parameters; the weights and biases of the output projection layers of the forward and reverse Mamba modules are initialized to zero. Through these methods, the perturbation of the original model output by the replaced hybrid model is minimized in the initial stage of structural transformation, thus helping to maintain the original protein sequence representation capability.

[0051] Step 5: Train the model using a progressive knowledge distillation strategy.

[0052] like Figure 4 As shown, this invention employs a teacher-student distillation method to train an ESM-Mamba hybrid architecture protein language model. The teacher model is the original ESM protein language model, and the student model is the ESM-Mamba hybrid architecture protein language model. Training samples using the same mask language modeling are input into both the teacher and student models, respectively, to obtain the output of the teacher model. and student model output .

[0053] On the set of masked token positions M, calculate the masked language modeling cross-entropy loss based on the student model output and the real token labels: ;

[0054] Set of non-filled token positions The knowledge distillation loss is calculated based on the output distributions of the teacher and student models. , where T is the distillation temperature coefficient, and KL(·) represents the Kullback-Leibler divergence.

[0055] The total training loss is: ,in, This is the loss weight hyperparameter.

[0056] In one specific embodiment, the distillation training data consists of approximately 400,000 protein sequences that have undergone sequence cleaning, homology filtering, and length truncation. For different layer replacement ratios, corresponding ESM-Mamba hybrid architecture protein language models are constructed, and each stage of the model undergoes 10 rounds of distillation training. After training, the parameters of the current stage's student model are saved and used as the initialization parameters for the next stage's student model. This allows the model to inherit the protein sequence representation capabilities learned in the previous stage as the proportion of bidirectional Mamba state space encoding layers gradually increases.

[0057] Step 6: Save the model and test it on downstream tasks.

[0058] After completing progressive knowledge distillation training, the trained ESM-Mamba hybrid architecture protein language model is saved. This model is then used as a protein sequence encoder to input protein function prediction task data, extracting token-level hidden state representations of the protein sequences. Subsequently, pooling or feature fusion is performed on the token-level hidden state representations to obtain protein sequence-level representations, which are then input into the function prediction module to output protein function prediction results.

[0059] In specific downstream tasks, the function prediction module is configured as a multi-label classification module, used to output the predicted probabilities of proteins corresponding to multiple functional labels. In one specific embodiment, downstream task adaptation adopts a method of fixing the backbone parameters of the protein language model and training the function prediction module. The protein function multi-label prediction task is trained for 30 rounds, and the model parameters for the corresponding task are saved based on the validation set performance; the subcellular localization task and stability task are each trained for 20 rounds, and the model parameters for the corresponding tasks are also saved based on the validation set performance. During the testing phase, the model parameters that perform well on the validation set are loaded, and the prediction performance index and inference efficiency index are recorded on the test set to evaluate the inference efficiency of the hybrid architecture protein language model while maintaining representational ability and prediction performance.

[0060] As stated above, although the invention has been shown and described with reference to specific preferred embodiments, it should not be construed as limiting the invention itself. Various changes in form and detail may be made by those skilled in the art without departing from the spirit and scope of the invention as defined in the appended claims.

Claims

1. A protein function prediction method based on an ESM-Mamba hybrid architecture, characterized in that, include: Step 1: Obtain protein sequence data, clean, truncate, and encode the protein sequence data to obtain a protein sequence token representation; Step 2: Construct an ESM-Mamba hybrid architecture protein language model: Load the pre-trained ESM protein language model, determine the self-attention layers to be retained and the self-attention layers to be replaced according to the preset layer replacement strategy, replace the self-attention layers to be replaced with bidirectional Mamba state space coding layers, and initialize the parameters of the replaced model. Step 3: For the ESM-Mamba hybrid architecture model, a progressive knowledge distillation training strategy is adopted for training: the original ESM protein language model is used as the teacher model, and the ESM-Mamba hybrid architecture model is used as the student model. The training is carried out by combining masked language modeling loss and knowledge distillation loss, so that the student model can maintain the protein sequence representation ability of the original ESM model. Step 4: Apply the trained ESM-Mamba hybrid protein sequence encoder to the protein function prediction task. By extracting protein sequence representations and connecting them to the function prediction head, the protein function prediction results are output, and the computational overhead is reduced in the downstream training and inference stages.

2. The protein function prediction method based on the ESM-Mamba hybrid architecture according to claim 1, characterized in that, The hybrid architecture protein language model in step 2 is based on the pre-trained ESM protein language model and consists of a retained self-attention encoding layer, a bidirectional Mamba state space encoding layer, a layer normalization module, a feedforward network module, and an output representation module, specifically including: The pre-trained ESM protein language model contains N Transformer encoding layers, denoted as... , Based on the preset layer replacement strategy, the N coding layers are divided into a set of self-attention retention layers. and Mamba replacement layer set The self-attention retention layer retains the original ESM model structure, and the Mamba replacement layer is replaced by a bidirectional Mamba state space coding layer. The preset layer replacement strategy retains the first and last self-attention encoding layers, and replaces the intermediate layers at a ratio of 25%, 50%, 75%, or all except the first and last layers, so as to introduce a state space sequence modeling structure while maintaining the stability of the original ESM representation. The bidirectional Mamba state space coding layer consists of an input layer normalization module, a forward Mamba module, a reverse Mamba module, a feature fusion module, a post-layer normalization module, a feedforward network module, and a residual connection module. The forward Mamba module models along the original direction of the protein sequence, and the reverse Mamba module models and restores the sequence hidden state after flipping it. The outputs of the two modules are fused with features and then residually connected to the input hidden state. The feedforward network module maintains the same feedforward network structure as the corresponding layer of the original ESM model. During model construction, the feedforward network parameters and layer normalization parameters in the layer to be replaced in the original ESM model are migrated to the corresponding bidirectional Mamba state space coding layer, and the output projection parameters of the forward Mamba module and the reverse Mamba module are initialized to zero to reduce the perturbation of the pre-trained representation space by the structural replacement. The hybrid architecture protein language model outputs a token-level hidden state representation of the protein sequence, which is used for subsequent training and downstream task prediction.

3. The protein function prediction method based on the ESM-Mamba hybrid architecture according to claim 1, characterized in that, The progressive knowledge distillation training strategy in step 3 specifically includes: The protein sequence token is dynamically masked according to a preset mask probability. Select the token to be predicted and exclude at least one special token from padding symbols, sequence start symbols, sequence end symbols and mask symbols to obtain mask language modeling training samples; The same masked language modeling training samples are input into the teacher model and the student model respectively; the teacher model is the original ESM protein language model, and the student model is an ESM-Mamba hybrid architecture protein language model, and the output of the teacher model is obtained respectively. and student model output ; Set of masked token positions Above, output based on the student model Calculate the mask language modeling cross-entropy loss with the real token label y. : ; Set of non-filled token positions The knowledge distillation loss is calculated based on the output distributions of the teacher and student models. : Where T represents the distillation temperature coefficient, and KL(·) represents the Kullback-Leibler divergence; Total training loss Modeling cross-entropy loss using masked language and knowledge distillation loss Weighted summation yields: ,in, The loss weight hyperparameter; The progressive knowledge distillation training strategy proceeds in stages from low to high according to the bidirectional Mamba state space coding layer replacement ratio. The student model parameters obtained from the previous stage of training are used for the initialization of the student model in the next stage, so that the hybrid architecture protein language model gradually adapts to the attention-state space hybrid structure. Save the trained hybrid architecture protein language model and apply it as a protein sequence encoder to the protein function prediction task; in the downstream task, extract the protein sequence representation and connect it to the function prediction module to output the protein function prediction results.