josh-oo commited on
Commit
40b4d9e
·
verified ·
1 Parent(s): f33d3c4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -1
README.md CHANGED
@@ -9,6 +9,33 @@ This is an embedding model for clinical papers
9
 
10
  ## How to Use
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ```python
13
  from transformers import AutoTokenizer, AutoModel
14
  import torch
@@ -36,5 +63,5 @@ model.to(DEVICE)
36
  with torch.no_grad():
37
  output = model(**dummy_input)
38
 
39
- embeddings = output.last_hidden_state[:, 0]
40
  ```
 
9
 
10
  ## How to Use
11
 
12
+ ### Simple finetuned model
13
+
14
+ ```python
15
+ from transformers import AutoTokenizer, AutoModel
16
+ import torch
17
+
18
+ DEVICE = "cuda:0" if torch.cuda.is_available() else "cpu"
19
+
20
+ PATH = "josh-oo/aspect-based-embeddings-v3"
21
+
22
+ tokenizer = AutoTokenizer.from_pretrained(PATH)
23
+ model = AutoModel.from_pretrained(PATH)
24
+
25
+ dummy_text = "This is a title of a medical paper"
26
+ dummy_input = tokenizer([dummy_text], return_tensors="pt")
27
+
28
+ dummy_input.to(DEVICE)
29
+ model.to(DEVICE)
30
+
31
+ with torch.no_grad():
32
+ output = model(**dummy_input)
33
+
34
+ embeddings = output.last_hidden_state[:, 0] #cls pooling
35
+ ```
36
+
37
+ ### Aspect guided model
38
+
39
  ```python
40
  from transformers import AutoTokenizer, AutoModel
41
  import torch
 
63
  with torch.no_grad():
64
  output = model(**dummy_input)
65
 
66
+ embeddings = output.last_hidden_state[:, 0] #cls pooling
67
  ```