Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,75 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- protein
|
| 5 |
+
- antibody
|
| 6 |
+
- nanobody
|
| 7 |
+
- vhh
|
| 8 |
+
- structure
|
| 9 |
+
- masked-language-model
|
| 10 |
+
- esm
|
| 11 |
+
- saprot
|
| 12 |
+
base_model: westlake-repl/SaProt_650M_PDB
|
| 13 |
+
pipeline_tag: fill-mask
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# SaNano: Structure-Aware Nanobody Language Model
|
| 17 |
+
|
| 18 |
+
SaNano is a protein language model fine-tuned on VHH (nanobody) sequences for improved representation learning of single-domain antibodies. Built on top of [SaProt-650M](https://huggingface.co/westlake-repl/SaProt_650M_PDB), this model incorporates both sequence and predicted structure information to generate high-quality embeddings for VHH antibodies.
|
| 19 |
+
|
| 20 |
+
## Model Description
|
| 21 |
+
|
| 22 |
+
- **Base Model:** [SaProt_650M_PDB](https://huggingface.co/westlake-repl/SaProt_650M_PDB)
|
| 23 |
+
- **Model Size:** 650M parameters
|
| 24 |
+
- **Hidden Dimensionality:** 1280
|
| 25 |
+
- **Fine-tuning Method:** LoRA (Low-Rank Adaptation)
|
| 26 |
+
- Rank: 32
|
| 27 |
+
- Alpha: 64
|
| 28 |
+
- Dropout: 0.1
|
| 29 |
+
- Target modules: query, key, value, dense
|
| 30 |
+
- **Training Objective:** Masked Language Modeling (MLM)
|
| 31 |
+
- Masking probability: 15%
|
| 32 |
+
- Masking method: Uniform MLM
|
| 33 |
+
|
| 34 |
+
## Training Data
|
| 35 |
+
|
| 36 |
+
The model was fine-tuned on a curated dataset of 75% VHH sequences with predicted structures and 25% protein sequences with predicted structures. In training the model sees 50% sequences with structural tokens and 50% sequences with structureal tokens masked.
|
| 37 |
+
|
| 38 |
+
## Training Configuration
|
| 39 |
+
|
| 40 |
+
- **Steps:** 5000
|
| 41 |
+
- **Batch Size:** 16 per device (with gradient accumulation steps of 4)
|
| 42 |
+
- **Learning Rate:** 2e-5
|
| 43 |
+
- **Scheduler:** Cosine with 1000 warmup steps
|
| 44 |
+
- **Weight Decay:** 0.01
|
| 45 |
+
- **Precision:** FP16
|
| 46 |
+
|
| 47 |
+
## Usage
|
| 48 |
+
|
| 49 |
+
### Basic Usage
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
from transformers import EsmForMaskedLM, EsmTokenizer
|
| 53 |
+
|
| 54 |
+
def add_structure_masking(sequence):
|
| 55 |
+
return "#".join(sequence) + "#"
|
| 56 |
+
|
| 57 |
+
model = EsmForMaskedLM.from_pretrained("novonordisk-red/SaNano")
|
| 58 |
+
tokenizer = EsmTokenizer.from_pretrained("novonordisk-red/SaNano")
|
| 59 |
+
|
| 60 |
+
sequences = [
|
| 61 |
+
"EVQLVESGGGLVQAGGSLRLSCAASGFTFPTYAMAWFRQAPGKGREFV",
|
| 62 |
+
"QVQLQESGGGLVQAGGSLRLSCAASGRTFSSYAMGWFRQAPGKEREFVAAI",
|
| 63 |
+
"EVQLVESGGGLVQPGGSLRLSCAASGFTFSSYAMSWVRQAPGKG",
|
| 64 |
+
"DVQLVESGGGLVQAGGSLRLSCAASGRTFSTYAMGWFRQAPGKGREFVAGISWS"
|
| 65 |
+
]
|
| 66 |
+
|
| 67 |
+
# To convert to structure-aware format with masking. This is necessary if structural tokens are not computed
|
| 68 |
+
structure_aware_sequences = [add_structure_masking(seq) for seq in sequences]
|
| 69 |
+
|
| 70 |
+
# Result example:
|
| 71 |
+
# ["E#V#Q#L#V#E#S#G#G#G#L#V#Q#A#G#G#S#L#R#L#S#C#A#A#S#G#F#T#F#P#T#Y#A#M#A#W#F#R#Q#A#P#G#...", ...]
|
| 72 |
+
|
| 73 |
+
# For structure-aware input, use '#' between amino acids
|
| 74 |
+
inputs = tokenizer(structure_aware_sequences, return_tensors="pt")
|
| 75 |
+
outputs = model(**inputs)
|