dru-acrps commited on
Commit
a00b355
1 Parent(s): 26426a1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -1
README.md CHANGED
@@ -18,4 +18,52 @@ cation, History, Language and Linguistics, Law,
18
  as well as Philosophy in Arabic.
19
 
20
 
21
- For more details, check out our [example.com](paper)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  as well as Philosophy in Arabic.
19
 
20
 
21
+ For more details, check out our [example.com](paper)
22
+
23
+
24
+ ### Pipeline example
25
+
26
+ ```python
27
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
28
+ tokenizer = AutoTokenizer.from_pretrained("dru-acrps/ArGTClass")
29
+ model = AutoModelForSequenceClassification.from_pretrained("dru-acrps/ArGTClass", device_map = 'auto')
30
+
31
+ classifier = pipeline("text-classification", model=model, tokenizer= tokenizer)
32
+
33
+ text = " .قصفت إسرائيل مستشفى المعمداني في مدينة غزة، والذي خلف مئات الشهداء والجرحى"
34
+
35
+ classifier(text)
36
+
37
+ ```
38
+
39
+
40
+ ### Pipeline example (GPU)
41
+
42
+ ```python
43
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
44
+ tokenizer = AutoTokenizer.from_pretrained("dru-acrps/ArGTClass")
45
+ model = AutoModelForSequenceClassification.from_pretrained("dru-acrps/ArGTClass", device_map = 'auto')
46
+
47
+ classifier = pipeline("text-classification", model=model, tokenizer= tokenizer, device="cuda:0")
48
+
49
+ text = " .قصفت إسرائيل مستشفى المعمداني في مدينة غزة، والذي خلف مئات الشهداء والجرحى"
50
+
51
+ classifier(text)
52
+ ```
53
+
54
+ ### Full classification example
55
+
56
+ ```python
57
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
58
+
59
+ tokenizer = AutoTokenizer.from_pretrained("dru-acrps/ArGTClass")
60
+ model = AutoModelForSequenceClassification.from_pretrained("dru-acrps/ArGTClass", device_map = 'auto')
61
+
62
+ text = " .قصفت إسرائيل مستشفى المعمداني في مدينة غزة، والذي خلف مئات الشهداء والجرحى"
63
+
64
+ inputs = tokenizer(text, return_tensors= 'pt')
65
+ outputs = model(**inputs)
66
+ ind = outputs.logits.argmax(dim=-1)[0]
67
+ predicted_class = model.config.id2label[ind.item()]
68
+ ```
69
+