mox commited on
Commit
93c73ce
·
1 Parent(s): 1178af6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +41 -1
README.md CHANGED
@@ -3,4 +3,44 @@ This gBert-base model was finetuned on a sentiment prediction task with tweets f
3
  This model was trained on ~30.000 annotated tweets in German language on its sentiment. It can predict tweets as negative, positive or neutral. It achieved an accuracy of 93% on the specific dataset.
4
 
5
  ## Model Implementation
6
- You can implement this model for example with Simpletransformers. First you have to unpack the file.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  This model was trained on ~30.000 annotated tweets in German language on its sentiment. It can predict tweets as negative, positive or neutral. It achieved an accuracy of 93% on the specific dataset.
4
 
5
  ## Model Implementation
6
+ You can implement this model for example with Simpletransformers. First you have to unpack the file.
7
+
8
+ def unpack_model(model_name=''):
9
+ tar = tarfile.open(f"{model_name}.tar.gz", "r:gz")
10
+ tar.extractall()
11
+ tar.close()
12
+
13
+ The hyperparameter were defined as follows:
14
+ train_args ={"reprocess_input_data": True,
15
+ "fp16":False,
16
+ "num_train_epochs": 4,
17
+ "overwrite_output_dir":True,
18
+ "train_batch_size": 32,
19
+ "eval_batch_size": 32}
20
+
21
+ Now create the model:
22
+ unpack_model(YOUR_DOWNLOADED_FILE_HERE)
23
+
24
+ model = ClassificationModel(
25
+ "bert", "content/outputs/",
26
+ num_labels= 3,
27
+ args=train_args
28
+ )
29
+
30
+ In this case for the output:
31
+ - 0 = positive
32
+ - 1 = negative
33
+ - 2 = neutral
34
+
35
+ Example for a positive prediction:
36
+ model.predict(["Das ist gut! Wir danken dir."])
37
+ ([0], array([[ 2.06561327, -3.57908797, 1.5340755 ]]))
38
+
39
+ Example for a negative prediction:
40
+ model.predict(["Ich hasse dich!"])
41
+ ([1], array([[-3.50486898, 4.29590368, -0.9000684 ]]))
42
+
43
+ Example for a neutral prediction:
44
+ model.predict(["Heute ist Sonntag."])
45
+ ([2], array([[-2.94458342, -2.91875601, 4.94414234]]))
46
+