Skip to content

Commit 84cb9d4

Browse files
committed
release initial version of Enformer uploaded to huggingface based on deepminds recently released weights
1 parent 7280544 commit 84cb9d4

3 files changed

Lines changed: 10 additions & 42 deletions

File tree

README.md

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -115,60 +115,34 @@ corr_coef # pearson R, used as a metric in the paper
115115

116116
## Pretrained Model
117117

118-
Deepmind has released the weights for their tensorflow sonnet Enformer model! I have ported it over to pytorch at <a href="https://drive.google.com/u/0/uc?id=1sg41meLWKPMaM6hMx4aBWSwlVOfXbe0R">here</a> (~1GB). There are still some rounding errors that seem to be accruing across the layers, resulting in an absolute error as high as `0.5`. However, correlation coefficient look good so I am releasing it and will upload it to Huggingface in due time. Will keep working on figuring out where the numerical errors are happening (it may be the attention pooling module, as I noticed the attention logits are pretty high).
118+
Deepmind has released the weights for their tensorflow sonnet Enformer model! I have ported it over to Pytorch and uploaded it to <a href="https://huggingface.co/EleutherAI/enformer-official-rough">🤗 Huggingface</a> (~1GB). There are still some rounding errors that seem to be accruing across the layers, resulting in an absolute error as high as `0.5`. However, correlation coefficient look good so I am releasing the 'rough'ly working version. Will keep working on figuring out where the numerical errors are happening (it may be the attention pooling module, as I noticed the attention logits are pretty high).
119119

120120
```bash
121121
$ pip install enformer-pytorch==0.5
122122
````
123123

124-
Copy model to local directory
125-
126-
```bash
127-
$ cp /path/to/official-enformer-rough.pt ./official-enformer-rough.pt
128-
```
129-
130124
Loading the model
131125

132126
```python
133-
enformer = Enformer.from_hparams().cuda()
134-
enformer.load_state_dict(torch.load('./official-enformer-rough.pt'))
127+
from enformer_pytorch import Enformer
128+
enformer = Enformer.from_pretrained('EleutherAI/enformer-official-rough')
135129
```
136130

137-
Quick test
131+
Quick sanity check on a single human validation point
138132

139133
```python
140134
$ python test_pretrained.py
141135
# 0.5963 correlation coefficient on a validation sample
142136
```
143137

144-
## Older models (no longer recommended)
145-
146-
First make sure you are on version 0.4.5 or below
147-
148-
```
149-
$ pip install enformer-pytorch==0.4.5
150-
```
151-
152-
Warning: the pretrained models so far have not hit the mark of what was presented in the paper. if you would like to help out, please join <a href="https://discord.com/invite/s7WyNU24aM">this discord</a>. replication efforts ongoing
153-
154-
To use a pretrained model (may not be of the same quality as the one in the paper yet), simply use the `from_pretrained` method (powered by [HuggingFace](https://huggingface.co/)):
155-
156-
```python
157-
from enformer_pytorch import Enformer
158-
159-
model = Enformer.from_pretrained("EleutherAI/enformer-preview")
160-
161-
# do your fine-tuning
162-
```
163-
164-
This is made possible thanks to HuggingFace's [custom model](https://huggingface.co/docs/transformers/master/en/custom_models) feature. All Enformer checkpoints can be found on the [hub](https://huggingface.co/models?other=enformer).
138+
This is all made possible thanks to HuggingFace's [custom model](https://huggingface.co/docs/transformers/master/en/custom_models) feature.
165139
166140
You can also load, with overriding of the `target_length` parameter, if you are working with shorter sequence lengths
167141
168142
```python
169143
from enformer_pytorch import Enformer
170144
171-
model = Enformer.from_pretrained('EleutherAI/enformer-preview', target_length = 128, dropout_rate = 0.1)
145+
model = Enformer.from_pretrained('EleutherAI/enformer-official-rough', target_length = 128, dropout_rate = 0.1)
172146
173147
# do your fine-tuning
174148
```
@@ -178,7 +152,7 @@ To save on memory during fine-tuning a large Enformer model
178152
```python
179153
from enformer_pytorch import Enformer
180154
181-
enformer = Enformer.from_pretrained('EleutherAI/enformer-preview', use_checkpointing = True)
155+
enformer = Enformer.from_pretrained('EleutherAI/enformer-official-rough', use_checkpointing = True)
182156
183157
# finetune enformer on a limited budget
184158
```

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
name = 'enformer-pytorch',
55
packages = find_packages(exclude=[]),
66
include_package_data = True,
7-
version = '0.5.0',
7+
version = '0.5.1',
88
license='MIT',
99
description = 'Enformer - Pytorch',
1010
author = 'Phil Wang',

test_pretrained.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import torch
22
from enformer_pytorch import Enformer
33

4-
# download pytorch weights from official set of deepmind enformer weights
5-
# from https://drive.google.com/u/0/uc?id=1sg41meLWKPMaM6hMx4aBWSwlVOfXbe0R
6-
7-
model_path = './official-enformer-rough.pt'
8-
9-
enformer = Enformer.from_hparams().cuda()
10-
enformer.load_state_dict(torch.load(model_path))
4+
enformer = Enformer.from_pretrained('EleutherAI/enformer-official-rough').cuda()
115
enformer.eval()
126

137
data = torch.load('./data/test-sample.pt')
@@ -22,4 +16,4 @@
2216
)
2317

2418
print(corr_coef)
25-
assert corr_coef > 0.1
19+
assert corr_coef > 0.1

0 commit comments

Comments
 (0)