Downloads · 30 days
19
23% of all-time downloads
MahmoudMabrok/HAYAA-student-int8
HAYAA-student-int8 is a text classification model from MahmoudMabrok. Use it when you need a label for a piece of text. The card lists the license as other.
A distilled, vocabulary-pruned, int8-quantized student of youssefreda9/HAYAA, built to run inside a mobile app. 651 MB - 9.6 MB (67.8x smaller).
Downloads · 30 days
19
23% of all-time downloads
All-time downloads
82
Public
Parameters
9.4M
571 MB on disk
Likes
0
Public
Click a slice to open those files.
.onnx47.3 MB · 50%
From the Hugging Face model README
A distilled, vocabulary-pruned, int8-quantized student of youssefreda9/HAYAA,
built to run inside a mobile app.
651 MB -> 9.6 MB (67.8x smaller).
Labels: 0 = Safe, 1 = Toxic.
The numbers below measure agreement with the teacher on synthetically generated Arabic, not accuracy against human labels. The teacher's own reported F1 is 0.924, so agreement is a ceiling on quality, not a measure of it. No human-labelled gold set was used. Treat these results as evidence that the distillation pipeline works, not that the model is fit for your traffic.
Known weaknesses:
enta 3abeet) scores markedly lower than the same
insult in Arabic script. Transliterated text is under-represented upstream.argmax is not a meaningful operating point. Choose a threshold
on your own labelled data.| teacher | student | |
|---|---|---|
| params | 162.8M | 9.4M |
| layers | 12 | 4 |
| hidden size | 768 | 256 |
| vocab | 100,000 | 23970 |
| size | 651 MB fp32 | 9.6 MB int8 |
| metric | value |
|---|---|
| teacher agreement | 0.967 |
| macro-F1 vs teacher labels | 0.9347 |
| PR-AUC | 0.9554 |
[UNK] rate, out-of-distribution | 0.0 |
| runtime | MB | p50 ms | p95 ms | max abs dp | flips |
|---|---|---|---|---|---|
| torch fp32 | 38 | 19.0 | 23.6 | 0.0 | 0/300 |
| onnx fp32 | 37.7 | 13.6 | 18.4 | 0.0 | 0/300 |
| onnx int8 | 9.6 | 10.4 | 12.6 | 0.00772 | 0/300 |
Measured single-threaded, batch 1, sequence 128, on a Colab CPU. Reference for the
dp and flips columns is PyTorch fp32. Expect 1.5-3x higher latency on a
mid-range phone.
loss = 0.8 * T^2 * KL(s/T || t/T) + 0.2 * CE, with T=3.0, 6 epochsMethod follows Hinton et al. 2015 (arXiv:1503.02531) and DistilBERT (arXiv:1910.01108).
import numpy as np, onnxruntime as ort
from transformers import AutoTokenizer
tok = AutoTokenizer.from_pretrained("MahmoudMabrok/HAYAA-student-int8", subfolder="tokenizer")
sess = ort.InferenceSession("student_int8.onnx")
enc = tok("النص هنا", truncation=True, max_length=128,
padding="max_length", return_tensors="np")
names = [i.name for i in sess.get_inputs()]
feed = {k: v.astype(np.int64) for k, v in enc.items() if k in names}
logits = sess.run(None, feed)[0]
e = np.exp(logits - logits.max(-1, keepdims=True))
p_toxic = (e / e.sum(-1, keepdims=True))[0, 1]
On Android: put student_int8.onnx and tokenizer/tokenizer.json in assets, and
verify your Kotlin WordPiece implementation against tokenizer_fixtures.json
before trusting any output. A tokenizer that is 98% right produces a classifier
that demos perfectly and is broken on exactly the inputs it was built for.
student_int8.onnx — quantized, for deploymentstudent.onnx — fp32student.tflite — LiteRT build, if conversion succeededtokenizer/ — pruned tokenizer (23970 tokens)tokenizer_fixtures.json — frozen tokenizer behaviour for cross-language testsrun_report.json — every metric from this runDerived from youssefreda9/HAYAA, itself a fine-tune of UBC-NLP/MARBERTv2.
MARBERT's authors release the checkpoints for research and direct commercial
users to contact them. Fine-tuning and distillation do not reset those terms, and a
permissive tag on an intermediate model cannot grant rights its author did not hold.
For commercial use, contact UBC-NLP, or rebuild from a permissively licensed teacher
such as CAMeL-Lab/bert-base-arabic-camelbert-mix (Apache-2.0, covers MSA plus
Egyptian, Gulf and Levantine).
@inproceedings{abdul-mageed-etal-2021-arbert,
title = {ARBERT & MARBERT: Deep Bidirectional Transformers for Arabic},
author = {Abdul-Mageed, Muhammad and Elmadany, AbdelRahim and Nagoudi, El Moatez Billah},
booktitle = {Proceedings of ACL-IJCNLP 2021},
year = {2021},
pages = {7088--7105}
}