/ Модель

Характеристики

Контекст
1 026 токенов
Параметры
865 млн
Архитектура
fast_esm · dense
Библиотека
transformers
Опубликована
3 дек 2024

FastESM2_650

Заполнение пропусковТекст → текст3 профессии

Ускоренная дообученная модель ESM2-650 для заполнения маскированных позиций в белковых последовательностях и получения их эмбеддингов.

416скачиваний за 30 дней3лайкавеса обновлены2 окт 2026

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

Synthyra/FastESM2_650 — белковая языковая модель семейства ESM2, разработанная Synthyra как ускоренная реализация FastESM для Transformers. Веса ESM2-650 дообучены ещё на 50 000 шагов с обычной задачей маскированного языкового моделирования на наборе OMGprot50; модель содержит 865,1 млн параметров, использует плотную архитектуру FastEsmForMaskedLM и принимает последовательности длиной до 2048 токенов по описанию обучения. Метаданные указывают native context в 1026 токенов.

Модель предназначена для заполнения замаскированных участков белковых последовательностей, получения контекстных представлений и расчёта логитов. README также описывает пакетное построение эмбеддингов и оценку свойств белков линейными пробами. FastESM оптимизирована для ускорения обучения и инференса с разными backend-ами внимания; автор рекомендует fp16, а для максимального ускорения — PyTorch 2.5 или новее. Экспериментальный режим test-time training с локальными LoRA-адаптерами может помочь на сложных белках, но увеличивает вычислительные затраты и способен ухудшить уверенные предсказания.

Вход модели — аминокислотные последовательности, выход — токенные представления и оценки для маскированных позиций. Для репозитория указаны веса safetensors и библиотека Transformers. Лицензия в предоставленных данных не приведена.

Сценарии применения

  • восстановление замаскированных аминокислот в белковой последовательности
  • получение эмбеддингов белковых последовательностей
  • пакетное векторное представление набора белков
  • извлечение признаков белка для классификации свойств
  • извлечение признаков белка для токенной разметки

Ограничения

Экспериментальный test-time training увеличивает вычислительные затраты и может ухудшить уже уверенные предсказания. README рекомендует fp16; указание на контекст в README (2048) расходится с метаданными native_context_tokens (1026).

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

NOTE

The GitHub with the implementation and requirements.txt can be found here

FastESM

FastESM is a Huggingface compatible plug in version of ESM2 rewritten with a newer PyTorch attention implementation.

Load any ESM2 models into a FastEsm model to dramatically speed up training and inference without ANY cost in performance.

The default attention backend is sdpa. See the FastPLMs README for a full breakdown of available backends (sdpa, kernels_flash, flex, auto) and how to switch between them. Attention maps (output_attentions=True) are supported on all backends via a separate naive computation. Various other optimizations also make the base implementation slightly different than the one in transformers.

FastESM2-650

A faster half-precision version of ESM2-650 with FlashAttention2 and longer context

To enhance the weights with longer context and better fp16 support, we trained ESM2-650 50000 additional steps with a traditional MLM objective (20% masking) in fp16 mixed precision on OMGprot50 up to sequence length of 2048.

Use with 🤗 transformers

For working with embeddings

import torch
from transformers import AutoModel, AutoTokenizer

model_path = 'Synthyra/FastESM2_650'
model = AutoModel.from_pretrained(model_path, dtype=torch.float16, trust_remote_code=True).eval()
tokenizer = model.tokenizer

sequences = ['MPRTEIN', 'MSEQWENCE']
tokenized = tokenizer(sequences, padding=True, return_tensors='pt')
with torch.no_grad():
    embeddings = model(**tokenized).last_hidden_state

print(embeddings.shape) # (2, 11, 1280)

For working with sequence logits

import torch
from transformers import AutoModelForMaskedLM, AutoTokenizer

model = AutoModelForMaskedLM.from_pretrained(model_path, dtype=torch.float16, trust_remote_code=True).eval()
with torch.no_grad():
    logits = model(**tokenized).logits

print(logits.shape) # (2, 11, 33)

Experimental test-time training

TTT is disabled by default. Normal inference, embeddings, logits, and state_dict() keys are unchanged unless you explicitly call model.ttt(...). The current implementation is experimental and trains only local LoRA adapters on the ESM2 backbone using masked language modeling on the test protein. It can help difficult proteins, but it adds test-time compute and can hurt already confident predictions.

metrics = model.ttt(
    seq="MSTNPKPQRKTKRNT",
    ttt_config={"steps": 3, "ags": 1, "batch_size": 1},
)
model.ttt_reset()
print(metrics["losses"])

For working with attention maps

import torch
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained(model_path, dtype=torch.float16, trust_remote_code=True).eval()
with torch.no_grad():
    attentions = model(**tokenized, output_attentions).attentions # tuples of (batch_size, num_heads, seq_len, seq_len)

print(attentions[-1].shape) # (2, 20, 11, 11) 

Embed entire datasets with no new code

To embed a list of protein sequences fast, just call embed_dataset. Sequences are sorted to reduce padding tokens, so the initial progress bar estimation is usually much longer than the actual time it will take.

Example:

embedding_dict = model.embed_dataset(
    sequences=[
        'MALWMRLLPLLALLALWGPDPAAA', ... # list of protein sequences
    ],
    tokenizer=model.tokenizer,
    batch_size=2, # adjust for your GPU memory
    max_len=512, # adjust for your needs
    full_embeddings=False, # if True, no pooling is performed
    embed_dtype=torch.float32, # cast to what dtype you want
    pooling_types=['mean', 'cls'], # more than one pooling type will be concatenated together
    num_workers=0, # if you have many cpu cores, we find that num_workers = 4 is fast for large datasets
    sql=False, # if True, embeddings will be stored in SQLite database
    sql_db_path='embeddings.db',
    save=True, # if True, embeddings will be saved as a .pth file
    save_path='embeddings.pth',
)
# embedding_dict is a dictionary mapping sequences to their embeddings as tensors for .pth or numpy arrays for sql
model.embed_dataset()
Args:
    sequences: List of protein sequences
    batch_size: Batch size for processing
    max_len: Maximum sequence length
    full_embeddings: Whether to return full residue-wise (True) embeddings or pooled (False)
    pooling_type: Type of pooling ('mean' or 'cls')
    num_workers: Number of workers for data loading, 0 for the main process
    sql: Whether to store embeddings in SQLite database - will be stored in float32
    sql_db_path: Path to SQLite database
    
Returns:
    Dictionary mapping sequences to embeddings, or None if sql=True

Note:
    - If sql=True, embeddings can only be stored in float32
    - sql is ideal if you need to stream a very large dataset for training in real-time
    - save=True is ideal if you can store the entire embedding dictionary in RAM
    - sql will be used if it is True and save is True or False
    - If your sql database or .pth file is already present, they will be scanned first for already embedded sequences
    - Sequences will be truncated to max_len and sorted by length in descending order for faster processing

Model probes

We employ linear probing techniques on various PLMs and standard datasets, similar our previous paper, to assess the intrinsic correlation between pooled hidden states and valuable properties. FastESM performs very well.

The plot below showcases performance normalized between the negative control (random vector embeddings) and the best performer. Classification task scores are averaged between MCC and F1 (or F1max for multilabel) and regression tasks are averaged between Spearman rho and R2. image/png

Comparison of half precisions

Presumabely because we trained in mixed-precision fp16, fp16 has closer outputs to the fp32 weights then bf16. Therefore, we recommend loading in fp16.

When summing the MSE of 1000 sequences vs. the fp32 weights:

Average MSE for FP16: 0.00000140

Average MSE for BF16: 0.00004125

Inference speed

We look at various ESM models and their throughput on an H100. FastESM is over twice as fast as ESM2-650 with longer sequences. Requires PyTorch 2.5+ for the most savings, see SDPA. image/png

Citations

@misc{FastPLMs,
  author={Hallee, Logan and Bichara, David and Gleghorn, Jason P.},
  title={FastPLMs: Fast, efficient, protein language model inference from Huggingface AutoModel.},
  year={2024},
  url={https://huggingface.co/Synthyra/ESMplusplus_small},
  DOI={10.57967/hf/3726},
  publisher={Hugging Face}
}
@article{lin2023esm2,
  title={Evolutionary-scale prediction of atomic-level protein structure with a language model},
  author={Lin, Zeming and Akin, Halil and Rao, Roshan and Hie, Brian and Zhu, Zhongkai and Lu, Wenting and Smestad, Nikita and Verkuil, Robert and Kabeli, Ori and Shmueli, Yaniv and dos Santos Costa, Allan and Fazel-Zarandi, Maryam and Sercu, Tom and Candido, Salvatore and Rives, Alexander},
  journal={Science},
  volume={379},
  number={6637},
  pages={1123--1130},
  year={2023},
  DOI={10.1126/science.ade2574}
}
@article{dong2024flexattention,
  title={Flex Attention: A Programming Model for Generating Optimized Attention Kernels},
  author={Dong, Juechu and Feng, Boyuan and Guessous, Driss and Liang, Yanbo and He, Horace},
  journal={arXiv preprint arXiv:2412.05496},
  year={2024}
}
@inproceedings{paszke2019pytorch,
  title={PyTorch: An Imperative Style, High-Performance Deep Learning Library},
  author={Paszke, Adam and Gross, Sam and Massa, Francisco and Lerer, Adam and Bradbury, James and Chanan, Gregory and Killeen, Trevor and Lin, Zeming and Gimelshein, Natalia and Antiga, Luca and Desmaison, Alban and K{\"o}pf, Andreas and Yang, Edward and DeVito, Zach and Raison, Martin and Tejani, Alykhan and Chilamkurthy, Sasank and Steiner, Benoit and Fang, Lu and Bai, Junjie and Chintala, Soumith},
  booktitle={Advances in Neural Information Processing Systems 32},
  year={2019}
}

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · transformers · fill-mask

Нельзя запустить

Модели нужен код из репозитория; автор пока не в списке доверенных организаций.

Класс архитектуры
FastEsmForMaskedLM
Ревизия весов
4d54ba0

0 моделей