mochodek commited on
Commit
9f7b679
·
verified ·
1 Parent(s): ebe4690

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +31 -3
README.md CHANGED
@@ -1,3 +1,31 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+
5
+ ```python
6
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
7
+ from scipy.special import softmax
8
+
9
+ checkpoint = 'mochodek/bert4code-purpose'
10
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
11
+
12
+ model = AutoModelForSequenceClassification.from_pretrained(checkpoint)
13
+
14
+ id2class = {
15
+ 0: 'discussion_participation',
16
+ 1: 'discussion_trigger',
17
+ 2: 'change_request',
18
+ 3: 'acknowledgement',
19
+ 4: 'same_as'
20
+ }
21
+
22
+ text = "Please, make constant from that string"
23
+ encoded_input = tokenizer(text, return_tensors='pt')
24
+
25
+ output = model(**encoded_input)
26
+
27
+ scores = softmax(output.logits.cpu().detach().numpy())
28
+
29
+ id2class[np.argmax(scores)]
30
+
31
+ ```