ESM-2 35M Enzyme EC Number Classifier

Fine-tuned ESM-2 35M for Enzyme Commission (EC) number prediction from amino-acid sequences.

Task

Given a protein sequence, predict its 4-level EC number (e.g., 1.1.1.131).
Evaluation is at all 4 levels (L1–L4); primary metric is L4 accuracy.

Inference

python /app/predict.py --input val_inputs.parquet --output predictions.jsonl

Input: Parquet with columns id (str) and sequence (str).
Output: JSONL, one line per input: {"id": "...", "prediction": ["x.x.x.x", ...]}.

Docker

# Clone repo (includes model weights)
git lfs install
git clone https://huggingface.co/YOUR_USERNAME/enzyme-ec-esm2

# Build
docker build -t enzyme-ec enzyme-ec-esm2/

# Run
docker run --rm \
  -v $(pwd)/data:/data \
  enzyme-ec \
  python /app/predict.py \
    --input /data/val_inputs.parquet \
    --output /data/predictions.jsonl

Environment Variables

Variable Default Description
EC_TIME_BUDGET 660 Max seconds for inference
EC_BATCH 32 Batch size
EC_THRESH 0.5 Probability threshold for extra predictions (set 1.1 for top-1 only)

Training Code

# Key architecture (must match for checkpoint to load)
class ESMClassifier(nn.Module):
    def __init__(self, model_name, num_classes, dropout=0.1, n_freeze=4):
        super().__init__()
        self.esm = EsmModel.from_pretrained(model_name, add_pooling_layer=False)
        H = self.esm.config.hidden_size   # 480
        self.classifier = nn.Sequential(
            nn.Dropout(dropout), nn.Linear(H, H), nn.GELU(),
            nn.Dropout(dropout), nn.Linear(H, num_classes))

File Structure

.
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ README.md
β”œβ”€β”€ ec_vocabulary.json      # 6939 valid EC numbers
β”œβ”€β”€ inputs.py               # input validation helper
β”œβ”€β”€ model.py                # ESMClassifier definition + load_model()
β”œβ”€β”€ predict.py              # inference entrypoint
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ task.json               # benchmark metadata
└── weights/
    β”œβ”€β”€ classes.json        # l4 class list + fallback_ec
    β”œβ”€β”€ classifier_head.pt  # fine-tuned head state_dict
    β”œβ”€β”€ meta.json           # model hyperparameters
    └── esm2/               # ESM-2 backbone weights
        β”œβ”€β”€ config.json
        β”œβ”€β”€ model.safetensors
        β”œβ”€β”€ tokenizer_config.json
        └── vocab.txt
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support