File size: 927 Bytes
87da83f
 
 
 
 
 
 
 
 
 
 
 
38db2e9
8ded9dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
license: mit
datasets:
- manueltonneau/arabic-hate-speech-superset
language:
- ar
metrics:
- f1
- accuracy
base_model:
- aubmindlab/bert-base-arabertv02
pipeline_tag: text-classification
library_name: transformers
---



model loading:
```py
import torch
from transformers import (
AutoTokenizer,
AutoModelForSequenceClassification,
)

model_name = "AyaHazem61/araBERT-For-Hate-Speech-Detection"

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(
model_name,
num_labels=2
)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
```

model predicting:
```py
texts = ["السلام عليكم و رحمة الله و بركاته"]
inputs = tokenizer(texts , return_tensors="pt", padding="max_length", truncation=True, max_length=512)

model .eval()
with torch.no_grad():
outputs = model (**inputs)

logits = outputs.logits

```