Downloads · 30 days
11
7% of all-time downloads
alainkh/arabic-misogyny-detection-cnn-bigru
arabic-misogyny-detection-cnn-bigru is a text classification model from alainkh. Use it when you need a label for a piece of text. It is set up for keras. The card lists the license as mit.
This repository hosts a high-performance deep learning model designed to identify misogynistic content in Arabic social media text. Developed as an academic project, the model successfully overcomes significant lingui…
Downloads · 30 days
11
7% of all-time downloads
All-time downloads
153
Public
Repo size
15.5 MB
Likes
0
Public
Click a slice to open those files.
.keras15.5 MB · 71%
From the Hugging Face model README
This repository hosts a high-performance deep learning model designed to identify misogynistic content in Arabic social media text. Developed as an academic project, the model successfully overcomes significant linguistic challenges, such as dialectal variation and high Out-of-Vocabulary (OOV) rates.
The model utilizes a Functional API structure for parallel feature extraction, combining local and sequential context:
To handle the "noise" of Arabic Twitter, a custom "Semantic Preservation" pipeline was developed (see preprocess.py):
The model was trained on a consolidated corpus of ~13,000 tweets from the following benchmarks:
Note: Raw datasets are not hosted here out of respect for the authors' distribution policies. Please contact the original researchers via their official request forms to access the data.
To use this model, ensure you apply the data_cleaning function from preprocess.py before passing text to the model.
import tensorflow as tf
from preprocess import prepare_input
# 1. Load the Hybrid CNN-BiGRU Model
# Ensure 'tokenizer.json' and 'preprocess.py' are in the same directory
model = tf.keras.models.load_model("arabic_misogyny_hybrid_model.keras")
def predict_misogyny(tweets):
"""
Cleans, tokenizes, and predicts for a list of raw Arabic strings.
"""
# Unified pipeline: Clean -> Tokenize -> Pad
# Returns a shape of (len(tweets), 48)
processed_data = [prepare_input(tweet) for tweet in tweets]
# Reshape for bulk prediction if necessary, or predict individually
for i, tweet in enumerate(tweets):
input_row = prepare_input(tweet)
prediction = model.predict(input_row, verbose=0)[0][0]
label = "MISOGYNY" if prediction > 0.5 else "NEUTRAL"
confidence = prediction if prediction > 0.5 else 1 - prediction
print(f"Tweet: {tweet}")
print(f"Result: {label} | Confidence: {confidence*100:.2f}%\n")
# --- Example Run ---
examples = [
"أنتِ رائعة حقاً", # Neutral
"أنتِ رائعة حقاً؟ 🤮", # Misogynistic (Sarcasm/Emoji)
"سوف تندمين #يا_واطية" # Misogynistic (Hashtag)
]
predict_misogyny(examples)
This project is licensed under the MIT License.