Alexandre-Numind commited on
Commit
a6cf5eb
1 Parent(s): 88c67e6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +42 -0
README.md CHANGED
@@ -1,3 +1,45 @@
1
  ---
2
  license: mit
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language:
4
+ - en
5
+ pipeline_tag: text-classification
6
  ---
7
+ Usage:
8
+
9
+ ## Model
10
+
11
+ Base version of e5-v2 finetunned on an annotated subbset of C4 (Numind/C4_sentiment-analysis). This model provide generic embedding for sentiment analysis.
12
+
13
+ ## Usage
14
+
15
+ Below is an example to encode text and get embedding.
16
+
17
+ ```python
18
+ import torch.nn.functional as F
19
+
20
+ from torch import Tensor
21
+ from transformers import AutoTokenizer, AutoModel
22
+
23
+
24
+ model = AutoModel.from_pretrained("Numind/e5-base-SA")
25
+ tokenizer = AutoTokenizer.from_pretrained("Numind/e5-base-SA")
26
+ device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
27
+ model.to(device)
28
+
29
+ size = 256
30
+ text = "This movie is amazing"
31
+
32
+ encoding = tokenizer(
33
+ text,
34
+ truncation=True,
35
+ padding='max_length',
36
+ max_length= size,
37
+ )
38
+
39
+ emb = model(
40
+ torch.reshape(torch.tensor(encoding.input_ids),(1,len(encoding.input_ids))).to(device),output_hidden_states=True
41
+ ).hidden_states[-1].cpu().detach()
42
+
43
+ embText = torch.mean(emb,axis = 1)
44
+
45
+ ```