Deep Learning with Proteins – Hugging Face guide to protein language models and folding

TL;DR

Hugging Face released a set of notebooks that let researchers fine‑tune pre‑trained protein language models (e.g., ESM‑2, ProtBERT) and run the ESMFold folding model, proving that the same transfer‑learning pipelines used for text can be applied to protein sequence classification, token classification, and structure prediction.


Introduction for Biologists: What a Language Model Is

A language model is a neural network trained on massive text corpora to learn the statistical structure of language. By pre‑training on abundant data and then fine‑tuning on a small downstream task, the model transfers its learned knowledge, dramatically reducing the amount of task‑specific data needed. This concept underlies modern NLP breakthroughs such as ULMFiT and BERT and forms the basis for protein‑focused models.

"Transfer learning yields performance equivalent to having more than 100× as much training data" – illustration from the ULMFiT paper cited in the blog.

Introduction for Machine‑Learning Practitioners: What a Protein Is

Proteins are linear chains of amino acids, each represented by a single letter (20 standard symbols). Although the alphabet is tiny, the combinatorial possibilities produce an enormous diversity of structures and functions. Like sentences, protein sequences exhibit long‑range dependencies; the three‑dimensional fold of a residue often depends on distant residues, making self‑attention mechanisms especially suitable.

Transfer Learning for Proteins

The same pre‑training‑then‑fine‑tuning workflow used for text can be applied to proteins:

  1. Pre‑train a transformer on a huge database of protein sequences (e.g., UniProt) to learn generic biochemical patterns.
  2. Fine‑tune the resulting model on a specific downstream task such as:
    • Sequence classification (e.g., subcellular localization).
    • Token classification (e.g., predicting post‑translational modification sites).
    • Structure prediction (protein folding). Because the pre‑trained model already encodes protein‑level knowledge, downstream tasks require far fewer labeled examples.

Protein Folding with ESMFold

ESMFold is Hugging Face’s implementation of a transformer‑based folding model similar to AlphaFold2 but without external database searches. It takes an amino‑acid string (e.g., MLKNV…) and directly outputs a 3‑D structure along with confidence scores. The model runs quickly on a GPU and can produce high‑quality predictions in seconds, as illustrated by the homodimeric P. multocida glucosamine‑6‑phosphate deaminase example.

Practical Resources

  • Fine‑tuning notebooks (PyTorch & TensorFlow) that demonstrate sequence and token classification using the ESM‑2 checkpoint.
  • ESMFold notebook (PyTorch only) for end‑to‑end folding predictions.
  • Data sources: UniProt provides a REST API and bulk downloads for large‑scale protein sequence collections.
  • Model hubs: Pre‑trained checkpoints such as facebook/esm2… (state‑of‑the‑art) and Rostlab/prot_bert (early benchmark) are hosted on the Hugging Face Model Hub and can be swapped by changing the checkpoint identifier.

Getting Started for Different Audiences

  • For ML engineers: The fine‑tuning code mirrors standard NLP scripts; replace the data‑loading step with your own list of sequences and labels.
  • For biologists: The notebooks isolate data loading, allowing you to focus on defining the biological task and providing labeled sequences.

Community Impact and Next Steps

Hugging Face encourages researchers to upload trained models back to the Hub, enabling reproducibility and rapid dissemination. Models can be showcased in interactive Spaces, letting anyone input a protein sequence and receive predictions without writing code. This open‑source workflow accelerates collaboration between computational scientists and experimental biologists.


The blog post does not contain quantitative benchmark results beyond the qualitative statements above; all claims are directly taken from the original Hugging Face article.

Sources