Update README.md
Browse files
README.md
CHANGED
|
@@ -45,7 +45,7 @@ To create embeddings and for classification:
|
|
| 45 |
title = 'MIReAD: simple method for learning scientific representations'
|
| 46 |
abstract = 'Learning semantically meaningful representations from scientific documents can ...'
|
| 47 |
text = title + tokenizer.sep_token + abstract
|
| 48 |
-
tokens = tokenizer(
|
| 49 |
max_length=512,
|
| 50 |
padding=True,
|
| 51 |
truncation=True,
|
|
@@ -54,12 +54,12 @@ tokens = tokenizer(sents,
|
|
| 54 |
|
| 55 |
# for embeddings
|
| 56 |
with torch.no_grad():
|
| 57 |
-
|
| 58 |
-
|
| 59 |
|
| 60 |
# for classification
|
| 61 |
-
|
| 62 |
-
|
| 63 |
```
|
| 64 |
|
| 65 |
## Training procedure
|
|
|
|
| 45 |
title = 'MIReAD: simple method for learning scientific representations'
|
| 46 |
abstract = 'Learning semantically meaningful representations from scientific documents can ...'
|
| 47 |
text = title + tokenizer.sep_token + abstract
|
| 48 |
+
tokens = tokenizer(text,
|
| 49 |
max_length=512,
|
| 50 |
padding=True,
|
| 51 |
truncation=True,
|
|
|
|
| 54 |
|
| 55 |
# for embeddings
|
| 56 |
with torch.no_grad():
|
| 57 |
+
output = model.bert(**tokens)
|
| 58 |
+
embedding = output.last_hidden_state[:, 0, :]
|
| 59 |
|
| 60 |
# for classification
|
| 61 |
+
output = model(**tokens)
|
| 62 |
+
class = out.logits
|
| 63 |
```
|
| 64 |
|
| 65 |
## Training procedure
|