|
Download README.md from sasudo2/cafa5_models: direct link, hf CLI and curl.
- Browser
- Download file 7.51 kB
-
https://huggingface.co/sasudo2/cafa5_models/resolve/main/README.md
- Command line
-
hf download hf://sasudo2/cafa5_models/README.md
-
curl -L -o README.md https://huggingface.co/sasudo2/cafa5_models/resolve/main/README.md
7.51 kB
| license: apache-2.0 | |
| tags: | |
| - biology | |
| - protein-function-prediction | |
| - cafa5 | |
| - gene-ontology | |
| - esm2 | |
| # CAFA 5 Protein Function Prediction Models | |
| This repository contains trained models, configurations, and inference scripts developed for multi-label Gene Ontology (GO) protein function prediction, aligned with the **CAFA 5** tournament guidelines. | |
| --- | |
| ## 📋 Table of Contents | |
| 1. [Overview](#1-overview) | |
| 2. [Shared Files & Cross-Model Common Assets](#2-shared-files--cross-model-common-assets) | |
| 3. [Model Architectures & Context](#3-model-architectures--context) | |
| * [`esm2_ffn` (ESM-2 + Feed-Forward Network Head)](#esm2_ffn-esm-2--feed-forward-network-head) | |
| * [`blast_knn` (Sequence Alignment & K-Nearest Neighbors)](#blast_knn-sequence-alignment--k-nearest-neighbors) | |
| * [`lr3mer` (Logistic Regression 3-mer Baseline)](#lr3mer-logistic-regression-3-mer-baseline) | |
| 4. [Input & Output Schemas](#4-input--output-schemas) | |
| 5. [Quick Usage Example](#5-quick-usage-example) | |
| --- | |
| ## 1. Overview | |
| Predicting protein functions across the three Gene Ontology (GO) domains—**Biological Process (BPO)**, **Molecular Function (MFO)**, and **Cellular Component (CCO)**—is critical for structural biology and functional annotation. | |
| This repository provides three complementary modeling paradigms evaluated on identical training sequences (142,241 proteins) and test sequences (141,864 proteins): | |
| * **Deep Protein Language Modeling:** Contextual representations from ESM-2 coupled with a multi-label classification head. | |
| * **Sequence Alignment & Homology:** Fast sequence search using DIAMOND and annotation propagation via weighted K-Nearest Neighbors ($k=50$). | |
| * **N-gram Linear Baseline:** Multi-label logistic regression trained on normalized amino-acid 3-mer frequency representations. | |
| --- | |
| ## 2. Shared Files & Cross-Model Common Assets | |
| To guarantee strict benchmark fairness and reproducible evaluations, all models share a common vocabulary, training set, and artifact structure: | |
| ### Common Input Assets (`shared/` directory) | |
| * **`shared/selected_terms.json` & `go_terms.json` (4,152 GO terms):** | |
| * **What it is:** The ordered vocabulary of target GO term identifiers across BPO, MFO, and CCO. | |
| * **Why it is needed:** Multi-label classification models must predict identical target output vectors. By applying unified frequency knee cutoffs (BPO $\ge 106$, MFO $\ge 70$, CCO $\ge 79$) and pruning uninformative root terms (`GO:0003674`, `GO:0005575`, `GO:0008150`), all models output predictions over an identical label space. | |
| * **`shared/train_sequences_filtered.fasta` (142,241 proteins):** | |
| * **What it is:** The canonical FASTA file containing all quality-filtered training protein sequences. | |
| * **Why it is needed:** Guarantees that deep learning embeddings, 3-mer frequency counts, and the reference alignment database are constructed from identical sequences. | |
| * **`shared/train_terms_filtered.tsv` (4,692,553 annotations):** | |
| * **What it is:** Tab-separated ground-truth mapping linking each training `EntryID` to its experimental GO terms. | |
| * **Why it is needed:** Serves as the binary training target for `esm2_ffn` and `lr3mer`, as well as the reference annotation store propagated to query proteins by `blast_knn`. | |
| * **`shared/preprocessing_manifest.json`:** | |
| * **What it is:** Documented cutoff rules, data versions, and SHA-256 hashes verifying preprocessing provenance. | |
| ### Common Artifacts in Every Model Directory | |
| * **`manifest.json`:** | |
| * **What it is:** Standardized metadata file capturing configuration parameters, compute hardware (e.g. Tesla T4), runtime, random seed (`42`), package versions, and SHA-256 artifact checksums. | |
| * **Why it is needed:** Ensures full scientific reproducibility, verification of inputs/outputs, and parameter tracking across different modeling experiments. | |
| * **`submission.tsv`:** | |
| * **What it is:** CAFA 5 formatted prediction file containing `EntryID`, `term`, and probability `score` for all 141,864 test proteins. | |
| * **Why it is needed:** Enables out-of-the-box comparative evaluation and ensemble blending without re-running long inference pipelines. | |
| --- | |
| ## 3. Model Architectures & Context | |
| ### `esm2_ffn` (ESM-2 + Feed-Forward Network Head) | |
| A deep representation model that captures contextual amino-acid semantics from raw sequence representations. | |
| * **Architecture:** | |
| * **Backbone:** Frozen [`facebook/esm2_t33_650M_UR50D`](https://huggingface.co/facebook/esm2_t33_650M_UR50D) protein language model (33 layers, 1,280 hidden dimensions). | |
| * **Pooling:** Mean pooling over valid residue tokens (excluding special tokens). | |
| * **Head:** Linear(1280 $\to$ 512) $\to$ ReLU $\to$ Dropout(0.2) $\to$ Linear(512 $\to$ 4152). | |
| * **Self-Contained Deployment:** The single `esm2_ffn/model.safetensors` checkpoint bundles both the complete frozen ESM-2 encoder and the trained FFN head alongside tokenizer assets and configs (`esm2_base/config.json`), requiring no external download connection to original Facebook weights. | |
| * **Inference Optimizations:** Batched inference with dynamic token budgets (4,096 tokens) and length-sorted windows to minimize padding overhead and bound GPU VRAM usage. | |
| ### `blast_knn` (Sequence Alignment & K-Nearest Neighbors) | |
| A classical bioinformatics baseline leveraging evolutionary conservation and sequence homology. | |
| * **Architecture:** | |
| * **Aligner:** DIAMOND `blastp --fast` against `reference_sequences.fasta` (built from the 142,241 training proteins). | |
| * **Neighborhood Propagation:** Selects top $k=50$ nearest neighbors with an e-value threshold of $\le 0.001$. | |
| * **Weighting:** Scores are weighted by sequence percent identity (`pident`) and normalized against query annotations (`reference_annotations.parquet`), filtered at a minimum confidence threshold of 0.01. | |
| * **Context & Utility:** High-precision predictions for homologs with well-conserved sequences; provides a strong, orthogonal signal when ensembled with deep learning models. | |
| ### `lr3mer` (Logistic Regression 3-mer Baseline) | |
| A lightweight sequence composition baseline modeling local amino-acid motifs. | |
| * **Architecture:** | |
| * **Vocabulary:** 8,000 canonical 3-mer permutations (`AAA` through `YYY` derived from 20 standard amino acids, tracked in `three_mer_vocabulary.json`). | |
| * **Model:** Multi-label logistic regression per GO term implemented in PyTorch (`lr3mer/model.pt`), optimized using AdamW and positive class weighting (cap: 50.0). | |
| * **Context & Utility:** Fast, low-memory baseline requiring no GPU or alignment tools during inference. It captures short motif biases and baseline term frequencies across the proteome. | |
| --- | |
| ## 4. Input & Output Schemas | |
| * **Required Input FASTA:** | |
| ```fasta | |
| >P12345 | |
| MKTLLILTCLVAVALAMKTLL... | |
| ``` | |
| * **Prediction Output Format (`submission.tsv`):** | |
| Headerless TSV format adhering to CAFA 5 specifications: | |
| ```tsv | |
| P12345 GO:0005515 0.842 | |
| P12345 GO:0008152 0.619 | |
| P12345 GO:0003674 0.520 | |
| ``` | |
| --- | |
| ## 5. Quick Usage Example | |
| Execute inference on arbitrary sequences using the standalone `esm2_ffn` runner: | |
| ```python | |
| import runpy | |
| from huggingface_hub import hf_hub_download | |
| repo = "sasudo2/cafa5_models" | |
| revision = "main" | |
| # Download and execute the self-contained inference script | |
| loader = hf_hub_download(repo, "esm2_ffn/inference.py", revision=revision) | |
| inference = runpy.run_path(loader) | |
| # Run batch prediction directly from FASTA | |
| inference["predict_fasta"](repo, "input_proteins.fasta", "predictions.tsv", revision=revision) | |
| ``` | |