Update README.md
Browse files
README.md
CHANGED
|
@@ -9,7 +9,7 @@ metrics:
|
|
| 9 |
pipeline_tag: text-classification
|
| 10 |
---
|
| 11 |
|
| 12 |
-
`ArGTClass` is a bloomz based classification model, finetuned to categorize a comprehensive spectrum
|
| 13 |
of fourteen distinct subjects that are Religion,
|
| 14 |
Finance and Economics, Politics, Medical, Cul-
|
| 15 |
ture, Sports, Science and Technology, Anthro-
|
|
@@ -28,7 +28,7 @@ For more details, check out our [example.com](paper)
|
|
| 28 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 29 |
|
| 30 |
tokenizer = AutoTokenizer.from_pretrained("dru-ac/ArGTClass")
|
| 31 |
-
model = AutoModelForSequenceClassification.from_pretrained("dru-ac/ArGTClass"
|
| 32 |
|
| 33 |
text = " .قصفت إسرائيل مستشفى المعمداني في مدينة غزة، والذي خلف مئات الشهداء والجرحى"
|
| 34 |
|
|
@@ -48,7 +48,7 @@ model = AutoModelForSequenceClassification.from_pretrained("dru-ac/ArGTClass", d
|
|
| 48 |
|
| 49 |
text = " .قصفت إسرائيل مستشفى المعمداني في مدينة غزة، والذي خلف مئات الشهداء والجرحى"
|
| 50 |
|
| 51 |
-
inputs = tokenizer(text, return_tensors= 'pt')
|
| 52 |
outputs = model(**inputs)
|
| 53 |
ind = outputs.logits.argmax(dim=-1)[0]
|
| 54 |
predicted_class = model.config.id2label[ind.item()]
|
|
@@ -69,17 +69,3 @@ text = " .قصفت إسرائيل مستشفى المعمداني في مدين
|
|
| 69 |
classifier(text)
|
| 70 |
```
|
| 71 |
|
| 72 |
-
|
| 73 |
-
### Pipeline example (GPU)
|
| 74 |
-
|
| 75 |
-
```python
|
| 76 |
-
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 77 |
-
tokenizer = AutoTokenizer.from_pretrained("dru-ac/ArGTClass")
|
| 78 |
-
model = AutoModelForSequenceClassification.from_pretrained("dru-ac/ArGTClass", device_map = 'auto')
|
| 79 |
-
|
| 80 |
-
classifier = pipeline("text-classification", model=model, tokenizer= tokenizer, device="cuda:0")
|
| 81 |
-
|
| 82 |
-
text = " .قصفت إسرائيل مستشفى المعمداني في مدينة غزة، والذي خلف مئات الشهداء والجرحى"
|
| 83 |
-
|
| 84 |
-
classifier(text)
|
| 85 |
-
```
|
|
|
|
| 9 |
pipeline_tag: text-classification
|
| 10 |
---
|
| 11 |
|
| 12 |
+
`ArGTClass` is a `bloomz` based classification model, finetuned to categorize a comprehensive spectrum
|
| 13 |
of fourteen distinct subjects that are Religion,
|
| 14 |
Finance and Economics, Politics, Medical, Cul-
|
| 15 |
ture, Sports, Science and Technology, Anthro-
|
|
|
|
| 28 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 29 |
|
| 30 |
tokenizer = AutoTokenizer.from_pretrained("dru-ac/ArGTClass")
|
| 31 |
+
model = AutoModelForSequenceClassification.from_pretrained("dru-ac/ArGTClass")
|
| 32 |
|
| 33 |
text = " .قصفت إسرائيل مستشفى المعمداني في مدينة غزة، والذي خلف مئات الشهداء والجرحى"
|
| 34 |
|
|
|
|
| 48 |
|
| 49 |
text = " .قصفت إسرائيل مستشفى المعمداني في مدينة غزة، والذي خلف مئات الشهداء والجرحى"
|
| 50 |
|
| 51 |
+
inputs = tokenizer(text, return_tensors= 'pt').to("cuda")
|
| 52 |
outputs = model(**inputs)
|
| 53 |
ind = outputs.logits.argmax(dim=-1)[0]
|
| 54 |
predicted_class = model.config.id2label[ind.item()]
|
|
|
|
| 69 |
classifier(text)
|
| 70 |
```
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|