Fill-Mask
Transformers
PyTorch
Safetensors
Arabic
bert
masked-language-modeling
arabic
social-media
pilot
Instructions to use thejosango/nuha-ajp-mlm with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thejosango/nuha-ajp-mlm with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="thejosango/nuha-ajp-mlm")# Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("thejosango/nuha-ajp-mlm") model = AutoModelForMaskedLM.from_pretrained("thejosango/nuha-ajp-mlm", device_map="auto") - Notebooks
- Google Colab
- Kaggle
docs: revise model card and remove misleading base_model field
Browse filesRemove base_model: bert-base-uncased from YAML metadata since the
model was pre-trained from scratch, not fine-tuned from bert-base.
README.md
CHANGED
|
@@ -1,109 +1,84 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
-
base_model: bert-base-uncased
|
| 4 |
tags:
|
| 5 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
datasets:
|
| 7 |
-
- nuha-dataset
|
| 8 |
-
model-index:
|
| 9 |
-
- name: nuha-mlm
|
| 10 |
-
results: []
|
| 11 |
---
|
| 12 |
|
| 13 |
-
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
| 14 |
-
should probably proofread and complete it, then remove this comment. -->
|
| 15 |
-
|
| 16 |
# nuha-mlm
|
| 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 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
| 74 |
-
|
|
| 75 |
-
|
|
| 76 |
-
|
|
| 77 |
-
|
|
| 78 |
-
|
|
| 79 |
-
|
|
| 80 |
-
|
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
| 5.7924 | 16.57 | 16500 | 6.0288 |
|
| 86 |
-
| 5.7764 | 17.07 | 17000 | 6.0061 |
|
| 87 |
-
| 5.7545 | 17.57 | 17500 | 5.9600 |
|
| 88 |
-
| 5.7025 | 18.07 | 18000 | 5.9287 |
|
| 89 |
-
| 5.6703 | 18.57 | 18500 | 5.9549 |
|
| 90 |
-
| 5.6887 | 19.08 | 19000 | 5.8808 |
|
| 91 |
-
| 5.629 | 19.58 | 19500 | 5.8967 |
|
| 92 |
-
| 5.6139 | 20.08 | 20000 | 5.8629 |
|
| 93 |
-
| 5.5925 | 20.58 | 20500 | 5.8651 |
|
| 94 |
-
| 5.5506 | 21.08 | 21000 | 5.8567 |
|
| 95 |
-
| 5.5177 | 21.59 | 21500 | 5.8216 |
|
| 96 |
-
| 5.479 | 22.09 | 22000 | 5.8242 |
|
| 97 |
-
| 5.468 | 22.59 | 22500 | 5.8100 |
|
| 98 |
-
| 5.4426 | 23.09 | 23000 | 5.7828 |
|
| 99 |
-
| 5.4648 | 23.59 | 23500 | 5.7881 |
|
| 100 |
-
| 5.4199 | 24.1 | 24000 | 5.8162 |
|
| 101 |
-
| 5.3976 | 24.6 | 24500 | 5.7881 |
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
### Framework versions
|
| 105 |
-
|
| 106 |
-
- Transformers 4.32.1
|
| 107 |
-
- Pytorch 2.0.1+cu117
|
| 108 |
-
- Datasets 2.14.4
|
| 109 |
-
- Tokenizers 0.13.3
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- ar
|
| 4 |
license: apache-2.0
|
|
|
|
| 5 |
tags:
|
| 6 |
+
- bert
|
| 7 |
+
- masked-language-modeling
|
| 8 |
+
- arabic
|
| 9 |
+
- social-media
|
| 10 |
+
- fill-mask
|
| 11 |
+
- pilot
|
| 12 |
datasets:
|
| 13 |
+
- thejosango/nuha-dataset
|
|
|
|
|
|
|
|
|
|
| 14 |
---
|
| 15 |
|
|
|
|
|
|
|
|
|
|
| 16 |
# nuha-mlm
|
| 17 |
|
| 18 |
+
## Model Summary
|
| 19 |
+
|
| 20 |
+
`nuha-mlm` is an Arabic BERT model pre-trained from scratch on Jordanian social media text using masked language modelling (MLM). It serves as the domain-adapted base for the NUHA classifier family — [`nuha-binary`](https://huggingface.co/thejosango/nuha-binary) and [`nuha-multiclass`](https://huggingface.co/thejosango/nuha-multiclass) — and was developed as part of a **pilot proof-of-concept** for the NUHA project by the [Jordan Open Source Association (JOSA)](https://josa.ngo).
|
| 21 |
+
|
| 22 |
+
Starting from a fresh vocabulary trained on the NUHA corpus rather than fine-tuning an existing Arabic BERT, the model is adapted to the vocabulary and linguistic patterns of colloquial Jordanian Arabic social media text.
|
| 23 |
+
|
| 24 |
+
## Uses
|
| 25 |
+
|
| 26 |
+
### Direct Use
|
| 27 |
+
|
| 28 |
+
`nuha-mlm` can be used for masked token prediction on Arabic social media text, or as a base model for fine-tuning downstream Arabic NLP tasks — particularly those involving informal Jordanian or Levantine Arabic.
|
| 29 |
+
|
| 30 |
+
```python
|
| 31 |
+
from transformers import pipeline
|
| 32 |
+
|
| 33 |
+
fill_mask = pipeline("fill-mask", model="thejosango/nuha-mlm")
|
| 34 |
+
results = fill_mask("هذه المرأة [MASK] جداً")
|
| 35 |
+
for r in results:
|
| 36 |
+
print(r["token_str"], r["score"])
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
### Downstream Use
|
| 40 |
+
|
| 41 |
+
The primary intended downstream use is fine-tuning for hate speech and gender-based violence detection using the NUHA dataset, as demonstrated by [`nuha-binary`](https://huggingface.co/thejosango/nuha-binary) and [`nuha-multiclass`](https://huggingface.co/thejosango/nuha-multiclass).
|
| 42 |
+
|
| 43 |
+
### Out-of-Scope Use
|
| 44 |
+
|
| 45 |
+
This model was pre-trained on a relatively small, domain-specific corpus of Jordanian social media comments. It is not suitable as a general-purpose Arabic language model and should not be used as a replacement for models trained on broader Arabic corpora (e.g. for MSA tasks, translation, or summarisation).
|
| 46 |
+
|
| 47 |
+
## Bias, Risks, and Limitations
|
| 48 |
+
|
| 49 |
+
- **Corpus bias**: The pre-training corpus consists entirely of social media comments, many of which contain offensive or harmful language. The model may reflect biases present in that content.
|
| 50 |
+
- **Dialect coverage**: The corpus is primarily Jordanian Arabic. Performance on other Arabic dialects or Modern Standard Arabic is not guaranteed.
|
| 51 |
+
- **Pilot scale**: As part of an initial proof-of-concept effort, the pre-training corpus size and training duration are modest. A larger corpus and longer training would likely yield a stronger base model.
|
| 52 |
+
- **Vocabulary size**: The tokenizer vocabulary (17,513 tokens) was trained specifically on this corpus and is much smaller than general Arabic BERT vocabularies.
|
| 53 |
+
|
| 54 |
+
## Training Details
|
| 55 |
+
|
| 56 |
+
### Training Data
|
| 57 |
+
|
| 58 |
+
Pre-trained on the text portion of the [`thejosango/nuha-dataset`](https://huggingface.co/datasets/thejosango/nuha-dataset) — a corpus of Arabic social media comments collected from Jordanian platforms. The `binary` dataset split was used for pre-training (text only, labels ignored).
|
| 59 |
+
|
| 60 |
+
### Training Procedure
|
| 61 |
+
|
| 62 |
+
- **Architecture**: BERT (`BertForMaskedLM`), 12 layers, 12 attention heads, 768 hidden size
|
| 63 |
+
- **Vocabulary**: Custom BPE tokenizer trained from scratch on the corpus (17,513 tokens), with `[URL]` as an added special token
|
| 64 |
+
- **MLM probability**: 15%
|
| 65 |
+
- **Optimizer**: Adam (β₁=0.9, β₂=0.999, ε=1e-8)
|
| 66 |
+
- **Learning rate**: 1e-4 with linear schedule, 5,000 warmup steps
|
| 67 |
+
- **Batch size**: 128
|
| 68 |
+
- **Epochs**: 25
|
| 69 |
+
- **Framework**: Transformers 4.32.1, PyTorch 2.0.1
|
| 70 |
+
|
| 71 |
+
### Training Results
|
| 72 |
+
|
| 73 |
+
| Epoch | Validation Loss |
|
| 74 |
+
|---|---|
|
| 75 |
+
| 1 | 8.435 |
|
| 76 |
+
| 5 | 7.296 |
|
| 77 |
+
| 10 | 6.499 |
|
| 78 |
+
| 15 | 6.118 |
|
| 79 |
+
| 20 | 5.863 |
|
| 80 |
+
| 25 | 5.788 |
|
| 81 |
+
|
| 82 |
+
---
|
| 83 |
+
|
| 84 |
+
*This model was developed as part of an initial pilot study. It is intended as a stepping stone for the downstream NUHA classifiers rather than as a general-purpose Arabic language model.*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|