Update README.md
Browse files
README.md
CHANGED
|
@@ -3,4 +3,88 @@ license: mit
|
|
| 3 |
base_model:
|
| 4 |
- facebook/esm2_t36_3B_UR50D
|
| 5 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
|
|
|
| 3 |
base_model:
|
| 4 |
- facebook/esm2_t36_3B_UR50D
|
| 5 |
---
|
| 6 |
+
# Antibody ESM2 Paired Model
|
| 7 |
+
|
| 8 |
+
## Model Description
|
| 9 |
+
|
| 10 |
+
This model is a fine-tuned version of ESM2-3B for paired antibody sequences (heavy and light chains).
|
| 11 |
+
|
| 12 |
+
**Key Features:**
|
| 13 |
+
- Trained on paired antibody sequences
|
| 14 |
+
- 15% WC followed by 50% CDr fine-tuning
|
| 15 |
+
- Input format: Heavy-Light chains separated by "-"
|
| 16 |
+
- Output: 2560-dimensional embeddings
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
### Preprocessing
|
| 20 |
+
|
| 21 |
+
Sequences were:
|
| 22 |
+
1. Combined as: HEAVY-LIGHT (with "-" separator)
|
| 23 |
+
2. Uncommon amino acids replaced with X
|
| 24 |
+
3. Tokenized with ESM2 tokenizer
|
| 25 |
+
4. CDR regions annotated for masking
|
| 26 |
+
|
| 27 |
+
## Usage
|
| 28 |
+
|
| 29 |
+
### Loading the Model
|
| 30 |
+
|
| 31 |
+
\`\`\`python
|
| 32 |
+
from transformers import EsmModel, AutoTokenizer
|
| 33 |
+
import torch
|
| 34 |
+
|
| 35 |
+
# Load model and tokenizer
|
| 36 |
+
model = EsmModel.from_pretrained("MahTala/AbCDR-ESM2")
|
| 37 |
+
tokenizer = AutoTokenizer.from_pretrained("MahTala/AbCDR-ESM2")
|
| 38 |
+
model.eval()
|
| 39 |
+
\`\`\`
|
| 40 |
+
|
| 41 |
+
### Extract Embeddings
|
| 42 |
+
|
| 43 |
+
\`\`\`python
|
| 44 |
+
# Prepare paired sequence
|
| 45 |
+
SEP_TOKEN = "-"
|
| 46 |
+
heavy_chain = (
|
| 47 |
+
"EVQLVESGGGLVQPGGSLRLSCAASGFTFSSYAMSWVRQAPGKGLEWVAVISYDGSNKYYADSVKGRF"
|
| 48 |
+
"TISADTSKNTAYLQMNSLRAEDTAVYYCAREGYYGSSYWYFDYWGQGTLVTVSS"
|
| 49 |
+
)
|
| 50 |
+
light_chain = (
|
| 51 |
+
"DIQMTQSPSSLSASVGDRVTITCRASQSISSYLNWYQQKPGKAPKLLIYAASSLQSGVPSRFSGSGS"
|
| 52 |
+
"GTDFTLTISSLQPEDFATYYCQQSYSTPLTFGGGTKVEIK"
|
| 53 |
+
)
|
| 54 |
+
paired_sequence = f"{h_chain}{SEP_TOKEN}{l_chain}"
|
| 55 |
+
|
| 56 |
+
# Tokenize
|
| 57 |
+
inputs = tokenizer(paired, return_tensors="pt", add_special_tokens=True)
|
| 58 |
+
|
| 59 |
+
# Extract embeddings
|
| 60 |
+
with torch.no_grad():
|
| 61 |
+
outputs = model(**inputs)
|
| 62 |
+
embeddings = outputs.last_hidden_state
|
| 63 |
+
|
| 64 |
+
# Mean pooling
|
| 65 |
+
mask = inputs["attention_mask"].unsqueeze(-1)
|
| 66 |
+
pooled = (embeddings * mask).sum(1) / mask.sum(1)
|
| 67 |
+
|
| 68 |
+
print(f"Embedding shape: {pooled.shape}") # (1, 2560)
|
| 69 |
+
\`\`\`
|
| 70 |
+
|
| 71 |
+
## Input Format
|
| 72 |
+
|
| 73 |
+
**Required Format:** `HEAVY_CHAIN-LIGHT_CHAIN`
|
| 74 |
+
|
| 75 |
+
- Heavy and light chains must be separated by hyphen (`-`)
|
| 76 |
+
- Use standard single-letter amino acid codes
|
| 77 |
+
- No spaces in sequence
|
| 78 |
+
- Uncommon residues should be replaced with X
|
| 79 |
+
|
| 80 |
+
**Example:**
|
| 81 |
+
\`\`\`python
|
| 82 |
+
sequence = "EVQLVESGGGLVQPGGSLRLSCAASGFTFSSYAMS...-DIQMTQSPSSLSASVGDRVTITCRASQSISS..."
|
| 83 |
+
\`\`\`
|
| 84 |
+
|
| 85 |
+
## Output
|
| 86 |
+
|
| 87 |
+
- **Embedding dimension:** 2560
|
| 88 |
+
- **Sequence length:** Variable (up to ~1024 tokens including special tokens)
|
| 89 |
+
- **Format:** PyTorch tensor
|
| 90 |
|