atasoglu commited on
Commit
3d82efb
1 Parent(s): be99838

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +48 -7
README.md CHANGED
@@ -8,12 +8,53 @@ language:
8
  pipeline_tag: text-classification
9
  ---
10
 
11
- # Test Results
12
 
13
- ||NOT|OFF|
14
- |:-|:-|:-|
15
- |Precision|0.92|0.75|
16
- |Recall|0.94|0.67|
17
- |F1-Score|0.93|0.71|
18
 
19
- - Accuracy: 0.89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  pipeline_tag: text-classification
9
  ---
10
 
11
+ # atasoglu/turkish-base-bert-uncased-offenseval2020_tr
12
 
13
+ This is a offensive language detection model fine-tuned with [coltekin/offenseval2020_tr](https://huggingface.co/datasets/coltekin/offenseval2020_tr) dataset on [ytu-ce-cosmos/turkish-base-bert-uncased](https://huggingface.co/ytu-ce-cosmos/turkish-base-bert-uncased).
 
 
 
 
14
 
15
+ ## Usage
16
+
17
+ Quick usage:
18
+
19
+ ```py
20
+ from transformers import pipeline
21
+ pipe = pipeline("text-classification", "atasoglu/turkish-base-bert-uncased-offenseval2020_tr")
22
+ print(pipe("bu bir test metnidir.", top_k=None))
23
+ # [{'label': 'NOT', 'score': 0.9970345497131348}, {'label': 'OFF', 'score': 0.0029654440004378557}]
24
+ ```
25
+
26
+ Or:
27
+
28
+ ```py
29
+ import torch
30
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
31
+
32
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
33
+ model_id = "atasoglu/turkish-base-bert-uncased-offenseval2020_tr"
34
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
35
+ model = AutoModelForSequenceClassification.from_pretrained(model_id).to(device)
36
+
37
+ @torch.no_grad
38
+ def predict(X):
39
+ inputs = tokenizer(X, padding="max_length", truncation=True, max_length=256, return_tensors="pt")
40
+ outputs = model.forward(**inputs.to(device))
41
+ return torch.argmax(outputs.logits, dim=-1).tolist()
42
+
43
+ print(predict(["bu bir test metnidir."]))
44
+ # [0]
45
+ ```
46
+
47
+ ## Test Results
48
+
49
+ Test results examined on the *test* split of fine-tuning dataset.
50
+
51
+ | |precision|recall|f1-score|support|
52
+ |------------:|:--------|:-----|:-------|:------|
53
+ | NOT|0.9162 |0.9559|0.9356 |2812 |
54
+ | OFF|0.7912 |0.6564|0.7176 |716 |
55
+
56
+ | | | | | |
57
+ |------------:|:--------|:-----|:-------|:------|
58
+ | accuracy| | |0.8951 |3528 |
59
+ | macro avg|0.8537 |0.8062|0.8266 |3528 |
60
+ | weighted avg|0.8908 |0.8951|0.8914 |3528 |