RashidNLP commited on
Commit
e74ed38
·
1 Parent(s): f79b5f9

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +45 -0
README.md ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - de
4
+ ---
5
+
6
+ library_name: transformers
7
+ tags:
8
+ - Text Classification
9
+ - Pytorch
10
+ - Discourse Classification
11
+ - Roberta
12
+ ---
13
+ # Roberta for German Discourse Classification
14
+
15
+ This is a xlm Roberta model finetuned on a German Discourse dataset of 60 discourses having a total over 10k sentences.
16
+
17
+
18
+ ## How to use the model
19
+
20
+ ```python
21
+ import torch
22
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
23
+
24
+ def get_label(sentence):
25
+ vectors = tokenizer(sentence, return_tensors='pt').to(device)
26
+ outputs = bert_model(**vectors).logits
27
+ probs = torch.nn.functional.softmax(outputs, dim = 1)[0]
28
+ bert_dict = {}
29
+ keys = ['Externalization', 'Elicitation', 'Conflict', 'Acceptence', 'Integration', 'None']
30
+ for i in range(len(keys)):
31
+ bert_dict[keys[i]] = round(probs[i].item(), 3)
32
+ return bert_dict
33
+
34
+ MODEL_NAME = 'RashidNLP/Roberta-German-Discourse'
35
+ MODEL_DIR = 'model'
36
+ CHECKPOINT_DIR = 'checkpoints'
37
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
38
+ OUTPUTS = 6
39
+
40
+ bert_model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME, num_labels = OUTPUTS).to(device)
41
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
42
+
43
+ get_label("Gehst du zum Oktoberfest?")
44
+
45
+ ```