Downloads · 30 days
15
15% of all-time downloads
Rahilgh/dziribert-algerian-darija-misinformation-detection
dziribert-algerian-darija-misinformation-detection is a text classification model from Rahilgh. Use it when you need a label for a piece of text. The card lists the license as mit.
DziriBERT is a fine-tuned XLM-RoBERTa-large model for detecting misinformation in Algerian Darija text from social media and news.
Downloads · 30 days
15
15% of all-time downloads
All-time downloads
100
Public
Parameters
560M
4.5 GB on disk
Likes
0
Public
Click a slice to open those files.
.pt2.2 GB · 50%
From the Hugging Face model README
DziriBERT is a fine-tuned XLM-RoBERTa-large model for detecting misinformation in Algerian Darija text from social media and news.
xlm-roberta-large (355M parameters)Per-class F1:
Strengths
Limitations
import os
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
os.environ["USE_TF"] = "0"
os.environ["USE_TORCH"] = "1"
MODEL_ID = "Rahilgh/model4_2"
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, use_fast=False)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_ID).to(DEVICE)
model.eval()
LABEL_MAP = {0: "F", 1: "R", 2: "N", 3: "M", 4: "S"}
LABEL_NAMES = {
"F": "Fake",
"R": "Real",
"N": "Non-new",
"M": "Misleading",
"S": "Satire",
}
texts = [
"الجزائر فازت ببطولة امم افريقيا 2019",
"صورة زعيم عالمي يرتدي ملابس غريبة تثير السخرية",
]
for text in texts:
inputs = tokenizer(
text,
return_tensors="pt",
max_length=128,
truncation=True,
padding=True,
).to(DEVICE)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)
pred_id = probs.argmax().item()
confidence = probs[0][pred_id].item()
label = LABEL_MAP[pred_id]
print(f"Text: {text}")
print(f"Prediction: {LABEL_NAMES[label]} ({label}) — {confidence:.2%}")