prithivida
commited on
Commit
•
79c4f0f
1
Parent(s):
13d5c45
Update README.md
Browse files
README.md
CHANGED
@@ -177,14 +177,21 @@ sparse_rep = expander.expand(
|
|
177 |
```
|
178 |
|
179 |
|
|
|
180 |
## 8. With HuggingFace
|
181 |
|
|
|
|
|
|
|
|
|
|
|
182 |
```python
|
183 |
import torch
|
184 |
from transformers import AutoModelForMaskedLM, AutoTokenizer
|
185 |
|
186 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
187 |
tokenizer = AutoTokenizer.from_pretrained('prithivida/Splade_PP_en_v1')
|
|
|
188 |
model = AutoModelForMaskedLM.from_pretrained('prithivida/Splade_PP_en_v1')
|
189 |
model.to(device)
|
190 |
|
@@ -216,6 +223,7 @@ for k, v in sorted_d.items():
|
|
216 |
bow_rep.append((reverse_voc[k], round(v,2)))
|
217 |
|
218 |
print("SPLADE BOW rep:\n", bow_rep)
|
|
|
219 |
```
|
220 |
|
221 |
## BEIR Zeroshot ODD performance:
|
|
|
177 |
```
|
178 |
|
179 |
|
180 |
+
|
181 |
## 8. With HuggingFace
|
182 |
|
183 |
+
**NOTEBOOK USERS, please login first**
|
184 |
+
```
|
185 |
+
!huggingface-cli login
|
186 |
+
```
|
187 |
+
|
188 |
```python
|
189 |
import torch
|
190 |
from transformers import AutoModelForMaskedLM, AutoTokenizer
|
191 |
|
192 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
193 |
tokenizer = AutoTokenizer.from_pretrained('prithivida/Splade_PP_en_v1')
|
194 |
+
reverse_voc = {v: k for k, v in tokenizer.vocab.items()}
|
195 |
model = AutoModelForMaskedLM.from_pretrained('prithivida/Splade_PP_en_v1')
|
196 |
model.to(device)
|
197 |
|
|
|
223 |
bow_rep.append((reverse_voc[k], round(v,2)))
|
224 |
|
225 |
print("SPLADE BOW rep:\n", bow_rep)
|
226 |
+
|
227 |
```
|
228 |
|
229 |
## BEIR Zeroshot ODD performance:
|