messalti commited on
Commit
225d221
·
verified ·
1 Parent(s): a5002e6

Update MagharibiBERT model card

Browse files
Files changed (1) hide show
  1. README.md +143 -23
README.md CHANGED
@@ -3,44 +3,73 @@ language:
3
  - ar
4
  library_name: transformers
5
  pipeline_tag: fill-mask
6
- base_model: UBC-NLP/MARBERT
 
7
  tags:
8
  - arabic
9
  - maghrebi-arabic
10
  - darija
11
  - arabizi
12
  - code-switching
 
 
 
 
13
  - bert
 
14
  - masked-language-modeling
15
  ---
16
 
 
 
 
17
  # MagharibiBERT
18
 
19
- **MagharibiBERT** is a regionally adapted BERT-based language model for Maghrebi Arabic.
 
 
 
 
 
 
 
 
 
20
 
21
- It is designed for North African social-media text, including dialectal Arabic, Arabizi,
22
- non-standard spelling, and Arabic-French/English code-switching.
23
 
24
- MagharibiBERT was developed by **NumidiaNLP**.
25
 
26
  ## Model architecture
27
 
28
- - Parent model: `UBC-NLP/MARBERT`
29
- - Objective: Masked Language Modeling (MLM)
30
- - Parameters: 162,942,880
31
- - Hidden size: 768
32
- - Transformer layers: 12
33
- - Attention heads: 12
34
- - Vocabulary size: 100,000
35
- - Maximum sequence length: 512
 
 
 
 
 
36
 
37
- ## Continued pretraining
38
 
39
- MagharibiBERT was obtained through additional regional continued pretraining
40
- on a curated multi-source corpus covering Maghrebi Arabic varieties.
 
41
 
 
 
 
 
 
 
 
42
  - Optimizer steps: 120,000
43
- - Training sequence length: 128
44
  - Effective batch size: 48
45
  - Learning rate: 2e-5
46
  - Warmup steps: 6,000
@@ -48,20 +77,111 @@ on a curated multi-source corpus covering Maghrebi Arabic varieties.
48
  - Precision: BF16
49
  - Random seed: 42
50
 
51
- ## Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
- Load the model with `NumidiaNLP/MagharibiBERT` using Hugging Face Transformers.
 
 
 
 
54
 
55
  ## Intended use
56
 
57
- The model is intended for research on Maghrebi Arabic NLP, including Arabizi,
58
- code-switching, sentiment analysis, hate and offensive language detection,
59
- dialect identification, and related text-processing tasks.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
  ## Citation
62
 
63
- A formal citation will be added following publication of the accompanying paper.
 
 
 
 
 
 
 
 
 
 
64
 
65
  ## Organization
66
 
67
  **NumidiaNLP — Language Intelligence for North Africa**
 
 
3
  - ar
4
  library_name: transformers
5
  pipeline_tag: fill-mask
6
+ base_model:
7
+ - UBC-NLP/MARBERT
8
  tags:
9
  - arabic
10
  - maghrebi-arabic
11
  - darija
12
  - arabizi
13
  - code-switching
14
+ - algeria
15
+ - morocco
16
+ - tunisia
17
+ - libya
18
  - bert
19
+ - pytorch
20
  - masked-language-modeling
21
  ---
22
 
23
+ <img src="https://i.imgur.com/cwgkvqe.png"
24
+ alt="MagharibiBERT" width="35%" align="right"/>
25
+
26
  # MagharibiBERT
27
 
28
+ **MagharibiBERT** is a regionally adapted Transformer language model
29
+ for **Maghrebi Arabic**.
30
+
31
+ It is initialized from `UBC-NLP/MARBERT` and further adapted using
32
+ Masked Language Modeling (MLM) on a large multi-source corpus of
33
+ Maghrebi text.
34
+
35
+ The model targets the linguistic and orthographic diversity of
36
+ North African online communication, including Arabic-script dialect,
37
+ Arabizi, spelling variation, and Arabic-French/English code-switching.
38
 
39
+ MagharibiBERT is developed by **NumidiaNLP**.
 
40
 
41
+ ---
42
 
43
  ## Model architecture
44
 
45
+ | Property | Value |
46
+ |---|---:|
47
+ | Architecture | BERT |
48
+ | Parent model | `UBC-NLP/MARBERT` |
49
+ | Objective | Masked Language Modeling |
50
+ | Parameters | 162,942,880 |
51
+ | Transformer layers | 12 |
52
+ | Hidden size | 768 |
53
+ | Attention heads | 12 |
54
+ | Vocabulary size | 100,000 |
55
+ | Maximum position embeddings | 512 |
56
+
57
+ ---
58
 
59
+ ## Regional continued pretraining
60
 
61
+ MagharibiBERT underwent additional regional continued pretraining on
62
+ a curated mixture of **17 corpora** covering Maghrebi Arabic and
63
+ North African social-media language.
64
 
65
+ The training mixture includes material associated with Algeria, Tunisia,
66
+ Morocco, Libya, and cross-regional Maghrebi sources, with explicit
67
+ coverage of Arabic script, Arabizi, and code-mixed text.
68
+
69
+ ### Training configuration
70
+
71
+ - MLM sequence length: 128
72
  - Optimizer steps: 120,000
 
73
  - Effective batch size: 48
74
  - Learning rate: 2e-5
75
  - Warmup steps: 6,000
 
77
  - Precision: BF16
78
  - Random seed: 42
79
 
80
+ ---
81
+
82
+ ## How to use
83
+
84
+ ### Fill-mask pipeline
85
+
86
+ ```python
87
+ from transformers import pipeline
88
+
89
+ pipe = pipeline(
90
+ "fill-mask",
91
+ model="NumidiaNLP/MagharibiBERT"
92
+ )
93
+
94
+ results = pipe("واش راك [MASK]", top_k=5)
95
+
96
+ for result in results:
97
+ print(result["token_str"], result["score"])
98
+ ```
99
+
100
+ ### Example output
101
+
102
+ Output produced by the released MagharibiBERT checkpoint:
103
+
104
+ ```text
105
+ {"token": "دير", "score": 0.277943}
106
+ {"token": "تهدر", "score": 0.071477}
107
+ {"token": "تدير", "score": 0.062739}
108
+ {"token": "تقول", "score": 0.047855}
109
+ {"token": "تحكي", "score": 0.038360}
110
+ ```
111
+
112
+ > Scores depend on the complete masked context. The example above is
113
+ > provided only to demonstrate model usage rather than as an evaluation result.
114
+
115
+ ### Load the model directly
116
+
117
+ ```python
118
+ from transformers import AutoTokenizer, AutoModelForMaskedLM
119
+
120
+ model_name = "NumidiaNLP/MagharibiBERT"
121
 
122
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
123
+ model = AutoModelForMaskedLM.from_pretrained(model_name)
124
+ ```
125
+
126
+ ---
127
 
128
  ## Intended use
129
 
130
+ MagharibiBERT is intended primarily for research involving Maghrebi Arabic,
131
+ including:
132
+
133
+ - hate and offensive language detection,
134
+ - sentiment analysis,
135
+ - dialect identification,
136
+ - Arabizi processing,
137
+ - code-switched text processing,
138
+ - social-media text classification,
139
+ - representation learning for Maghrebi Arabic.
140
+
141
+ ---
142
+
143
+ ## Intrinsic evaluation
144
+
145
+ On the fixed held-out MLM test set used during development, the released
146
+ checkpoint obtained:
147
+
148
+ | Metric | MagharibiBERT |
149
+ |---|---:|
150
+ | MLM loss | 2.8099 |
151
+ | Perplexity | 16.6080 |
152
+ | Masked-token accuracy | 52.42% |
153
+
154
+ Downstream evaluation against MARBERT and other Arabic language models
155
+ is being conducted separately.
156
+
157
+ ---
158
+
159
+ ## Limitations
160
+
161
+ Maghrebi Arabic is highly heterogeneous across countries, regions,
162
+ writing systems, platforms, and communities. Performance may therefore
163
+ vary across domains and linguistic varieties.
164
+
165
+ The model should not be interpreted as representing all North African
166
+ languages or all Maghrebi speakers equally.
167
+
168
+ ---
169
 
170
  ## Citation
171
 
172
+ The citation for the accompanying MagharibiBERT paper will be added
173
+ following publication.
174
+
175
+ MagharibiBERT is initialized from MARBERT. Users should also cite the
176
+ original MARBERT work:
177
+
178
+ > Abdul-Mageed, M., Elmadany, A., and Nagoudi, E. M. B. (2021).
179
+ > ARBERT & MARBERT: Deep Bidirectional Transformers for Arabic.
180
+ > ACL-IJCNLP 2021.
181
+
182
+ ---
183
 
184
  ## Organization
185
 
186
  **NumidiaNLP — Language Intelligence for North Africa**
187
+