ONNX Model Zoo

andrewdalpino/ESM2-35M-Protein-Molecular-Function

By andrewdalpino · ↓ 7 · ♥ 1 · Updated 2025-06-05

What's in this repo

This page lists the files in andrewdalpino/ESM2-35M-Protein-Molecular-Function, including model.onnx.

  • 1 ONNX models (.onnx files)
  • 10 files, including 3 .json, 2 .0, 1 .md, 1 .onnx, 1 .safetensors, 1 .txt
  • Last updated 2025-06-05

ONNX files

File Size Download
model.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

ESM2 Protein Function Caller

An Evolutionary-scale Model (ESM) for protein function prediction from amino acid sequences using the Gene Ontology (GO). Based on the ESM2 Transformer architecture, pre-trained on UniRef50, and fine-tuned on the AmiGO dataset, this model predicts the GO subgraph for a particular protein sequence - giving you insight into the molecular function, biological process, and location of the activity inside the cell.

Note: This version only models the molecular function subgraph of the gene ontology.

What are GO terms?

"The Gene Ontology (GO) is a concept hierarchy that describes the biological function of genes and gene products at different levels of abstraction (Ashburner et al., 2000). It is a good model to describe the multi-faceted nature of protein function."

"GO is a directed acyclic graph. The nodes in this graph are functional descriptors (terms or classes) connected by relational ties between them (is_a, part_of, etc.). For example, terms 'protein binding activity' and 'binding activity' are related by an is_a relationship; however, the edge in the graph is often reversed to point from binding towards protein binding. This graph contains three subgraphs (subontologies): Molecular Function (MF), Biological Process (BP), and Cellular Component (CC), defined by their root nodes. Biologically, each subgraph represent a different aspect of the protein's function: what it does on a molecular level (MF), which biological processes it participates in (BP) and where in the cell it is located (CC)."

From CAFA 5 Protein Function Prediction

Code Repository

https://github.com/andrewdalpino/esm2-function-classifier

Model Specs

  • Vocabulary Size: 33
  • Embedding Dimensions: 480
  • Attention Heads: 20
  • Encoder Layers: 12
  • Context Length: 1026

Basic Example

For a basic demonstration we can rank the GO terms for a particular sequence. For a more advanced example see the predict-subgraph.py source file.

import torch

from transformers import EsmTokenizer, EsmForSequenceClassification

model_name = "andrewdalpino/ESM2-35M-Protein-Molecular-Function"

tokenizer = EsmTokenizer.from_pretrained(model_name)

model = EsmForSequenceClassification.from_pretrained(model_name)

model.eval()

sequence = "MCNAWYISVDFEKNREDKSKCIHTRRNSGPKLLEHVMYEVLRDWYCLEGENVYMM"

top_k = 10

out = tokenizer(sequence)

input_ids = out["input_ids"]

input_ids = torch.tensor(input_ids, dtype=torch.int64).unsqueeze(0)

with torch.no_grad():
    outputs = model.forward(input_ids)

    probabilities = torch.sigmoid(outputs.logits.squeeze(0))

    probabilities, indices = torch.topk(probabilities, top_k)

probabilities = probabilities.tolist()

terms = [model.config.id2label[index] for index in indices.tolist()]

print(f"Top {args.top_k} GO Terms:")

for term, probability in zip(terms, probabilities):
    print(f"{probability:.4f}: {term}")

References:

  • A. Rives, et al. Biological structure and function emerge from scaling unsupervised learning to 250 million protein sequences, 2021.
  • Z. Lin, et al. Evolutionary-scale prediction of atomic level protein structure with a language model, 2022.
  • G. A. Merino, et al. Hierarchical deep learning for predicting GO annotations by integrating protein knowledge, 2022.
  • M. Ashburner, et al. Gene Ontology: tool for the unification of biology, 2000.

Model info

text-classification transformers
transformers tensorboard onnx safetensors esm text-classification gene-ontology proteomics dataset:andrewdalpino/AmiGO base_model:facebook/esm2_t12_35M_UR50D base_model:quantized:facebook/esm2_t12_35M_UR50D endpoints_compatible
↓ 7 ♥ 1

Created: 2025-05-12

Updated: 2025-06-05

View on Hugging Face

Files (10)

.gitattributes
README.md
config.json
events.out.tfevents.1748896612.Volluto.1063310.0
events.out.tfevents.1749094932.Volluto.3409555.0
model.onnx ONNX
model.safetensors
special_tokens_map.json
tokenizer_config.json
vocab.txt

Related models