IAMJB commited on
Commit
95c7f8b
·
verified ·
1 Parent(s): 581928c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +3 -0
README.md CHANGED
@@ -9,6 +9,7 @@ base_model:
9
  ```python
10
  import torch
11
  from transformers import AutoTokenizer, AutoModel
 
12
 
13
  # Pick one sentence
14
  sentence = "The patient has a right pneumothorax."
@@ -31,6 +32,8 @@ with torch.no_grad():
31
  outputs = model(**inputs, output_hidden_states=True)
32
  last_hidden_state = outputs.hidden_states[-1]
33
  cls_embedding = last_hidden_state[:, 0, :] # CLS token
 
 
34
 
35
  print("Sentence:", sentence)
36
  print("Embedding shape:", cls_embedding.shape)
 
9
  ```python
10
  import torch
11
  from transformers import AutoTokenizer, AutoModel
12
+ import torch.nn.functional as F
13
 
14
  # Pick one sentence
15
  sentence = "The patient has a right pneumothorax."
 
32
  outputs = model(**inputs, output_hidden_states=True)
33
  last_hidden_state = outputs.hidden_states[-1]
34
  cls_embedding = last_hidden_state[:, 0, :] # CLS token
35
+ cls_embedding = F.normalize(cls_embedding, p=2, dim=1)
36
+
37
 
38
  print("Sentence:", sentence)
39
  print("Embedding shape:", cls_embedding.shape)