File size: 5,689 Bytes
9f16c4c
 
 
 
 
 
 
 
 
 
 
317a5ec
9f16c4c
 
 
 
 
 
 
 
 
 
 
 
317a5ec
9f16c4c
 
a24e458
 
9f16c4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a24e458
 
 
 
 
 
 
 
 
9f16c4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a24e458
 
9f16c4c
 
 
 
 
 
 
 
a24e458
 
 
 
 
 
 
 
 
 
 
 
9f16c4c
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
---
license: mit
tags:
  - biology
  - bioinformatics
  - peptides
  - protein
  - antimicrobial-peptide
  - amp
  - pytorch
  - transformers
  - protein-sequence
  - sequence-classification
library_name: custom
base_model: none
metrics:
  - f1
  - accuracy
  - roc_auc
  - mcc
model-index:
  - name: PeptEdgeV2
    results:
      - task:
          type: protein-sequence
          name: Antimicrobial Peptide (AMP) Binary Classification
        dataset:
          type: devansh0703/GenPept-Curated-2025
          id: devansh0703/GenPept-Curated-2025
          name: GenPept-Curated-2025 (balanced_11000)
          split: test
        metrics:
          - name: F1 Score
            type: f1
            value: 0.9147
          - name: Accuracy
            type: accuracy
            value: 0.9134
          - name: ROC AUC
            type: roc_auc
            value: 0.9510
          - name: Matthews Correlation Coefficient
            type: mcc
            value: 0.8272
---

# PeptEdgeV2: Parameter-Efficient Antimicrobial Peptide Classification

State-of-the-art antimicrobial peptide (AMP) classifier with **189x fewer parameters** than prior
methods, reaching **91.47% F1**, **91.34% accuracy**, and **95.10% AUC** on the
GenPept-Curated-2025 benchmark.

| Metric | PeptEdgeV2 | ESM-2 LoRA (prior SOTA) | Delta |
|--------|-----------|------------------------|-------|
| F1 Score | 91.47% | 88.30% | +3.17% |
| Accuracy | 91.34% | 86.80% | +4.54% |
| AUC | 0.9510 | 0.938 | +0.013 |
| Parameters | **3.43M** | 650M | 189x fewer |
| Inference | 52,800 seq/s | 248 seq/s | 213x faster |

## Model Description

PeptEdgeV2 combines four components in a single compact encoder:

1. **Biophysical Embedding** — 12 physicochemical properties per amino acid (from a fixed table)
   concatenated with learned token embeddings (192-dim total).
2. **Multi-Scale Convolution** — four parallel `Conv1D` branches (kernel sizes 3, 5, 7, 11) with
   batch norm + residual connections.
3. **SwiGLU Transformer** — 5 transformer layers with gated feed-forward networks and stochastic
   depth regularization.
4. **Adaptive Tri-Pooling** — mean, max, and attention pooling fused before a 3-layer MLP head.

Total parameters: **3,434,018**.

- **Config** (`config.json`): `d_model=192, n_heads=6, num_layers=5, ff_dim=384, dropout=0.25,
  sd_prob=0.05, vocab_size=21, max_len=200, num_classes=2`
- **Input encoding**: amino-acid tokens `0..20` (`PAD=0`, 20 standard AAs, `X=20`), truncated/padded
  to `max_len=200`.

## Quickstart

Install:

```bash
pip install torch huggingface-hub safetensors numpy pandas scikit-learn
```

The repo contains full source (`model_v2.py`, `data_utils.py`, `train_final.py`). To load the model:

```python
import torch
from model_v2 import PeptEdgeV2

model = PeptEdgeV2.from_pretrained("devansh0703/PeptEdgeV2")
model.eval()

# Encode a peptide (tokens 1-20 = AAs, 0 = pad)
from data_utils import encode_sequence
ids = encode_sequence("GLFDIVKKVVGALGSL", max_len=200)
x = torch.tensor([ids])

with torch.no_grad():
    logits = model(x)
    prob_amp = torch.softmax(logits, dim=-1)[0, 1].item()
print(f"P(AMP) = {prob_amp:.3f}")
```

## Dataset

Trained on the **GenPept-Curated-2025** benchmark. The curated tables are mirrored on the Hub as a
dataset repo:

- **HF dataset:** [devansh0703/GenPept-Curated-2025](https://huggingface.co/datasets/devansh0703/GenPept-Curated-2025)
- **Original source:** https://github.com/biochem-data-sci/GenPept-Curated-2025
- **Paper (bioRxiv):** https://doi.org/10.64898/2026.04.25.720793
- **License:** CC-BY-NC 4.0 (dataset belongs to its original authors — see dataset card)

Dataset summary:
- 11,000 peptide sequences (5,500 AMP / 5,500 non-AMP)
- Sequence lengths 10–200 amino acids
- Taxonomy: Bacteria, Archaea, Fungi

> **Note on splits:** the published numbers come from a simple random stratified split
> (`random_state=42`), *not* the homology-controlled CD-HIT split described in the README/paper.

## Training

The final pipeline lives in `train_final.py` (CUDA + mixed precision required):

```bash
python train_final.py
```

Key hyperparameters (embedded in `train_final.py`): `lr=3e-4`, `weight_decay=5e-5`,
`label_smoothing=0.1`, warmup 15 epochs over 100, cosine decay, gradient clipping 1.0,
early stopping patience 30 on validation F1.

## Test Results

From `results/final_results.json`:

| Metric | Value |
|--------|-------|
| Accuracy | 0.9134 |
| Precision | 0.9009 |
| Recall | 0.9290 |
| F1 | 0.9147 |
| AUC | 0.9510 |
| MCC | 0.8272 |
| Params | 3,434,018 |

## Files

| File | Description |
|------|-------------|
| `config.json` | Model hyperparameters |
| `model.safetensors` | Trained weights (SOTA pipeline) |
| `model_v2.py` | PeptEdgeV2 architecture + `from_pretrained`/`save_pretrained` |
| `data_utils.py` | AA vocab, encoding, dataloaders |
| `train_final.py` | Final training/eval pipeline |
| `model.py` / `train.py` | Earlier v1 architecture (kept for reference) |
| `train_v2.py` | Older grid-search script (outdated, lower metrics) |

## Citation

If you use this model, cite the model:

```bibtex
@article{peptedgev2,
  title={PeptEdgeV2: A Parameter-Efficient Multi-Scale Hybrid Architecture for Antimicrobial Peptide Classification},
  author={Devansh Raulo},
  year={2026}
}
```

If you use the dataset, cite its original authors:

```bibtex
@article{Pham2026GenPeptCurated2025,
  title={GenPept-Curated-2025: A Benchmark Dataset for Antimicrobial Peptide Prediction with Homology-Controlled Partitioning},
  author={Huynh Trong Pham and Bao Huynh and Thanh-Hoang Nguyen-Vo},
  journal={bioRxiv},
  year={2026},
  doi={10.64898/2026.04.25.720793}
}
```

## License

MIT