AgaMiko commited on
Commit
8c5f9f2
1 Parent(s): 8f2d5b4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +14 -0
README.md CHANGED
@@ -13,12 +13,26 @@ language:
13
  # Sentiment Classification in Polish
14
 
15
  ```
 
16
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
17
 
 
18
  tokenizer = AutoTokenizer.from_pretrained("Voicelab/herbert-base-cased-sentiment")
19
 
20
  model = AutoModelForSequenceClassification.from_pretrained("Voicelab/herbert-base-cased-sentiment")
21
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  ```
23
 
24
 
 
13
  # Sentiment Classification in Polish
14
 
15
  ```
16
+ import numpy as np
17
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
18
 
19
+ id2label = {0: "negative", 1: "neutral", 2: "positive"}
20
  tokenizer = AutoTokenizer.from_pretrained("Voicelab/herbert-base-cased-sentiment")
21
 
22
  model = AutoModelForSequenceClassification.from_pretrained("Voicelab/herbert-base-cased-sentiment")
23
 
24
+ encoding = tokenizer(
25
+ input,
26
+ add_special_tokens=True,
27
+ return_token_type_ids=True,
28
+ truncation=True,
29
+ padding='max_length',
30
+ return_attention_mask=True,
31
+ return_tensors='pt',
32
+ ).to("cuda:0")
33
+ output = model(**encoding).logits.to("cpu").detach().numpy()
34
+ prediction = id2label[np.argmax(output)]
35
+
36
  ```
37
 
38