Skip to main content
iScience logoLink to iScience
. 2025 Sep 3;28(10):113495. doi: 10.1016/j.isci.2025.113495

Efficient inference, training, and fine-tuning of protein language models

Muhammed Hasan Çelik 1,2, Xiaohui Xie 1,3,
PMCID: PMC12481099  PMID: 41035687

Summary

Protein language models (PLMs) have shown great promise in protein structure and function predictions, but their adoption is limited by computational cost. We address this challenge by enhancing the efficiency of evolutionary scale modeling (ESM). Using FlashAttention and sequence packing, we achieve 4–9× faster inference and 3–14× lower memory usage. Four-bit quantization of billion-parameter models further reduces memory by 2–3× while preserving accuracy for missense variant effect prediction. Training is also optimized, cutting runtime 6-fold with methods, such as activation checkpointing and DeepSpeed zero-offload. Parameter-efficient fine-tuning of a few adapter weights yields state-of-the-art performance at protein property and function predictions, resulting in 70% Spearman’s correlation for melting point and 87% AU-PRC for transcription factor identification. Our efficient ESM (ESME) implementation significantly lowers the barrier to using these powerful models, making them accessible to academic laboratories with limited computational resources. The code is available on GitHub.

Subject areas: Protein, Bioinformatics

Graphical abstract

graphic file with name fx1.jpg

Highlights

  • FlashAttention and sequence packing enable 4–9× faster inference and 3–14× lower memory usage

  • Introducing weight quantization reduces memory usage by 2–3× with minimal accuracy loss

  • Training runtime is reduced 6-fold using activation checkpointing and zero-offload

  • Parameter-efficient fine-tuning achieves state-of-the-art performance in function prediction


Protein; Bioinformatics

Introduction

An in-depth understanding of protein properties and function is crucial for the discovery of the mechanisms underlying essential cellular processes.1 Deep learning techniques have long been employed for various in-silico protein prediction tasks2 and recently led to breakthroughs in structure prediction.3,4,5,6,7 Furthermore, protein language models (PLMs) enable the prediction of protein properties,8,9 function,10 and the effect of the missense variants on protein fitness and disease.11,12,13 Recent advances have been achieved by the adaptation of large language models (LLMs) based on the transformer architecture from natural language processing (NLP)14,15 to the proteomics field.9,16,17,18,19,20 These models, known as PLMs, leverage abundant protein sequence data, and are trained using semi-supervised objectives to predict masked amino acids from the surrounding protein sequence context.21,22 As a result, the attention mechanism in the transformer layers captures the complex interactions between the amino acids during the semi-supervised training to predict masked amino acids. Traditional sequence-based alignment methods can capture pairwise conservation between amino acids; however, modeling higher-order interactions is computationally intractable and requires heuristic approximations.23 In contrast, deep learning models capture high-order epistatic interactions and context-dependent sequence constraints.24,25 Thus, PLMs can perform a wide range of downstream tasks, including protein structure prediction.3,6

PLMs facilitate protein prediction tasks, particularly when supervised training data are limited. These models are fine-tuned to predict biochemical properties by leveraging predicted structures and contextualized sequence embeddings. For example, after fine-tuning with a small number of additional training samples, PLMs can accurately predict various biochemical properties, such as folding stability22,26,27 and melting point.28 By capturing intrinsic features and conserved amino acids, PLMs enable effective generalization through few-shot learning. Beyond structural predictions, PLMs also infer biophysical features, such as protein dynamics in disordered regions29 and phase transitions.30 Since the properties of proteins determine their functions, PLMs are also highly effective in predicting the functional characteristics of proteins. For instance, PLMs can accurately predict gene ontology (GO) terms10 and enzyme commission (EC) numbers31,32 directly from amino acid sequences. Furthermore, the prediction of protein-protein and protein-small molecule interactions5 is crucial for understanding the role of proteins in biological processes, and PLMs can predict these interactions, including ligand-binding proteins,33 peptide-T cell receptor interactions,34 and drug-protein interactions.35,36,37 Finally, PLMs have important applications in protein design, enabling the generation of amino acid sequences with specified characteristics,38,39 thereby facilitating computational approaches in drug development.

Another application of PLMs is the variant effect prediction of missense variants.11,12,13 Classifying deleterious missense variants from benign ones is critical for the identification of pathogenic variants in disease studies. The PLMs learn the natural sequence space of the proteins selected by evolution; thus, they can estimate the variants disrupting the protein fitness. Learning the sequence distribution of homolog proteins and the co-conservation of amino acids reveals the epistatic interactions and improves variant effect prediction.24,25,40

A significant challenge in utilizing PLMs is their substantial computational cost, with training requiring thousands of GPU hours on large computing clusters.41 This high computational cost makes training PLMs from scratch impractical, especially for researchers relying on academic laboratory-grade computation infrastructure, thereby limiting the ability to experiment with different modeling choices and hindering progress in research. Furthermore, inference and fine-tuning of these models are computationally expensive; our initial experiments revealed that inference on long protein sequences often results in memory errors. Fine-tuning, which requires backpropagation, further increases memory requirements. The large memory footprint also constrains the batch size during fine-tuning, which is essential for stable training and objectives like contrastive learning. Recent advances in efficient inference,42 fine-tuning,43 and training methods44,45 in the LLMs literature offer a promising solution to these limitations; thus, adapting these techniques could also facilitate the broader use of PLMs.

In this work, we implemented techniques to enhance the efficiency of PLMs and benchmarked their performance across various tasks, including variant effect prediction, using our reimplementation of the widely used evolutionary scale modeling (ESM) family, including ESM1v, ESM1b, ESM2, and ESM-Cambrian (ESM-C) models. We integrated widely used techniques like Flash-Attention46 and sequence packing to efficiently handle proteins of variable lengths, leading to a substantial reduction in both inference and training time, as well as memory usage. These reimplemented models achieve performance comparable to the original models in missense variant effect prediction based on the ProteinGym benchmark dataset,47 confirming the correctness of our implementation. Moreover, we achieve state-of-the-art performance on protein properties on the fitness landscape inference for proteins (FLIP) benchmark dataset28 and function prediction by only training a small fraction of model weights. Overall, the approaches employed in this work greatly improve the efficiency of PLMs and enable their use on academic computing infrastructure. Our open-source, efficient implementation ESME is available on PyPI (pypi.org/project/esm-efficient), GitHub (github.com/uci-cbcl/esm-efficient), and HuggingFace (huggingface.co/mhcelik/esm-efficient).

Results

We applied a combination of efficient LLM techniques to the ESM models, chosen for their standard transformer architecture, which facilitates the easy adaptation of LLM methods from NLP. We conducted in-depth benchmarking of the original ESM and efficient ESME reimplementation for inference, training, and downstream fine-tuning tasks (Figure S1).

Benchmarking the model inference

The first technique we leveraged in the efficient ESME implementation is FlashAttention.46 FlashAttention is an efficient, IO-aware self-attention algorithm that optimizes memory usage and runtime for long sequences by minimizing read/write operations between high-bandwidth memory (HBM) and SRAM while fusing operations to reduce memory overhead (STAR Methods). To demonstrate performance gains, we sampled proteins of varying lengths from UniProtKB/Swiss-Prot48 and measured runtime and memory usage. Inference performance was benchmarked on NVIDIA A100 GPUs using ESM2 models ranging from 8 million to 15 billion parameters, with a batch size of 16 proteins in brain floating point (bfloat16)49 for both original and efficient implementations. ESM1v and ESM1b were not included in this benchmark, as their behavior is comparable to the similarly sized ESM2 650M model. Adapting FlashAttention can reduce model runtime by ∼3–10 times across all model sizes, depending on protein length (Figure 1A; Table S1). For example, inference on a batch of 16 proteins with lengths of 300–400 residues takes ∼0.07 s with the ESME-2 650M model, compared to ∼0.21 s with the original implementation. The runtime of the models with FlashAttention scales linearly with input size, whereas the dot-product attention in the original implementation scales quadratically. Similarly, memory usage scales quadratically with input size in the dot-product attention implementation, limiting the batch size and inference on large proteins (Figure 1B; Table S2). Long protein sequences are often truncated to avoid an out-of-memory (OOM) error; however, FlashAttention maintains a small memory footprint even for large proteins. For instance, the 3-billion-parameter ESME-2 model uses approximately 5.6 gigabytes (GB) of GPU memory for a batch of proteins 300–400 amino acids long and no more than ∼8.4 GB for proteins up to 3,500 amino acids. In contrast, the original implementation cannot handle proteins longer than 3,000 amino acids for billion parameter models.

Figure 1.

Figure 1

The benchmark of inference performance

(A) The runtime comparison between the original ESM2 model (solid line) and ESME2 (dashed line) demonstrates the reduction in runtime as protein length increases (batch size of 16 proteins in subfigures A–C). M and B are abbreviations for million and billion, respectively.

(B) The benchmark of memory usage shows that FlashAttention scales linearly with sequence length, while dot-product attention scales quadratically.

(C) The model quantization techniques effectively reduce memory usage, but their impact is significant only in billion-scale models.

The proteins vary significantly in length; for example, ∼12% of human proteins are longer than 1000 amino acids, while the median protein is 414 amino acids long (Figures S2A and S2B). With linear scaling, the GPU memory usage of a batch of proteins can be quantified by the number of token (amino acid) count in the batch. Consequently, we engineered dataloaders that prepare batches based on token count rather than the number of proteins (Figure S3). To efficiently handle batches with varying protein lengths and maximize GPU utilization, we utilize sequence packing,50 which concatenates variable-length protein sequences into a single long chain without padding and utilizes attention masks to preserve batch structure (STAR Methods). Regardless of model size, FlashAttention with sequence packing can handle up to 100,000 tokens without memory errors (Figure S4). This combination ensures consistent computational load across batches, achieving full GPU utilization and enhancing model inference performance 9.4-fold for ESM2 and 3.8-fold for ESM-C models (Figure S5). The small footprint of FlashAttention and extending batch sizes using sequence packing could further enable training large PLMs on tasks involving protein complexes51 and even genome-scale protein predictions.52

We explored weight quantization techniques to optimize inference by benchmarking 8-bit quantization with LLM.int8()53 and 4-bit quantization using QLoRA54 algorithms using bitsandbytes package.55 Quantization provides marginal benefits for only billion-parameter models (3B and 15B), primarily by reducing memory usage through compressing model weights to lower precision (Figure 1C; Table S2). For instance, 4-bit and 8-bit quantization reduces memory usage to 41% and 80% of the unquantized inference for 3B models and 33% and 63% for 15B models. However, the memory overhead from the quantization constants needed for quantization and dequantization limits the effectiveness of these algorithms for sub-billion-parameter models. Additionally, 8-bit quantization introduces computational overhead, nearly doubling inference time, whereas 4-bit quantization achieves a runtime comparable to bfloat16 precision (Figure S6; Table S1).

Efficient reimplementation replicates the pseudo-perplexity of original models

We use pseudo-perplexity56 as the primary metric to evaluate model uncertainty on given protein sequences. Pseudo-perplexity is computed by systematically masking each position in a sequence, one at a time, and estimating the probability of the masked token given the sequence context (STAR Methods). To validate the correctness of our efficient reimplementation, we compared the pseudo-perplexity of the original and replicated models across 500 randomly sampled human proteins. We use full precision (float32) for the model weights of the original models and bfloat16 for the efficient implementations, except for the ESMC models, where bfloat16 is used for both the original and efficient versions to utilize FlashAttention for both models. As expected, the ESM2-8M model with the smallest parameter size exhibited the highest pseudo-perplexity of 12.744 ± 3.033 (SD) for the original and 12.735 ± 3.027 for the efficient model. The ESM2-15B model with the largest parameter size achieved the lowest pseudo-perplexity of 3.637 ± 3.423 for the original and 3.636 ± 3.423 for the efficient model (Figure 1A; Table S3). The mean squared error (MSE) between original and efficient implementations was extremely small across all models (e.g., ESM1b: MSE = 0.0023, ESM2-150M: MSE = 0.0006, ESMC-300M: MSE = 0.0005), indicating that our reimplementation accurately reproduces the behavior of the original models. The replication of the pseudo-perplexities across proteins confirms the correctness of the efficient implementation.

Benchmarking variant effect prediction on ProteinGym

As another validation of correctness, we benchmarked the ESM family—ESM1v, ESM1b, and ESM2—by evaluating how effectively they capture the impact of missense mutations on protein fitness, a key application of PLMs. We used deep mutational scanning (DMS) experimental data from the ProteinGym database as ground truth for 94 human proteins.47 The ProteinGym database contains 12 proteins longer than 1024 residues, but the original ESM1b and ESM1v models use learned positional embeddings57 with a maximum sequence length of 1024 tokens, requiring sequence truncation for longer proteins. To address this limitation in our implementation, we extended the supported sequence length to 4096 residues in the ESME-1b and ESME-1v models by retraining the positional embedding layer using longer sequences from Uniref. 50 (STAR Methods). Spearman’s rank correlation coefficients between predicted mask margin scores and DMS scores (STAR Methods) demonstrate that our reimplementation produced results comparable to the original implementation on the variant effect prediction task (Figure 2B; Figure S7; Table S4). Weight quantization leads to only a slight performance decrease with 4-bit quantization in smaller models (8M and 35M), while larger models are robust to quantization. Interestingly, model performance improves as the parameter size increases, reaching a peak at 650 million parameters for ESM2, ESM1b, and ESM1v models, with average performance of 46.6 ± 17.5% (SD), 42.7 ± 17.2%, and 43.1 ± 16.7%, respectively. However, performance does not increase further for the larger 3 billion and 15 billion parameter models, staying at 45.2 ± 16.5% and 44.1 ± 16.6%, respectively. The latest ESM-C 300M and 600M models achieve slightly higher correlations of 47.2 ± 16.8% and 46.7 ± 17.3%, respectively. This suggests that the 300 million to 650 million parameter models are optimal for variant effect prediction, and the reduced performance of larger ESM2 models may result from overfitting, potentially leading to an overestimation of the reference amino acids’ probabilities in the masked margin score.

Figure 2.

Figure 2

Efficient reimplementation preserves pseudo-perplexity and variant prediction accuracy

(A) Pseudo-perplexity comparison between the original models and efficient reimplementations on 500 randomly sampled human proteins. The efficient implementations replicate the original models’ pseudo-perplexity values, confirming the correctness of the reimplementation.

(B) Benchmark of protein language models for predicting deep mutational screening (DMS) ground truth. The distribution of Spearman correlation coefficients between the predicted masked margin scores by the protein language models and the DMS measurements from 94 experiments for original implementation with full precision (blue), efficient implementation bfloat16 precision (orange), 8-bit quantization (green), and 4-bit quantization (red). The 300 to 650 million parameter models demonstrate the best performance for variant effect prediction. Quantized 8-bit and 4-bit models perform similarly to unquantized models, except for models with fewer than 150 million parameters, where 4-bit quantization results in reduced performance.

Benchmarking the model training and fine-tuning

We also benchmarked the performance of PLMs during training and fine-tuning. We measured memory savings by progressively applying various optimization techniques (Figure 3A; Table S5). Similar to inference, FlashAttention resulted in substantial memory reductions during training. However, training demands more memory than inference due to gradient computation, and Adam optimization states.58 Therefore, we integrated training-specific techniques for backpropagation and parameter optimization to further reduce memory consumption. First, activation checkpointing reduces memory usage by recalculating intermediate states during the backward pass instead of storing them, trading runtime for memory savings, thus lowering GPU memory usage from ∼10 GB to 8 GB for the 650 million parameter model and from ∼35 GB to ∼28 GB for the 3 billion parameter ESME models. Another technique, ZeRO-Offload/CPU-Adam, offloads optimization states to CPU memory and performs parameter updates on the CPU (STAR Methods).59 This strategy saves ∼39% memory for both the 650 million and 3 billion parameter models. Yet, due to memory limitations, training 15 billion parameters is still not feasible even with all the optimization algorithms with a batch size of 4 proteins.

Figure 3.

Figure 3

The benchmark of training performance of ESME-2

(A) Memory utilization of model training when the range of training and fine-tuning optimization methods are applied to the ESME-2. OOM indicates an out-of-memory error.

(B) One epoch training time of the original ESM2 models and the efficient implementation on the UniProtKB/Swiss-Prot dataset.

(C) The runtime of parameter efficient fine-tuning of ESME-2 models for one epoch on UniProtKB/Swiss-Prot.

We measured memory consumption during parameter-efficient fine-tuning by adding LoRA60 adapters with a rank of 16 to the query, value, and output layers (Figure 3A). Fine-tuning with these adapters updates only a tiny fraction of the weights, enabling fine-tuning of the 15 billion parameter model (STAR Methods). The largest 15 billion parameter model uses 33 GB of memory, while the remaining models use less than 10 GB. While quantizing frozen model weights during fine-tuning is possible, the current implementations of 8-bit and 4-bit quantization result in increased memory usage as the input token count grows (Figure S8). For example, quantized LoRA fine-tuning with 8-bit quantization increases GPU memory usage from ∼32 GB to ∼40 GB. Thus, unlike inference, quantization during fine-tuning is not memory efficient, highlighting the need for more effective quantization methods for PLMs. Moreover, ZeRO-Offload/CPU-Adam does not significantly reduce memory usage during parameter-efficient fine-tuning, as only the adapters are optimized; thus, offloading optimization states and gradients to CPU memory provide negligible GPU memory savings (Figure S9).

Moreover, we benchmarked the training runtime of ESME-2 after applying all the outlined optimization methods and compared it to the original implementation (Figures 3B; Table S6). Significant speedups were achieved; for instance, one epoch on 571,609 proteins from UniProtKB/Swiss-Prot takes ∼0.04, ∼1.1, and ∼3.4 h for the 8 million, 650 million, and 3 billion parameter models, respectively, using 4 A6000 GPUs. We also estimated the training time for ESM2 models on Uniref. 50 (65,672,468 proteins, totaling ∼18.7 billion tokens) if trained from scratch with our implementation and setup (Figure S10). The original training runs for 500,000 steps with a batch size of 2 million tokens, translating to approximately 53 epochs on Uniref. 50. Based on this estimate, training the 150 million and 650 million parameter models would take 33 and 309 days, respectively.

We further investigated various sequence packing strategies for the ESM-C model using two A100 GPUs with a similar training setup. We found that the original implementation of ESM-C, even with its FlashAttention implementation, is suboptimized due to repeated padding and reshaping at each layer (Figure S11). In contrast, our optimized implementation performs packing only once and uses token-based batching at the dataloader level, improving GPU utilization and reducing training time by up to 53%, thereby demonstrating substantial performance gains with the proposed sequence packing strategy.

Lastly, we measured the runtime of fine-tuning and observed that LoRA fine-tuning is slightly faster compared to the training of all weights (Figure 3C). For instance, fine-tuning 3 billion parameter models takes ∼3.4 h, which is 12.5% faster.

Finetuning for protein melting point and fitness landscape prediction on the FLIP dataset

Annotation of protein function and properties is only available for a limited number of proteins. Thus, leveraging semi-supervised PLMs as foundation models to train task-specific models with limited data are critical. Semi-supervised training of PLMs on diverse sequences enables the capture of latent spaces and protein properties, allowing the model to generalize from limited training samples. To demonstrate this, we fine-tuned ESME-2 using head-only and LoRA fine-tuning to predict the melting point61 of proteins and fitness landscape of AAV and GB1 proteins from sequence content using the FLIP benchmarking dataset28 (STAR Methods). Based on the hyperparameter tuning on the validation set (Figure S12), adapters with a rank-size of 16 were added to the query, value, and output layers for each transformer block. We achieved a Spearman’s correlation coefficient of ∼70% using head-only fine-tuning of the ESME-2 3B model for melting point prediction, surpassing the state-of-the-art28 (Figure 4A; Table S7). LoRA fine-tuning showed improvements for smaller models, boosting performance from 58% to 62% for the 8M model and from 60% to 64% for the 35M model (Figure 4B). The test set consisted of proteins with less than 20% sequence identity to the training set, demonstrating that PLMs can generalize effectively to proteins from unrelated families or remote homologs when predicting protein properties, such as melting point. Furthermore, we achieve a Spearman’s correlation coefficient of 64% on the GB1 protein landscape prediction task using the ESME-2 35M model; however, we observe that LoRA fine-tuning of larger models leads to poorer performance (Table S8; Figure 4C). Interestingly, LoRA fine-tuning leads to a substantial improvement in fitness landscape prediction for the AAV protein, particularly in smaller models. The ESME-2 650M and 3B models with LoRA fine-tuning achieve the best performance, reaching a Spearman’s correlation of 42%, outperforming the FLIP baseline28 (Figures 4D; Table S9). Furthermore, we evaluated the efficient implementation of the ESME-1v model across three benchmark tasks. For melting point, GB1, and AAV fitness landscape predictions, we achieved Spearman correlations of 62%, 56%, and 37% using head-only fine-tuning, and 63%, 55%, and 36% with LoRA fine-tuning, respectively. Our findings are comparable to the correlations of 65%, 51%, and 34% reported by the FLIP benchmark for these tasks, respectively, which indicates a successful replication of the original results with efficient implementation. These results show that fine-tuning PLMs enables generalization to the prediction of fitness landscapes for unseen protein sequences.

Figure 4.

Figure 4

Melting point and fitness landscape prediction with parameter-efficient fine-tuning

(A) Correlation between experimentally measured protein melting points from the Meltome Atlas and predictions from the ESME-2 3B model using head-only fine-tuning. The dashed line indicates x = y line.

(B) Spearman’s correlation coefficients between observed and predicted melting points, based on head-only (green) and LoRA fine-tuning (brown) of ESME models with different parameter sizes.

(C and D) Performance of fitness landscape prediction, measured by Spearman’s correlation coefficients, using head-only fine-tuning (green) and LoRA fine-tuning (brown) for the GB1 and AAV protein datasets.

Homology-based transcription factor prediction

Moreover, we fine-tune the ESME-2 model to predict transcription factors (TFs) using ground truths derived from TF-related GO-terms (STAR Methods). The train and test sets are separated by release time in the database, following the same approach as DeepTFactor. Thus, the prediction task primarily uses homology modeling to estimate protein function. The head-only fine-tuning achieves an area under the receiver operating characteristic curve (AU-ROC) of 97% on the test set, outperforming the state-of-the-art DeepTFactor model,62 which achieves 87% AU-ROC (Figures 5A and 5B; Table S10). The LoRA fine-tuning with a rank-size of 16, applied to the query, value, and output layers, achieves slightly higher precision, 87% under the area of the precision-recall curve (AU-PRC) for the 3 billion parameters model, while head-only fine-tuning achieves 84% AU-PRC (Figures 5C and 5D; Table S11). These results demonstrate that PLMs significantly enhance homology-based protein function prediction through a simple fine-tuning procedure.

Figure 5.

Figure 5

Transcription factor prediction with parameter efficient fine-tuning

(A) The receiver operating characteristic curve (ROC) for transcription factor prediction of DeepTFactor, head-only, and LoRA fine-tuned ESME-2 650 million parameter model.

(B) The area under the ROC (AUROC) for DeepTFactor, head-only, and LoRA fine-tuned ESME-2 models.

(C) The precision-recall curve (PRC) for transcription factor prediction of DeepTFactor, head-only, and LoRA fine-tuned ESME-2 3 billion parameters model.

(D) The area under the ROC (AU-PRC) for DeepTFactor, head-only, and LoRA fine-tuned ESME-2 models.

Discussion

In this study, significant efficiency improvements are demonstrated in the training, inference, and fine-tuning of PLMs using a combination of advanced techniques such as FlashAttention, activation checkpointing, zero-offload, and low-rank adaptation. Additionally, we introduced dataloaders that effectively utilize sequence packing, enabling transformer models to effectively handle proteins with highly diverse lengths while also significantly extending the batch size. Our efficient reimplementation of the evolutionary sequence model (ESME) achieved up to a 3 to 9-fold reduction in inference time and an 8-fold reduction in memory usage. Moreover, the correctness of our reimplementation is validated by comparing it with the original model through pseudo-perplexity evaluations and missense variant effect prediction, using deep mutational scanning data from ProteinGym as the ground truth for benchmarking. These enhancements enable the use of large-scale PLMs in more resource-constrained environments, such as academic labs.

Our findings underscore the practical utility of these models in various biological contexts. Specifically, the application of PLMs to predict protein properties on the FLIP benchmark dataset and functions—such as melting points and TFs—demonstrates their effectiveness. For instance, fine-tuning ESME-2 for the TF prediction task achieved state-of-the-art performance while training only a small fraction of the model parameters. The LoRA fine-tuning method achieved slightly higher performance, with an AU-PRC of 87%, compared to head-only fine-tuning on TF prediction. In melting point prediction, head-only fine-tuning attained the best performance, with a Spearman’s correlation coefficient of 70%, while LoRA fine-tuning was beneficial only for smaller model sizes. For the GB1 protein fitness landscape prediction, LoRA fine-tuning yields suboptimal results, in contrast to the AAV prediction task, where it achieves the best performance. These results suggest that LoRA fine-tuning can outperform head-only fine-tuning on certain tasks, particularly when the representations of pretrained models are poor, as is often the case with models with smaller parameter sizes. The results indicate that both head-only and LoRA fine-tuning offer distinct advantages, with each achieving the best performance on certain datasets while underperforming on others. LoRA fine-tuning is particularly beneficial when embeddings from the pretrained baseline model are not sufficiently informative; for example, in the case of smaller models on the AAV benchmark. However, LoRA may degrade performance or offer little to no improvement when the pretrained embeddings are already well-aligned with the downstream task, as observed in the GB1 benchmark. Overall, the LoRA adapter weights, trained from a small amount of labeled data, can generate annotations of unannotated protein sequences via homology modeling or de novo predictions. Moreover, the adapter weights are highly modular, allowing different adapters to be easily integrated into the base models.

Our observations indicate that quantization techniques effectively save memory by compressing model weights during inference while maintaining comparable results in variant effect prediction. However, their efficacy is limited to models with billions of parameters, and the llm.int8() algorithm doubles the inference runtime, rendering it impractical. However, quantization methods are not as effective during fine-tuning as inference, primarily due to significantly higher memory overhead. We observed that the open-source implementation of quantization algorithms during fine-tuning results in increased memory usage, particularly due to the memory overhead of storing quantization constants, which grow significantly with large input sizes, highlighting the importance of benchmarking before adopting any optimization technique. There are quantization techniques that combine knowledge distillation with quantization.63,64 Although this technique might improve the model performance, further systematic benchmarking of quantization methods is another research avenue beyond the scope of this work.

Overall, the methodologies employed in this study represent a significant advancement toward making PLMs more accessible and practical for a wider range of research applications. The techniques explored are generalizable and not specific to ESM models, and we anticipate that they will be utilized in training the next generation of PLMs. Furthermore, given that the development of optimization techniques for LLMs is still an active area of research, continuous benchmarking and integration of these techniques into PLMs will be essential in the future.

Limitations of the study

A limitation of the current study is that FlashAttention cannot be used for structure prediction tasks, such as contact map or 3D structure inference, because it does not retain the full attention matrix required for these applications. This restricts the use of the proposed method to sequence-based tasks only. Another limitation is that quantization, while effective at reducing memory usage during inference for large models, significantly increases memory usage during fine-tuning due to the overhead of storing quantization constants and dequantization buffers.

Resource availability

Lead contact

Requests for additional information or resources should be addressed to the lead contact, Xiaohui Xie (xhx@uci.edu).

Materials availability

This study was conducted entirely through computational analyses and did not generate any new materials or reagents.

Data and code availability

  • All data reported in this study are available from the lead contact upon request.

  • The original code has been deposited on reproduce GitHub (github.com/uci-cbcl/esm-efficient) and is publicly accessible as of the date of publication. Model weights have been deposited on Hugging Face (huggingface.co/mhcelik/esm-efficient) and are publicly available as of the date of publication.

  • Any additional information required to reanalyze the data are available from the lead contact upon request.

Acknowledgments

This study was funded by the Institute for Precision Health Pilot (IPH) study awards.

Author contributions

M.H.C. designed the methodology, implemented the software, and performed analyses. X.X. supervised the project. M.H.C. and X.X. wrote the manuscript.

Declaration of interests

The authors declare no competing interests.

STAR★Methods

Key resources table

REAGENT or RESOURCE SOURCE IDENTIFIER
Software and algorithms

FlashAttention Dao et al.46,65 https://github.com/Dao-AILab/flash-attention
Bitsandbytes Dettmers et al.53,54 https://github.com/bitsandbytes-foundation/bitsandbytes
ESM1v, ESM1b, ESM2 Lin,6 Meier,16 Rives17 https://github.com/facebookresearch/esm
ESMC ESM Team7 https://github.com/evolutionaryscale/esm
PyTorch Paszke et al.66 https://github.com/pytorch/pytorch
DeepSpeed Ren et al.59 https://github.com/deepspeedai/DeepSpeed
SciPy Virtanen et al.67 https://github.com/scipy/scipy
Scikit-learn Pedregosa et al.68 https://github.com/scikit-learn/scikit-learn

Method details

In this section, we first outline the transformer architecture of the PLMs. We then described the combination of optimization techniques applied–such as FlashAttention, sequence packing, model quantization, and checkpointing–to enhance the performance of ESM2 during training, fine-tuning, and inference.

Protein language models

The attention layers in the model are composed of three key components: embedding layers, transformer blocks, and the language model head. The embedding layers generate embeddings for each amino acid in the input sequence. Positional information of the amino acids is incorporated through learned positional embeddings69 in ESM-1b and ESM-1v, while ESM2 and ESM-C employ rotary position embeddings.70 The transformer layers, which contain the majority of the parameters of the models, contextualize the input embeddings by capturing interactions between amino acids. These interactions are computed using self-attention, which is formalized as follows:

SelfAttention(x)=softmax(Q(x)K(x)d)V(x) (Equation 1)

where query (Q), key (K), and value (V) vectors are used to calculate attention scores between amino ancids, and d is the normalization constant. Each transformer block consists of an attention layer, followed by two feedforward dense layers with GeLU activation,71 except for the ESM-C7 model, which utilizes SwiGLU72 activation and Pre-Layer Normalization73 in transformer blocks. Finally, the language model head computes the logits for each amino acid based on the sequence context. The model is trained using a masked language modeling approach, where some amino acids are masked, and the task is to predict the masked amino acids using the surrounding sequence context, optimized with cross-entropy loss.

FlashAttention

The memory footprint of standard dot-product attention grows quadratically with sequence length, creating a bottleneck when running models on long protein sequences. FlashAttention, an I/O-aware attention algorithm, addresses this issue by significantly reducing the memory footprint and improving the runtime of attention computations.46,65 Memory access dominates the runtime in the attention calculation. FlashAttention optimizes attention by minimizing the number of read/write operations between the slower GPU high-bandwidth memory (HBM) and the faster on-chip SRAM. Specifically, FlashAttention divides the input key, query, and value matrices into smaller blocks, loading only the necessary blocks into SRAM. All computations are then performed using fused kernels, and intermediate matrices, such as those required for the backward pass, are recalculated as needed to minimize HBM access. By fusing operations together, FlashAttention further accelerates the attention calculation. One limitation of FlashAttention is that it cannot be used for protein structure prediction because structure prediction requires calculating the full attention matrix, which is not stored during the tiled calculation.

Sequence packing

We utilized sequence packing to efficiently handle batches of protein sequences with varying lengths. Traditionally, tokens are padded to accommodate flexible input sizes during batch preparation. However, proteins exhibit widely differing sequence lengths, which leads to batches containing a large number of padding tokens and results in wasted computational resources. To address this issue, sequence packing constructs a single long amino acid chain by concatenating all protein sequences in the input batch without any padding tokens and prepares an attention mask that corresponds to the original batch structure. This approach enables batching with a balanced number of tokens, ensuring consistent computational cost in each step and near-full utilization of GPUs. Furthermore, preparing batches with a consistent computational load is essential for distributed data parallelization; thus, sequence packing is critical for scaling computations across multiple GPUs.

Retraining the positional embedding layer

We retrained the positional embedding layers of the ESM-1v and ESM-1b models to extend their context size from 1,024 to 4,000 amino acids. To accomplish this, we constructed a training dataset by selecting proteins with lengths between 1,000 and 4,000 amino acids from the Uniref. 50 database,48 resulting in 1,755,116 proteins. We reserved 1% of this data as a validation set. During training, we froze all weights except for the positional embedding layer. As a result, only 5,245,440 parameters of positional embeddings were trained. While this approach is suboptimal, since model parameters that may interact with positional embeddings remain frozen, it was chosen to reduce computational cost. We masked 15% of the input tokens and used cross-entropy as the loss function, training the model until convergence.

Quantization

As PLMs increase in size, they can consume a significant amount of memory. Rounding model weights to lower-precision numbers can significantly reduce memory usage; for example, half-precision Brain Floating Point (bfloat16) is widely preferred over full-precision float32 due to its lower memory footprint and faster training times.49 Model weights can even be represented with lower precision, such as 8-bit and 4-bit formats. For instance, absolute max quantization reduces a matrix to the desired precision by dividing each value by the absolute maximum value, multiplying by the quantization level, and rounding to the nearest integer. However, naive quantization methods introduce errors, thereby significantly degrading accuracy. Therefore, quantization methods specific to language models have been proposed to ensure model performance while reducing memory footprint and runtime. These quantization techniques are helpful during model inference by reducing memory usage and runtime. However, training with quantized weights may not be stable. Nevertheless, quantization can be used during fine-tuning because the quantized model weights are frozen, and only the fine-tuned weights are trained without quantization.

8-bit quantization with LLM.int8

It has been empirically observed that the weights of language models are normally distributed and centered around zero. However, rare outlier features with very large magnitudes can occur. These outlier features are sufficient to shift the quantization scale, thereby introducing large errors in matrix multiplication. To address this issue, LLM.int853 proposes a mixed-precision decomposition methodology that retains outlier features in the original float16 precision and performs calculations in half-precision, while computations for the remaining non-outlier weights are carried out in 8-bit using absolute max quantization. Since the outliers are extremely sparse, storing them in half-precision does not significantly affect the memory footprint while maintaining model performance.

4-bit quantization with QLoRA

QLoRA is an algorithm that efficiently fine-tunes large language models using 4-bit quantization. It employs blockwise quantization, where model weights are divided into blocks that are quantized independently,54 effectively containing outliers within each block. This technique stores the quantized weights using the information-theoretically optimal NormalFloat (NF) data type and further reduces memory usage by quantizing the quantization constants through a proposed double quantization method.

Activation checkpointing

Model training is significantly more computationally expensive than model inference because the outputs of each layer and the intermediate states needed for backpropagation must be stored during the forward pass to calculate gradients during the backward pass. The accumulation of these intermediate states leads to substantial memory usage in large deep-learning models. Activation checkpointing addresses this issue by significantly reducing GPU memory usage during model training. In this approach, intermediate results are not stored in GPU memory during the forward pass but are recomputed lazily during the backward pass. As a result, activation checkpointing saves memory at the cost of additional computational time.

Zero-offload and CPU-Adam

Zero-Offload is a model training strategy that employs CPU offloading to reduce GPU memory usage without significantly degrading model performance.59 In the Stage-2 Zero-Offload strategy utilized in this work, the model weights are kept on the GPU, but gradients and optimizer states are offloaded to the CPU after the execution of each layer. Model training requires storing gradients for each parameter and optimization state, such as momentum parameters for the Adam algorithm, thereby multiplying the memory usage per weight. Storing the gradients and optimizer states on the CPU saves GPU memory. However, the offloading process can lead to a slowdown of training because updating the model weights requires transferring gradients and optimizer states between the CPU and GPU. To mitigate the inefficiencies introduced by CPU-GPU communication, Zero-Offload utilizes CPU-Adam,59 an algorithm optimized for computation on the CPU. CPU-Adam performs the weight updates on the CPU based on the gradients and optimizer states stored in CPU memory and then transfers the updated model parameters back to the GPU. When this approach is combined with gradient accumulation, where gradients are accumulated over a certain number of steps before updating the model parameters, it minimizes CPU-GPU memory transfer overhead, resulting in minimal efficiency loss during model training.

LoRA

Fine-tuning large language models (LLMs) is computationally expensive due to their large parameter sizes. Additionally, information learned during foundational model training might be lost during updates during fine-tuning, a phenomenon known as catastrophic forgetting. Low-Rank Adaptation (LoRA)60 addresses these issues by training only a small fraction of the model’s weights, called adapters, during fine-tuning. These low-rank adapters are added to the key, query, and value matrices and are defined as:

h=Wx+BAx (Equation 2)

where WRn×m and BinRn×r,AinRr×m the matrix rank r of the matrixes A and B are much smaller (nr,mr) than the size of the key, query, and value matrixes. As a result, model weights are frozen, and only the extra adapter weight is trained with LoRA, leading to efficient model training and avoiding catastrophic forgetting. The adapters can be attached and detached from the model, enabling modularity.

Pseudo-perplexity

We use pseudo-perplexity as the primary metric to evaluate the goodness of fit of models on protein sequences. Pseudo-perplexity by masking each position in the sequence separately and estimating the probability of the masked token given the unmasked context:

PseudoPPL(x)=exp(1Tt=1Tlogp(xtxt)) (Equation 3)

where the input sequence of length T and xt denotes the sequence with the t token masked. The probability p(xtxt) is the predicted probability of the model for the masked token xt. Lower pseudo-perplexity indicates lower uncertainty of the model.

Variant effect prediction

The PLMs can prioritize potentially pathogenic missense variants by comparing the posterior likelihood of the alternative and the reference amino acids:

v=log(palt)log(pref) (Equation 4)

where probabilities for the reference (pref) and alternative (palt) alleles are predicted by the model. The deep mutational scanning (DMS) experiments provide unbiased experimental ground truth for the benchmark of variant effect prediction on protein fitness. DMS experiments for 92 human proteins were downloaded from the ProteinGym database47 and used to validate the correctness of our reimplementation. ESM-1v and ESM-1b models only support sequences up to 1024 amino acids; thus, sequences are truncated to match this length by centering the variants. Similarly, we used this truncation strategy for the original 15 billion parameter ESM2 model to avoid memory error. For ESME models, variant effect predictions were performed with entire protein sequences.

Melting point and protein fitness landscapes of GB1 and AAV prediction using the FLIP dataset

Protein language models can be fine-tuned to predict various properties of proteins. To demonstrate this capability, we fine-tuned models to predict the melting points of proteins. We used the Meltome Atlas61 as the ground truth for melting points, which contains approximately 48,000 proteins from 13 species. The training and test sets were obtained from the Fitness Landscape Inference for Proteins (FLIP) project,28 which splits the data so that sequences in the training and test sets share no more than 20% sequence identity. Additionally, we used the fitness landscapes of GB1 and AAV proteins from the FLIP project as ground truth, where low-fitness sequences were used for training and high-fitness sequences for testing. We employed two fine-tuning approaches: head-only fine-tuning and LoRA fine-tuning for all three datasets.

In head-only fine-tuning, we trained only the regression head while keeping all other layers of the model frozen. For melting point prediction, the model regression consists of two feedforward layers with ReLU activations, taking the average-pooled embeddings as input from the protein language model:

h=1Ni=1Nei (Equation 5)
ypred=W2ReLU(W1h+b1)+b2 (Equation 6)

where N is the sequence length of the protein, ei is the embedding vector for the i-th token in the sequence, W1, W2, b1, and b2 are the weights and biases, and ReLU is the Rectified Linear Unit activation function. In the GB1 and AAV fitness landscape prediction tasks, attention pooling is utilized to aggregate the embeddings E into a vector h before passing it to the regression head:

h=softmax(C(EWk)Tdk)E (Equation 7)

where h is the final output of the attention pooling layer, C is the learnable matrix of class tokens used to query the attention mechanism, E is the matrix representing the sequence of input token embeddings of a protein, Wk is the trainable “key” weight matrix, dk is the dimension of the key vectors which acts as a normalization constant, and softmax is the activation function that transforms attention scores into a weighted average. We implemented an attention pooling layer compatible with sequence packing.

In LoRA fine-tuning, additional adapters were added to the query, key, and value matrices of each transformer layer. For optimization, we used the Adam algorithm with a learning rate of 104 and momentum parameters of 0.9 and 0.999. The learning rate was reduced by 10% every 10 epochs during 100 epochs of training. Mean squared error is used as a loss function. We used a minibatch size of 50,000 tokens with 16 steps of gradient accumulation.

Transcription factor prediction

Another downstream application of PLMs is the prediction of protein functions. Specifically, in this work, we fine-tuned PLMs to predict TFs. We annotated proteins in UniProtKB/SwissProt as TFs if they are associated with relevant Gene Ontology (GO) terms (Table S12), using an approach adapted from DeepTFactor,62 a state-of-the-art model for TF prediction. We partitioned the data into training and test sets based on the publication date of the proteins in the UniProtKB/SwissProt database: proteins published up to 2021 were used for training, while those published after this date were used for testing. We employed a fine-tuning approach similar to that used for melting point prediction, except that we used the sigmoid function as the final layer of the model head, cross-entropy as the loss function, and upsampled the positive class of TF proteins to balance it with non-transcription factor proteins in each epoch.

Quantification and statistical analysis

All statistical analyses and model evaluations were conducted in Python (v3.11)74 using PyTorch66 (v2.3) for model implementation, DeepSpeed59 (v0.15) for the ZeRO-Offload strategy, bitsandbytes55 (v0.44) for weight quantization, and scikit-learn68 (v1.5) and SciPy67 (v1.14) for statistical analysis.

Pseudo-perplexity is reported as the primary evaluation metric of model quality for predicting masked amino acids from sequence context. In downstream prediction tasks, we report Spearman’s rank correlation coefficient (ρ) for melting point prediction (Meltome Atlas dataset) and fitness landscape prediction (GB1 and AAV tasks from the FLIP benchmark). For classification tasks (e.g., TF prediction), we report area under the receiver operating characteristic (AU-ROC) and area under the precision–recall curve (AU-PRC). Exact values of test performance, including means, standard deviations (SD), and sample sizes (n), are provided in the main text, figures, and figure legends.

Published: September 3, 2025

Footnotes

Supplemental information can be found online at https://doi.org/10.1016/j.isci.2025.113495.

Supplemental information

Document S1. Figures S1–S12
mmc1.pdf (1.9MB, pdf)
Table S1. Memory usage for inference with original and efficient ESM2 implementations
mmc2.xlsx (35.2KB, xlsx)
Table S2. Inference runtimes of original and efficient ESM2 implementations
mmc3.xlsx (37.5KB, xlsx)
Table S3. Perplexity of the original and efficient ESM2 model implementations
mmc4.xlsx (9.7KB, xlsx)
Table S4. Correlation between model predictions and experimental deep mutational scanning data for missense variant effects on the ProteinGYM dataset
mmc5.xlsx (10.7KB, xlsx)
Table S5. Effect of various optimization strategies on memory usage during model training
mmc6.xlsx (28.1KB, xlsx)
Table S6. One epoch training runtime for original and efficient model implementations
mmc7.xlsx (9.4KB, xlsx)
Table S7. Melting point prediction performance across different models using head-only fine-tuning
mmc8.xlsx (9.2KB, xlsx)
Table S8. Performance of fine-tuned models on GB1 fitness landscape prediction using head-only and Head + LoRA fine-tuning
mmc9.xlsx (9.2KB, xlsx)
Table S9. Performance of fine-tuned models on AAV fitness landscape prediction using head-only and Head + LoRA fine-tuning
mmc10.xlsx (9.2KB, xlsx)
Table S10. Performance of ESM2 models on transcription factor binding prediction, benchmarked against the DeepTFactor baseline using AUROC
mmc11.xlsx (9.2KB, xlsx)
Table S11. Performance of ESM2 models on transcription factor binding prediction, benchmarked against the DeepTFactor baseline using AUPRC
mmc12.xlsx (9.2KB, xlsx)
Table S12. Gene Ontology terms used in constructing the ground truth for the transcription factor prediction task
mmc13.xlsx (9.2KB, xlsx)

References

  • 1.Listov D., Goverde C.A., Correia B.E., Fleishman S.J. Opportunities and challenges in design and optimization of protein function. Nat. Rev. Mol. Cell Biol. 2024;25:639–653. doi: 10.1038/s41580-024-00718-y. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 2.Sapoval N., Aghazadeh A., Nute M.G., Antunes D.A., Balaji A., Baraniuk R., Barberan C.J., Dannenfelser R., Dun C., Edrisi M., et al. Current progress and open challenges for applying deep learning across the biosciences. Nat. Commun. 2022;13:1728. doi: 10.1038/s41467-022-29268-7. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 3.Jumper J., Evans R., Pritzel A., Green T., Figurnov M., Ronneberger O., Tunyasuvunakool K., Bates R., Žídek A., Potapenko A., et al. Highly accurate protein structure prediction with AlphaFold. Nature. 2021;596:583–589. doi: 10.1038/s41586-021-03819-2. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 4.Senior A.W., Evans R., Jumper J., Kirkpatrick J., Sifre L., Green T., Qin C., Žídek A., Nelson A.W.R., Bridgland A., et al. Improved protein structure prediction using potentials from deep learning. Nature. 2020;577:706–710. doi: 10.1038/s41586-019-1923-7. [DOI] [PubMed] [Google Scholar]
  • 5.Abramson J., Adler J., Dunger J., Evans R., Green T., Pritzel A., Ronneberger O., Willmore L., Ballard A.J., Bambrick J., et al. Accurate structure prediction of biomolecular interactions with AlphaFold 3. Nature. 2024;630:493–500. doi: 10.1038/s41586-024-07487-w. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 6.Lin Z., Akin H., Rao R., Hie B., Zhu Z., Lu W., Smetanin N., Verkuil R., Kabeli O., Shmueli Y., et al. Evolutionary-scale prediction of atomic-level protein structure with a language model. Science. 2023;379:1123–1130. doi: 10.1126/science.ade2574. [DOI] [PubMed] [Google Scholar]
  • 7.Evolutionary Scale ESM Cambrian: Revealing the mysteries of proteins with unsupervised learning. https://www.evolutionaryscale.ai/blog/esm-cambrian
  • 8.Elnaggar A., Heinzinger M., Dallago C., Rihawi G., Wang Y., Jones L., Gibbs T., Feher T., Angerer C., Steinegger M., et al. ProtTrans: Towards Cracking the Language of Life’s Code Through Self-Supervised Deep Learning and High Performance Computing. arXiv. 2021 doi: 10.48550/arXiv.2007.06225. Preprint at. [DOI] [Google Scholar]
  • 9.Heinzinger M., Weissenow K., Sanchez J.G., Henkel A., Mirdita M., Steinegger M., Rost B. Bilingual Language Model for Protein Sequence and Structure. bioRxiv. 2024 doi: 10.1101/2023.07.23.550085. Preprint at. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 10.Kulmanov M., Guzmán-Vega F.J., Duek Roggli P., Lane L., Arold S.T., Hoehndorf R. Protein function prediction as approximate semantic entailment. Nat. Mach. Intell. 2024;6:220–228. doi: 10.1038/s42256-024-00795-w. [DOI] [Google Scholar]
  • 11.Cheng J., Novati G., Pan J., Bycroft C., Žemgulytė A., Applebaum T., Pritzel A., Wong L.H., Zielinski M., Sargeant T., et al. Accurate proteome-wide missense variant effect prediction with AlphaMissense. Science. 2023;381 doi: 10.1126/science.adg7492. [DOI] [PubMed] [Google Scholar]
  • 12.Brandes N., Goldman G., Wang C.H., Ye C.J., Ntranos V. Genome-wide prediction of disease variant effects with a deep protein language model. Nat. Genet. 2023;55:1512–1522. doi: 10.1038/s41588-023-01465-0. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 13.Sundaram L., Gao H., Padigepati S.R., McRae J.F., Li Y., Kosmicki J.A., Fritzilas N., Hakenberg J., Dutta A., Shon J., et al. Predicting the clinical impact of human mutation with deep neural networks. Nat. Genet. 2018;50:1161–1170. doi: 10.1038/s41588-018-0167-z. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 14.Vaswani A., Shazeer N., Parmar N., Uszkoreit J., Jones L., Gomez A.N., Kaiser L., Polosukhin I. Attention Is All You Need. arXiv. 2023 doi: 10.48550/arXiv.1706.03762. Preprint at. [DOI] [Google Scholar]
  • 15.Chandra A., Tünnermann L., Löfstedt T., Gratz R. Transformer-based deep learning for predicting protein properties in the life sciences. eLife. 2023;12 doi: 10.7554/eLife.82819. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 16.Meier J., Rao R., Verkuil R., Liu J., Sercu T., Rives A. Language models enable zero-shot prediction of the effects of mutations on protein function. bioRxiv. 2021 doi: 10.1101/2021.07.09.450648. Preprint at. [DOI] [Google Scholar]
  • 17.Rives A., Meier J., Sercu T., Goyal S., Lin Z., Liu J., Guo D., Ott M., Zitnick C.L., Ma J., Fergus R. Biological structure and function emerge from scaling unsupervised learning to 250 million protein sequences. Proc. Natl. Acad. Sci.USA. 2021;118 doi: 10.1073/pnas.2016239118. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 18.Nijkamp E., Ruffolo J.A., Weinstein E.N., Naik N., Madani A. ProGen2: Exploring the boundaries of protein language models. Cell Syst. 2023;14:968–978.e3. doi: 10.1016/j.cels.2023.10.002. [DOI] [PubMed] [Google Scholar]
  • 19.Rao R., Liu J., Verkuil R., Meier J., Canny J.F., Abbeel P., Sercu T., Rives A. MSA Transformer. bioRxiv. 2021 doi: 10.1101/2021.02.12.430858. Preprint at. [DOI] [Google Scholar]
  • 20.Brandes N., Ofer D., Peleg Y., Rappoport N., Linial M. ProteinBERT: a universal deep-learning model of protein sequence and function. Bioinformatics. 2022;38:2102–2110. doi: 10.1093/bioinformatics/btac020. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 21.Liu Y., Ott M., Goyal N., Du J., Joshi M., Chen D., Levy O., Lewis M., Zettlemoyer L., Stoyanov V. RoBERTa: A Robustly Optimized BERT Pretraining Approach. arXiv. 2019 doi: 10.48550/arXiv.1907.11692. Preprint at. [DOI] [Google Scholar]
  • 22.Pak M.A., Dovidchenko N.V., Sharma S.M., Ivankov D.N. New mega dataset combined with deep neural network makes a progress in predicting impact of mutation on protein stability. bioRxiv. 2023 doi: 10.1101/2022.12.31.522396. Preprint at. [DOI] [Google Scholar]
  • 23.Laine E., Karami Y., Carbone A. GEMME: A Simple and Fast Global Epistatic Model Predicting Mutational Effects. Mol. Biol. Evol. 2019;36:2604–2619. doi: 10.1093/molbev/msz179. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 24.Riesselman A.J., Ingraham J.B., Marks D.S. Deep generative models of genetic variation capture the effects of mutations. Nat. Methods. 2018;15:816–822. doi: 10.1038/s41592-018-0138-4. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 25.Hopf T.A., Ingraham J.B., Poelwijk F.J., Schärfe C.P.I., Springer M., Sander C., Marks D.S. Mutation effects predicted from sequence co-variation. Nat. Biotechnol. 2017;35:128–135. doi: 10.1038/nbt.3769. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 26.Tsuboyama K., Dauparas J., Chen J., Laine E., Mohseni Behbahani Y., Weinstein J.J., Mangan N.M., Ovchinnikov S., Rocklin G.J. Mega-scale experimental analysis of protein folding stability in biology and design. Nature. 2023;620:434–444. doi: 10.1038/s41586-023-06328-6. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 27.Umerenkov D., Shashkova T.I., Strashnov P.V., Nikolaev F., Sindeeva M., Ivanisenko N.V., Kardymon O.L. PROSTATA: Protein Stability Assessment using Transformers. bioRxiv. 2022 doi: 10.1101/2022.12.25.521875. Preprint at. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 28.Dallago C., Mou J., Johnston K.E., Wittmann B.J., Bhattacharya N., Goldman S., Madani A., Yang K.K. FLIP: Benchmark tasks in fitness landscape inference for proteins. bioRxiv. 2022 doi: 10.1101/2021.11.09.467890. Preprint at. [DOI] [Google Scholar]
  • 29.Hou C., Shen Y. SeqDance: A Protein Language Model for Representing Protein Dynamic Properties. bioRxiv. 2024 doi: 10.1101/2024.10.11.617911. Preprint at. [DOI] [Google Scholar]
  • 30.Frank M., Ni P., Jensen M., Gerstein M.B. Leveraging a large language model to predict protein phase transition: A physical, multiscale, and interpretable approach. Proc. Natl. Acad. Sci. USA. 2024;121 doi: 10.1073/pnas.2320510121. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 31.Yu T., Cui H., Li J.C., Luo Y., Jiang G., Zhao H. Enzyme function prediction using contrastive learning. Science. 2023;379:1358–1363. doi: 10.1126/science.adf2465. [DOI] [PubMed] [Google Scholar]
  • 32.Song Y., Yuan Q., Chen S., Zeng Y., Zhao H., Yang Y. Accurately predicting enzyme functions through geometric graph learning on ESMFold-predicted structures. Nat. Commun. 2024;15:8180. doi: 10.1038/s41467-024-52533-w. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 33.Nguyen V.T.D., Nguyen N.D., Hy T.S. Complex-based Ligand-Binding Proteins Redesign by Equivariant Diffusion-based Generative Models. bioRxiv. 2024 doi: 10.1101/2024.04.17.589997. Preprint at. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 34.Meynard-Piganeau B., Feinauer C., Weigt M., Walczak A.M., Mora T. TULIP: A transformer-based unsupervised language model for interacting peptides and T cell receptors that generalizes to unseen epitopes. Proc. Natl. Acad. Sci. USA. 2024;121 doi: 10.1073/pnas.2316401121. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 35.Wang Y., Xia Y., Yan J., Yuan Y., Shen H.-B., Pan X. ZeroBind: a protein-specific zero-shot predictor with subgraph matching for drug-target interactions. Nat. Commun. 2023;14:7861. doi: 10.1038/s41467-023-43597-1. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 36.Singh R., Sledzieski S., Bryson B., Cowen L., Berger B. Contrastive learning in protein language space predicts interactions between drugs and protein targets. Proc. Natl. Acad. Sci. USA. 2023;120 doi: 10.1073/pnas.2220778120. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 37.Li H., Wang J., Zhao H., Zheng K., Zhao Q. A unified framework for drug–target interaction prediction by semantic-guided meta-path method. bioRxiv. 2024 doi: 10.1101/2024.10.14.618129. Preprint at. [DOI] [Google Scholar]
  • 38.Hie B.L., Shanker V.R., Xu D., Bruun T.U.J., Weidenbacher P.A., Tang S., Wu W., Pak J.E., Kim P.S. Efficient evolution of human antibodies from general protein language models. Nat. Biotechnol. 2024;42:275–283. doi: 10.1038/s41587-023-01763-2. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 39.Hayes T., Rao R., Akin H., Sofroniew N.J., Oktay D., Lin Z., Verkuil R., Tran V.Q., Deaton J., Wiggert M., et al. Simulating 500 million years of evolution with a language model. bioRxiv. 2024 doi: 10.1101/2024.07.01.600583. Preprint at. [DOI] [PubMed] [Google Scholar]
  • 40.Frazer J., Notin P., Dias M., Gomez A., Min J.K., Brock K., Gal Y., Marks D.S. Disease variant prediction with deep generative models of evolutionary data. Nature. 2021;599:91–95. doi: 10.1038/s41586-021-04043-8. [DOI] [PubMed] [Google Scholar]
  • 41.Zhu F., Nowaczynski A., Li R., Xin J., Song Y., Marcinkiewicz M., Eryilmaz S.B., Yang J., Andersch M. ScaleFold: Reducing AlphaFold Initial Training Time to 10 Hours. arXiv. 2024 https://arxiv.org/abs/2404.11068v1 Preprint at. [Google Scholar]
  • 42.Wang W., Chen W., Luo Y., Long Y., Lin Z., Zhang L., Lin B., Cai D., He X. Model Compression and Efficient Inference for Large Language Models: A Survey. arXiv. 2024 doi: 10.48550/arXiv.2402.09748. Preprint at. [DOI] [Google Scholar]
  • 43.Han Z., Gao C., Liu J., Zhang J., Zhang S.Q. Parameter-Efficient Fine-Tuning for Large Models: A Comprehensive Survey. arXiv. 2024 doi: 10.48550/arXiv.2403.14608. Preprint at. [DOI] [Google Scholar]
  • 44.Wan Z., Wang X., Liu C., Alam S., Zheng Y., Liu J., Qu Z., Yan S., Zhu Y., Zhang Q., et al. Efficient Large Language Models: A Survey. arXiv. 2024 doi: 10.48550/arXiv.2312.03863. Preprint at. [DOI] [Google Scholar]
  • 45.Bai G., Chai Z., Ling C., Wang S., Lu J., Zhang N., Shi T., Yu Z., Zhu M., Zhang Y., et al. Beyond Efficiency: A Systematic Survey of Resource-Efficient Large Language Models. arXiv. 2024 doi: 10.48550/arXiv.2401.00625. Preprint at. [DOI] [Google Scholar]
  • 46.Dao T. FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning. arXiv. 2023 doi: 10.48550/arXiv.2307.08691. Preprint at. [DOI] [Google Scholar]
  • 47.Notin P., Kollasch A.W., Ritter D., Niekerk L. van, Paul S., Spinner H., Rollins N., Shaw A., Weitzman R., Frazer J., et al. ProteinGym: Large-Scale Benchmarks for Protein Design and Fitness Prediction. bioRxiv. 2023 doi: 10.1101/2023.12.07.570727. Preprint at. [DOI] [Google Scholar]
  • 48.UniProt Consortium UniProt: the Universal Protein Knowledgebase in 2023. Nucleic Acids Res. 2023;51:D523–D531. doi: 10.1093/nar/gkac1052. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 49.Kalamkar D., Mudigere D., Mellempudi N., Das D., Banerjee K., Avancha S., Vooturi D.T., Jammalamadaka N., Huang J., Yuen H., et al. A Study of BFLOAT16 for Deep Learning Training. arXiv. 2019 doi: 10.48550/arXiv.1905.12322. Preprint at. [DOI] [Google Scholar]
  • 50.Dong J., Feng B., Guessous D., Liang Y., He H. Flex Attention: A Programming Model for Generating Optimized Attention Kernels. arXiv. 2024 https://arxiv.org/abs/2412.05496 Preprint at. [Google Scholar]
  • 51.Sledzieski S., Kshirsagar M., Baek M., Dodhia R., Lavista Ferres J., Berger B. Democratizing protein language models with parameter-efficient fine-tuning. Proc. Natl. Acad. Sci. USA. 2024;121 doi: 10.1073/pnas.2405840121. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 52.Hwang Y., Cornman A.L., Kellogg E.H., Ovchinnikov S., Girguis P.R. Genomic language model predicts protein co-regulation and function. Nat. Commun. 2024;15:2880. doi: 10.1038/s41467-024-46947-9. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 53.Dettmers T., Lewis M., Belkada Y., Zettlemoyer L. LLM.int8: 8-bit Matrix Multiplication for Transformers at Scale. arXiv. 2022 doi: 10.48550/arXiv.2208.07339. Preprint at. [DOI] [Google Scholar]
  • 54.Dettmers T., Pagnoni A., Holtzman A., Zettlemoyer L. QLoRA: Efficient Finetuning of Quantized LLMs. arXiv. 2023 doi: 10.48550/arXiv.2305.14314. Preprint at. [DOI] [Google Scholar]
  • 55.2024. bitsandbytes-foundation/bitsandbytes: bitsandbytes.https://github.com/bitsandbytes-foundation/bitsandbytes [Google Scholar]
  • 56.Kantroo P., Wagner G.P., Machta B.B. Pseudo-perplexity in One Fell Swoop for Protein Fitness Estimation. bioRxiv. 2024 doi: 10.1101/2024.07.09.602754. Preprint at. [DOI] [Google Scholar]
  • 57.Gehring J., Auli M., Grangier D., Yarats D., Dauphin Y.N. Convolutional Sequence to Sequence Learning. arXiv. 2017 doi: 10.48550/arXiv.1705.03122. Preprint at. [DOI] [Google Scholar]
  • 58.Kingma D.P., Ba J. Adam: A Method for Stochastic Optimization. arXiv. 2014 https://arxiv.org/abs/1412.6980v9 Preprint at. [Google Scholar]
  • 59.Ren J., Rajbhandari S., Aminabadi R.Y., Ruwase O., Yang S., Zhang M., Li D., He Y. ZeRO-Offload: Democratizing Billion-Scale Model Training. arXiv. 2021 https://arxiv.org/abs/2101.06840v1 Preprint at. [Google Scholar]
  • 60.Hu E.J., Shen Y., Wallis P., Allen-Zhu Z., Li Y., Wang S., Wang L., Chen W. LoRA: Low-Rank Adaptation of Large Language Models. arXiv. 2021 doi: 10.48550/arXiv.2106.09685. Preprint at. [DOI] [Google Scholar]
  • 61.Jarzab A., Kurzawa N., Hopf T., Moerch M., Zecha J., Leijten N., Bian Y., Musiol E., Maschberger M., Stoehr G., et al. Meltome atlas—thermal proteome stability across the tree of life. Nat. Methods. 2020;17:495–503. doi: 10.1038/s41592-020-0801-4. [DOI] [PubMed] [Google Scholar]
  • 62.Kim G.B., Gao Y., Palsson B.O., Lee S.Y. DeepTFactor: A deep learning-based tool for the prediction of transcription factors. Proc. Natl. Acad. Sci. 2021;118 doi: 10.1073/pnas.2021171118. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 63.Yao Z., Wu X., Li C., Youn S., He Y. ZeroQuant-V2: Exploring Post-training Quantization in LLMs from Comprehensive Study to Low Rank Compensation. arXiv. 2023 doi: 10.48550/arXiv.2303.08302. Preprint at. [DOI] [Google Scholar]
  • 64.Yao Z., Yazdani Aminabadi R., Zhang M., Wu X., Li C., He Y. ZeroQuant: Efficient and Affordable Post-Training Quantization for Large-Scale Transformers. Adv. Neural Inf. Process. Syst. 2022;35:27168–27183. [Google Scholar]
  • 65.Dao T., Fu D.Y., Ermon S., Rudra A., Ré C. FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness. arXiv. 2022 doi: 10.48550/arXiv.2205.14135. Preprint at. [DOI] [Google Scholar]
  • 66.Paszke A., Gross S., Massa F., Lerer A., Bradbury J., Chanan G., Killeen T., Lin Z., Gimelshein N., Antiga L., et al. PyTorch: An Imperative Style, High-Performance Deep Learning Library. arXiv. 2019 doi: 10.48550/arXiv.1912.01703. Preprint at. [DOI] [Google Scholar]
  • 67.Virtanen P., Gommers R., Oliphant T.E., Haberland M., Reddy T., Cournapeau D., Burovski E., Peterson P., Weckesser W., Bright J., et al. SciPy 1.0: fundamental algorithms for scientific computing in Python. Nat. Methods. 2020;17:261–272. doi: 10.1038/s41592-019-0686-2. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 68.Pedregosa F., Varoquaux G., Gramfort A., Michel V., Thirion B., Grisel O., Blondel M., Prettenhofer P., Weiss R., Dubourg V., et al. Scikit-learn: Machine Learning in Python. J. Mach. Learn. Res. 2011;12:2825–2830. [Google Scholar]
  • 69.Wang Y.-A., Chen Y.-N. What Do Position Embeddings Learn? An Empirical Study of Pre-Trained Language Model Positional Encoding. arXiv. 2020 doi: 10.48550/arXiv.2010.04903. Preprint at. [DOI] [Google Scholar]
  • 70.Su J., Ahmed M., Lu Y., Pan S., Bo W., Liu Y. RoFormer: Enhanced Transformer with Rotary Position Embedding. Neurocomputing. 2024;568 doi: 10.1016/j.neucom.2023.127063. [DOI] [Google Scholar]
  • 71.Hendrycks D., Gimpel K. Gaussian Error Linear Units (GELUs) arXiv. 2023 doi: 10.48550/arXiv.1606.08415. Preprint at. [DOI] [Google Scholar]
  • 72.Shazeer N. GLU Variants Improve Transformer. arXiv. 2020 doi: 10.48550/arXiv.2002.05202. Preprint at. [DOI] [Google Scholar]
  • 73.Xiong R., Yang Y., He D., Zheng K., Zheng S., Xing C., Zhang H., Lan Y., Wang L., Liu T.-Y. On Layer Normalization in the Transformer Architecture. arXiv. 2020 doi: 10.48550/arXiv.2002.04745. Preprint at. [DOI] [Google Scholar]
  • 74.python/cpython: The Python programming language. https://github.com/python/cpython

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Supplementary Materials

Document S1. Figures S1–S12
mmc1.pdf (1.9MB, pdf)
Table S1. Memory usage for inference with original and efficient ESM2 implementations
mmc2.xlsx (35.2KB, xlsx)
Table S2. Inference runtimes of original and efficient ESM2 implementations
mmc3.xlsx (37.5KB, xlsx)
Table S3. Perplexity of the original and efficient ESM2 model implementations
mmc4.xlsx (9.7KB, xlsx)
Table S4. Correlation between model predictions and experimental deep mutational scanning data for missense variant effects on the ProteinGYM dataset
mmc5.xlsx (10.7KB, xlsx)
Table S5. Effect of various optimization strategies on memory usage during model training
mmc6.xlsx (28.1KB, xlsx)
Table S6. One epoch training runtime for original and efficient model implementations
mmc7.xlsx (9.4KB, xlsx)
Table S7. Melting point prediction performance across different models using head-only fine-tuning
mmc8.xlsx (9.2KB, xlsx)
Table S8. Performance of fine-tuned models on GB1 fitness landscape prediction using head-only and Head + LoRA fine-tuning
mmc9.xlsx (9.2KB, xlsx)
Table S9. Performance of fine-tuned models on AAV fitness landscape prediction using head-only and Head + LoRA fine-tuning
mmc10.xlsx (9.2KB, xlsx)
Table S10. Performance of ESM2 models on transcription factor binding prediction, benchmarked against the DeepTFactor baseline using AUROC
mmc11.xlsx (9.2KB, xlsx)
Table S11. Performance of ESM2 models on transcription factor binding prediction, benchmarked against the DeepTFactor baseline using AUPRC
mmc12.xlsx (9.2KB, xlsx)
Table S12. Gene Ontology terms used in constructing the ground truth for the transcription factor prediction task
mmc13.xlsx (9.2KB, xlsx)

Data Availability Statement

  • All data reported in this study are available from the lead contact upon request.

  • The original code has been deposited on reproduce GitHub (github.com/uci-cbcl/esm-efficient) and is publicly accessible as of the date of publication. Model weights have been deposited on Hugging Face (huggingface.co/mhcelik/esm-efficient) and are publicly available as of the date of publication.

  • Any additional information required to reanalyze the data are available from the lead contact upon request.


Articles from iScience are provided here courtesy of Elsevier

RESOURCES