Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,81 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- protein-language-model
|
| 5 |
+
- bioinformatics
|
| 6 |
+
- transformer
|
| 7 |
+
- cnn
|
| 8 |
+
- small-protein
|
| 9 |
+
- smORF
|
| 10 |
+
frameworks:
|
| 11 |
+
- pytorch
|
| 12 |
---
|
| 13 |
+
|
| 14 |
+
# TinyProteinTransformer (TPT)
|
| 15 |
+
|
| 16 |
+
TinyProteinTransformer (TPT) is a lightweight CNN-Transformer hybrid encoder designed for microbial smORF-encoded small proteins. It was pretrained on the Global Microbial smORF Catalog (GMSC, >280M sequences) using masked language modeling combined with contrastive learning, producing compact yet expressive residue-level and sequence-level protein representations.
|
| 17 |
+
|
| 18 |
+
This repository hosts the pretrained model weights for direct inference and downstream fine-tuning.
|
| 19 |
+
|
| 20 |
+
For training scripts, ablation code, and the full experimental pipeline, see the GitHub repository: [F4NG66/TPT](https://github.com/F4NG66/TPT)
|
| 21 |
+
|
| 22 |
+
## Files
|
| 23 |
+
|
| 24 |
+
| File | Description |
|
| 25 |
+
|---|---|
|
| 26 |
+
| `TPT.pt` | Baseline pretrained TPT weights (CNN-Transformer hybrid encoder, hidden dim 640) |
|
| 27 |
+
| `TPT_gated.py` | Gated variant of the TPT architecture|
|
| 28 |
+
|
| 29 |
+
## Model Details
|
| 30 |
+
|
| 31 |
+
- **Architecture:** CNN-Transformer hybrid encoder with multi-scale convolutional feature extraction and attention-based pooling
|
| 32 |
+
- **Hidden dimension:** 640
|
| 33 |
+
- **Transformer layers:** 20
|
| 34 |
+
- **CNN kernel sizes:** 3, 5, 7, 9
|
| 35 |
+
- **Max sequence length:** 128
|
| 36 |
+
- **Pretraining objective:** Masked language modeling + contrastive learning (temperature 蟿 = 0.1, loss weight 位 = 0.05)
|
| 37 |
+
- **Pretraining corpus:** GMSC10.90 (Global Microbial smORF Catalog)
|
| 38 |
+
|
| 39 |
+
## Usage
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
import torch
|
| 43 |
+
from model import TinyProteinTransformer
|
| 44 |
+
from utils import build_tokenizer
|
| 45 |
+
|
| 46 |
+
tokenizer = build_tokenizer()
|
| 47 |
+
model = TinyProteinTransformer(vocab_size=len(tokenizer))
|
| 48 |
+
model.load_state_dict(torch.load("TPT.pt", map_location="cpu"))
|
| 49 |
+
model.eval()
|
| 50 |
+
|
| 51 |
+
def encode(seq, max_len=128):
|
| 52 |
+
ids = [tokenizer.get(aa, tokenizer["X"]) for aa in seq][:max_len]
|
| 53 |
+
ids += [tokenizer["PAD"]] * (max_len - len(ids))
|
| 54 |
+
return torch.tensor(ids).unsqueeze(0)
|
| 55 |
+
|
| 56 |
+
with torch.no_grad():
|
| 57 |
+
x = encode("MKVLILACLVVVTITVS")
|
| 58 |
+
h = model.encode(x) # (1, L, 640) residue-level representations
|
| 59 |
+
embedding = model.attention_pool(h) # (1, 640) sequence-level embedding
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
For classification tasks, attach a lightweight linear head on top of `embedding`.
|
| 63 |
+
|
| 64 |
+
### Gated variant
|
| 65 |
+
|
| 66 |
+
`TPT_gated.py` defines the gated architecture variant. Load its accompanying checkpoint the same way, using the model class defined in that script in place of `TinyProteinTransformer`.
|
| 67 |
+
|
| 68 |
+
## Intended Use
|
| 69 |
+
|
| 70 |
+
TPT embeddings can be used as frozen features for downstream classification tasks on small secreted/microbial proteins, including antimicrobial peptide (AMP) prediction, toxicity (TOX) prediction, bacteriocin (BCN) classification, and anti-CRISPR (Acr) protein classification.
|
| 71 |
+
|
| 72 |
+
## Citation
|
| 73 |
+
|
| 74 |
+
```bibtex
|
| 75 |
+
@article{sheng2026tpt,
|
| 76 |
+
title={TPT: A Compact CNN-Transformer Encoder for Efficient Microbial Small Protein Modeling},
|
| 77 |
+
author={Sheng, Fang and Zhang, Junhe and Zhu, Chengkai},
|
| 78 |
+
journal={Frontiers in Microbiology},
|
| 79 |
+
year={2026}
|
| 80 |
+
}
|
| 81 |
+
```
|