Update README.md
Browse files
README.md
CHANGED
@@ -12,14 +12,14 @@ tags:
|
|
12 |
- OAS
|
13 |
---
|
14 |
|
15 |
-
|
16 |
|
17 |
This is a huggingface version of AbLang: A language model for antibodies. It was introduced in
|
18 |
[this paper](https://doi.org/10.1101/2022.01.20.477061) and first released in
|
19 |
[this repository](https://github.com/oxpig/AbLang). This model is trained on uppercase amino acids: it only works with capital letter amino acids.
|
20 |
|
21 |
|
22 |
-
|
23 |
|
24 |
The model could be used for protein feature extraction or to be fine-tuned on downstream tasks (TBA).
|
25 |
|
@@ -42,6 +42,42 @@ Sequence embeddings can be produced as follows:
|
|
42 |
|
43 |
TBA (just mean pool not including special tokens)
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
### Citation
|
46 |
```
|
47 |
@article{Olsen2022,
|
|
|
12 |
- OAS
|
13 |
---
|
14 |
|
15 |
+
### AbLang model for heavy chains
|
16 |
|
17 |
This is a huggingface version of AbLang: A language model for antibodies. It was introduced in
|
18 |
[this paper](https://doi.org/10.1101/2022.01.20.477061) and first released in
|
19 |
[this repository](https://github.com/oxpig/AbLang). This model is trained on uppercase amino acids: it only works with capital letter amino acids.
|
20 |
|
21 |
|
22 |
+
### Intended uses & limitations
|
23 |
|
24 |
The model could be used for protein feature extraction or to be fine-tuned on downstream tasks (TBA).
|
25 |
|
|
|
42 |
|
43 |
TBA (just mean pool not including special tokens)
|
44 |
|
45 |
+
### Fine-tune
|
46 |
+
|
47 |
+
To save memory we recomend using [LoRA](https://doi.org/10.48550/arXiv.2106.09685):
|
48 |
+
|
49 |
+
```python
|
50 |
+
pip install git+https://github.com/huggingface/peft.git
|
51 |
+
pip install loralib
|
52 |
+
```
|
53 |
+
|
54 |
+
LoRA greatly reduces the number of trainable parameters and performs on-par or better than fine-tuning full model.
|
55 |
+
|
56 |
+
```python
|
57 |
+
from peft import LoraConfig, get_peft_model
|
58 |
+
|
59 |
+
def apply_lora_bert(model):
|
60 |
+
config = LoraConfig(
|
61 |
+
r=8, lora_alpha=32,
|
62 |
+
lora_dropout=0.3,
|
63 |
+
target_modules=['query', 'value']
|
64 |
+
)
|
65 |
+
for param in model.parameters():
|
66 |
+
param.requires_grad = False # freeze the model - train adapters later
|
67 |
+
if param.ndim == 1:
|
68 |
+
# cast the small parameters (e.g. layernorm) to fp32 for stability
|
69 |
+
param.data = param.data.to(torch.float32)
|
70 |
+
model.gradient_checkpointing_enable() # reduce number of stored activations
|
71 |
+
model.enable_input_require_grads()
|
72 |
+
model = get_peft_model(model, config)
|
73 |
+
return model
|
74 |
+
|
75 |
+
model = apply_lora_bert(model)
|
76 |
+
|
77 |
+
model.print_trainable_parameters()
|
78 |
+
# trainable params: 294912 || all params: 85493760 || trainable%: 0.3449514911965505
|
79 |
+
```
|
80 |
+
|
81 |
### Citation
|
82 |
```
|
83 |
@article{Olsen2022,
|