hassoudi commited on
Commit
6ce33f0
·
verified ·
1 Parent(s): f018687

Update model card (v0.1 fact-checked)

Browse files
Files changed (1) hide show
  1. README.md +74 -80
README.md CHANGED
@@ -26,31 +26,28 @@ model-index:
26
  type: token-classification
27
  name: Part-of-Speech Tagging
28
  dataset:
29
- name: Darija POS corpus (validation split, dev+test merged)
30
  type: darija-pos-corpus
31
  metrics:
32
  - type: f1
33
- value: 0.9999
34
- name: Seqeval F1 (validation)
35
- - type: accuracy
36
- value: 0.9999
37
- name: Token accuracy (validation)
38
  widget:
39
  - text: "شربت أتاي مع صحابي"
40
- example_title: "Simple sentence (verb + nouns)"
41
  - text: "غادي نمشي للسوق غدا"
42
- example_title: "Future (غادي + verb)"
43
  - text: "ما عند ي ش الفلوس"
44
  example_title: "Negation, clitic-segmented (ما … ش)"
45
  ---
46
 
47
  # DarijaPOSTagger (v0.1) — Part-of-Speech Tagging for Moroccan Darija
48
 
49
- > 🚧 **Preliminary release (v0.1) — for education & research.** This model was trained on a small corpus (1,225 sentences) and released early, with its limitations openly documented, as a teaching artifact and a baseline for the Darija NLP community. Read the [Preliminary Validation](#preliminary-validation-july-2026) and [Known Limitations](#known-limitations--bias) sections before using it. Not intended for production use.
50
 
51
- **DarijaPOSTagger** is a BERT-based token classification model that assigns **part-of-speech (POS) tags** to **Moroccan Darija** text (Moroccan Arabic dialect, Arabic script). It is fine-tuned from [SI2M-Lab/DarijaBERT](https://huggingface.co/SI2M-Lab/DarijaBERT) on a manually POS-annotated Darija corpus, using a 15-tag tagset adapted to Darija morphology including dialect-specific particles such as the progressive **كي** (`PROG_PART`), the future marker **غادي** (`FUT_PART`), and the discontinuous negation **ما ش** (`NEG_PART`).
52
 
53
- The model is released by [Typica.ai](https://typica.ai) as part of its applied research on **culturally localized AI for underserved languages**, and is **open-sourced for educational and research purposes**. It complements Typica.ai's Darija NLP suite (NER, sentiment, toxicity detection).
54
 
55
  ## Model Details
56
 
@@ -63,39 +60,44 @@ The model is released by [Typica.ai](https://typica.ai) as part of its applied r
63
  | **License** | CC BY-NC 4.0 (non-commercial — education & research) |
64
  | **Version** | v0.1 (preliminary) |
65
  | **Released** | July 2026 |
66
- | **Contact** | assoudi@typica.ai |
67
 
68
  ### Tagset (15 tags)
69
 
70
- | Tag | Meaning | Example (Darija) |
71
- |-----|---------|------------------|
72
- | `NOUN` | Noun | الولد، السوق، الفلوس |
73
- | `V` | Verb | مشيت، كيلعب، نمشي |
74
- | `ADJ` | Adjective | زوين، كبير |
75
- | `ADV` | Adverb | غدا، بزاف، دابا |
76
- | `PRON` | Pronoun | هو، ديالي، ها |
77
- | `DET` | Determiner | ال، هاد، واحد |
78
- | `PREP` | Preposition | ف، ل، على، من |
79
- | `CONJ` | Conjunction | و، ولكن، حيت |
80
- | `PART` | Particle (general) | را، واش |
81
- | `PROG_PART` | Progressive/aspectual particle | كي، تا (كيلعب) |
82
- | `FUT_PART` | Future particle | غادي، غا (غادي نمشي) |
83
- | `NEG_PART` | Negation particle | ما، ش (ما عندي ش) |
84
- | `NSUFF` | Noun suffix (inflection) | ة، ات، ين |
85
- | `CASE` | Case marker | |
86
- | `O` | Other (punctuation, numbers, URLs, mentions, emoticons, foreign tokens) | |
 
 
 
 
87
 
88
  ## Intended Uses
89
 
90
  **Direct intended uses:**
91
  - Research on morphosyntactic analysis of Moroccan Darija and Arabic dialects.
92
  - Education: teaching token classification, subword/label alignment, and fine-tuning for low-resource languages.
93
- - Preprocessing component in Darija NLP pipelines (e.g., feature extraction, chunking, linguistic annotation, corpus building).
94
 
95
  **Out-of-scope uses:**
96
  - ❌ Commercial deployment without a separate agreement with Typica.ai (license is non-commercial).
97
- - ❌ Latin-script Darija (Arabizi), French, or English text: non-Arabic tokens were cleaned from training data.
98
- - ❌ Modern Standard Arabic or other Arabic dialects — the tagset and training data are Darija-specific.
 
99
 
100
  ## How to Use
101
 
@@ -110,9 +112,9 @@ pos_tagger = pipeline(
110
  )
111
 
112
  sentences = [
113
- "غادي نمشي للسوق غدا", # I will go to the market tomorrow
114
- "شربت أتاي مع صحابي", # I drank tea with my friends
115
- "ما عنديش الفلوس", # I don't have money
116
  ]
117
 
118
  for sentence in sentences:
@@ -121,16 +123,20 @@ for sentence in sentences:
121
  print(f" {token['word']:<15} → {token['entity_group']:<10} ({token['score']:.3f})")
122
  ```
123
 
124
- > ℹ️ **Input format matters.** The training corpus is *morpheme-segmented* (clitics like ال، ف، كي، ش appear as separate tokens), while raw Darija text fuses them into surface words (فالزنقة، عنديش). The model is noticeably more reliable on clitic-segmented input; on raw text, expect degraded accuracy on fused forms (see Preliminary Validation below). Also note that `aggregation_strategy` may merge adjacent same-label words into one span — for strict one-tag-per-word output, tokenize with `is_split_into_words=True` and read per-word predictions directly.
125
 
126
  ## Training Data
127
 
128
- The model was trained on a manually POS-annotated Moroccan Darija corpus in CoNLL-style format (one `token tag` pair per line, sentences separated by `EOS` markers).
129
 
130
- **Preprocessing:**
 
 
131
  - Tokens were cleaned with a character filter keeping Arabic script, digits, and basic punctuation.
132
- - The original 22-tag scheme was simplified to 15 tags: formatting and non-linguistic tags (`WB`, `TB`, `EMOT`, `HASH`, `FOREIGN`, `MENTION`, `PUNC`, `URL`, `NUM`) were collapsed into a single `O` class, keeping the tagset focused on linguistically meaningful categories.
133
- - Subword/label alignment: only the first subword of each word receives the word's label during tokenization (WordPiece), with special tokens masked at `-100`.
 
 
134
 
135
  ### Splits
136
 
@@ -139,13 +145,14 @@ The model was trained on a manually POS-annotated Moroccan Darija corpus in CoNL
139
  | Train | 1,225 | Fine-tuning |
140
  | Dev | 175 | — |
141
  | Test | 350 | — |
142
- | Validation (dev + test merged) | 525 | Evaluation during training |
143
 
144
  ## Training Procedure
145
 
146
  - **Base checkpoint:** `SI2M-Lab/DarijaBERT` with a freshly initialized token classification head (15 labels)
147
- - **Objective:** token-level cross-entropy (seqeval-based evaluation)
148
  - **Hardware:** single T4 GPU (Google Colab)
 
149
 
150
  **Hyperparameters:**
151
 
@@ -161,22 +168,15 @@ The model was trained on a manually POS-annotated Moroccan Darija corpus in CoNL
161
 
162
  ### Quantitative (in-corpus)
163
 
164
- On the validation split (525 sentences, dev + test merged), the model converges to near-perfect seqeval scores:
165
-
166
- | Metric | Score |
167
- |---|---:|
168
- | Precision | ≈ 0.9999 |
169
- | Recall | ≈ 0.9999 |
170
- | F1 | ≈ 0.9999 |
171
- | Token accuracy | ≈ 0.9999 |
172
 
173
- > ⚠️ **Interpret with care.** The validation set is small, merges the original dev and test splits, and was used for checkpoint selection during training — it is not a clean held-out test set. Near-perfect scores reflect in-corpus fit on a small, homogeneous, morpheme-segmented corpus not expected real-world accuracy. The qualitative validation below gives a more realistic picture.
174
 
175
  ### Preliminary Validation (July 2026)
176
 
177
- Manual spot-checks on **raw (unsegmented) everyday Darija sentences** — a harder condition than the segmented training data — showed a consistent pattern:
178
 
179
- **What works well** — open-class words in canonical surface forms are tagged reliably, typically at ≥ 0.99 confidence:
180
 
181
  | Word | Predicted | Confidence |
182
  |---|---|---:|
@@ -187,27 +187,32 @@ Manual spot-checks on **raw (unsegmented) everyday Darija sentences** — a hard
187
  | الفلوس | NOUN | 0.998 |
188
  | للسوق | NOUN | 0.999 |
189
 
190
- **Known error patterns on raw text:**
191
 
192
- | Input | Predicted | Expected | Likely cause |
193
- |---|---|---|---|
194
- | الولد | O (0.512) | DET+NOUN | Fused article ال unseen as one token |
195
- | عنديش | ADV (0.582) | PREP+PRON+NEG_PART | Fused clitics (عند+ي+ش) unseen as one token |
196
- | فالزنقة | (merged into NOUN span) | PREP+DET+NOUN | Fused preposition ف lost |
197
- | غادي | PART (0.988) | FUT_PART | Closed-class near-miss |
198
- | مع | CONJ (0.996) | PREP | Closed-class confusion, confidently wrong |
199
 
200
- **Root cause:** a train/inference input mismatch. The corpus is morpheme-segmented (clitics as separate tokens hence the `NSUFF` tag and clitic-level `NEG_PART`), so fused surface words are out-of-distribution at inference. Low confidence (≈ 0.5) on fused forms is a useful signal of this. Note also that closed-class errors (مع → CONJ) can be high-confidence, so confidence alone is not a reliability guarantee.
 
 
 
 
 
201
 
202
- **Planned for v0.2:** an independent held-out evaluation on raw text, and either a paired rule-based clitic segmenter or retraining on de-segmented surface-word data.
 
 
203
 
204
  ## Known Limitations & Bias
205
 
206
- - **Preliminary release:** v0.1 is an educational baseline, not a production tagger. Error patterns above are documented, not yet fixed.
207
- - **Segmentation mismatch:** best results require clitic-segmented input; raw text degrades accuracy on fused forms (fused articles, prepositions, and negation clitics).
 
208
  - **Small training corpus:** 1,225 training sentences; limited coverage of rare constructions, regional sub-dialects, and domain vocabulary.
209
- - **In-corpus evaluation:** the quantitative metrics overestimate real-world performance (see Evaluation).
210
- - **Closed-class confusions:** some function words (e.g., مع، غادي) can be tagged incorrectly with high confidence.
211
  - **Script coverage:** Arabic script only; Arabizi/Latin-script Darija is out of scope.
212
  - **Tag granularity:** numbers, punctuation, URLs, mentions, and foreign words are collapsed into `O`.
213
 
@@ -227,22 +232,11 @@ No dedicated paper accompanies this model yet. If you use it, please cite the mo
227
  }
228
  ```
229
 
230
- Please also cite the base model:
231
-
232
- ```bibtex
233
- @article{gaanoun2023darijabert,
234
- title = {DarijaBERT: a step forward in NLP for the written Moroccan dialect},
235
- author = {Gaanoun, Kamel and Naira, Abdou Mohamed and Allak, Anass and Benelallam, Imade},
236
- journal = {International Journal of Data Science and Analytics},
237
- year = {2023},
238
- doi = {10.1007/s41060-023-00498-2}
239
- }
240
- ```
241
 
242
  ## Related Models by Typica.ai
243
 
244
- - [MAGBERT-NER](https://huggingface.co/TypicaAI/magbert-ner) Named Entity Recognition for Moroccan Darija/French
245
- - Darija Toxicity Detection — culturally grounded content moderation (see [arXiv:2505.04640](https://arxiv.org/abs/2505.04640))
246
 
247
  ## Contact
248
 
 
26
  type: token-classification
27
  name: Part-of-Speech Tagging
28
  dataset:
29
+ name: Darija POS corpus (validation split, dev+test merged, in-corpus)
30
  type: darija-pos-corpus
31
  metrics:
32
  - type: f1
33
+ value: 1.0
34
+ name: Seqeval F1 (in-corpus validation — see caveats)
 
 
 
35
  widget:
36
  - text: "شربت أتاي مع صحابي"
37
+ example_title: "Simple sentence"
38
  - text: "غادي نمشي للسوق غدا"
39
+ example_title: "Future construction"
40
  - text: "ما عند ي ش الفلوس"
41
  example_title: "Negation, clitic-segmented (ما … ش)"
42
  ---
43
 
44
  # DarijaPOSTagger (v0.1) — Part-of-Speech Tagging for Moroccan Darija
45
 
46
+ > 🚧 **Preliminary release (v0.1) — for education & research.** This model was trained on a small corpus (1,225 sentences) and is released early, with its limitations openly documented, as a teaching artifact and a baseline for the Darija NLP community. Read the [Preliminary Validation](#preliminary-validation-july-2026) and [Known Limitations](#known-limitations--bias) sections before using it. Not intended for production use.
47
 
48
+ **DarijaPOSTagger** is a BERT-based token classification model that assigns **part-of-speech (POS) tags** to **Moroccan Darija** text (Moroccan Arabic dialect, Arabic script). It is fine-tuned from [SI2M-Lab/DarijaBERT](https://huggingface.co/SI2M-Lab/DarijaBERT) on a POS-annotated Darija corpus using a 15-tag scheme that includes Darija-relevant particle categories (`PROG_PART`, `FUT_PART`, `NEG_PART`) alongside standard classes. Notably, the corpus is **morpheme-segmented**: clitics such as the article **ال** and the negation **ش** are annotated as separate tokens (e.g., ما `NEG_PART` + عند `ADV` + هوم `PRON` + ش `NEG_PART`).
49
 
50
+ The model is released by [Typica.ai](https://typica.ai) as part of its applied research on **culturally localized AI for underserved languages**, and is **open-sourced for educational and research purposes**.
51
 
52
  ## Model Details
53
 
 
60
  | **License** | CC BY-NC 4.0 (non-commercial — education & research) |
61
  | **Version** | v0.1 (preliminary) |
62
  | **Released** | July 2026 |
63
+ | **Contact** | assoudi@typica.ai <!-- TODO: verify preferred contact email --> |
64
 
65
  ### Tagset (15 tags)
66
 
67
+ Corpus-attested examples are shown where available; the annotation scheme of the source corpus is authoritative.
68
+
69
+ | Tag | Category | Corpus-attested examples |
70
+ |-----|----------|--------------------------|
71
+ | `NOUN` | Noun | مغربي، ديبلوم |
72
+ | `V` | Verb | خدام |
73
+ | `ADJ` | Adjective | |
74
+ | `ADV` | Adverb | عند |
75
+ | `PRON` | Pronoun | لي، هوم |
76
+ | `DET` | Determiner | ال |
77
+ | `PREP` | Preposition | ديال |
78
+ | `CONJ` | Conjunction | |
79
+ | `PART` | Particle | |
80
+ | `PROG_PART` | Progressive particle | |
81
+ | `FUT_PART` | Future particle | |
82
+ | `NEG_PART` | Negation particle | ما، ش |
83
+ | `NSUFF` | Noun suffix | ات |
84
+ | `CASE` | (per corpus scheme) | — |
85
+ | `O` | Other (punctuation, numbers, URLs, mentions, emoticons, foreign tokens — collapsed) | 0.7 |
86
+
87
+ > Note: some conventions may differ from other Arabic tagsets — for instance, this corpus annotates عند as `ADV`. Consult the source corpus's annotation guidelines for authoritative definitions.
88
 
89
  ## Intended Uses
90
 
91
  **Direct intended uses:**
92
  - Research on morphosyntactic analysis of Moroccan Darija and Arabic dialects.
93
  - Education: teaching token classification, subword/label alignment, and fine-tuning for low-resource languages.
94
+ - Baseline / preprocessing component in experimental Darija NLP pipelines.
95
 
96
  **Out-of-scope uses:**
97
  - ❌ Commercial deployment without a separate agreement with Typica.ai (license is non-commercial).
98
+ - ❌ Latin-script Darija (Arabizi), French, or English text: non-Arabic characters were cleaned from training data.
99
+ - ❌ Modern Standard Arabic or other Arabic dialects — the training data is Darija-specific.
100
+ - ❌ Production use: this is a preliminary v0.1 release.
101
 
102
  ## How to Use
103
 
 
112
  )
113
 
114
  sentences = [
115
+ "غادي نمشي للسوق غدا", # I will go to the market tomorrow
116
+ "شربت أتاي مع صحابي", # I drank tea with my friends
117
+ "ما عند ي ش الفلوس", # I don't have money (clitic-segmented, matching the training format)
118
  ]
119
 
120
  for sentence in sentences:
 
123
  print(f" {token['word']:<15} → {token['entity_group']:<10} ({token['score']:.3f})")
124
  ```
125
 
126
+ > ℹ️ **Input format matters.** The training corpus is morpheme-segmented (clitics like ال and ش appear as separate tokens), while raw Darija text fuses them into surface words (e.g., عنديش، فالزنقة). Fused surface forms are out-of-distribution for this model; expect lower confidence and less reliable tags on them (see Preliminary Validation). Also note that `aggregation_strategy` may merge adjacent same-label words into one span — for strict one-tag-per-word output, tokenize with `is_split_into_words=True` and read per-word predictions directly.
127
 
128
  ## Training Data
129
 
130
+ The model was trained on a POS-annotated Moroccan Darija corpus in CoNLL-style format (one `token tag` pair per line, sentences separated by `EOS` markers), read from local files.
131
 
132
+ <!-- TODO: add source corpus name, provenance, and citation -->
133
+
134
+ **Preprocessing (as implemented in the training notebook):**
135
  - Tokens were cleaned with a character filter keeping Arabic script, digits, and basic punctuation.
136
+ - The original tag scheme was simplified to 15 tags: formatting and non-linguistic tags (`WB`, `TB`, `EMOT`, `HASH`, `FOREIGN`, `MENTION`, `PUNC`, `URL`, `NUM`) were mapped to a single `O` class (any tag not in the final tagset defaults to `O`).
137
+ - Subword/label alignment: each word's label is propagated to **all** of its WordPiece subwords; special tokens are masked at `-100`.
138
+
139
+ > ⚠️ **Known v0.1 training artifact:** the label-alignment code inherits a `B-` → `I-` conversion step from NER-style code (`if label % 2 == 1: label += 1`), which is not meaningful for POS tags. For words split into multiple subwords, this shifts odd-id labels on continuation subwords to the next label id (e.g., `DET` → `FUT_PART`, `PRON` → `V`) during training. The impact has not been quantified; it is scheduled to be removed in v0.2.
140
 
141
  ### Splits
142
 
 
145
  | Train | 1,225 | Fine-tuning |
146
  | Dev | 175 | — |
147
  | Test | 350 | — |
148
+ | Validation (dev + test merged) | 525 | Per-epoch evaluation (monitoring) |
149
 
150
  ## Training Procedure
151
 
152
  - **Base checkpoint:** `SI2M-Lab/DarijaBERT` with a freshly initialized token classification head (15 labels)
153
+ - **Objective:** token-level cross-entropy; seqeval-based evaluation during training
154
  - **Hardware:** single T4 GPU (Google Colab)
155
+ - **Checkpoint released:** final model after 10 epochs (no best-checkpoint selection was configured)
156
 
157
  **Hyperparameters:**
158
 
 
168
 
169
  ### Quantitative (in-corpus)
170
 
171
+ On the validation split (525 sentences, dev + test merged), training-log seqeval metrics reach **1.00** (precision, recall, F1, and token accuracy) from epoch 6 onward, including the final epoch 10 checkpoint that is released here.
 
 
 
 
 
 
 
172
 
173
+ > ⚠️ **Interpret with care.** The validation set is small, merges the original dev and test splits, and comes from the same corpus as the training data — it is not an independent held-out test set. A perfect in-corpus score on a small, homogeneous, morpheme-segmented corpus does not translate to real-world accuracy on raw Darija text. The qualitative validation below gives a more realistic picture.
174
 
175
  ### Preliminary Validation (July 2026)
176
 
177
+ Manual spot-checks on **raw (unsegmented) everyday Darija sentences** — a harder condition than the segmented training format — showed the following:
178
 
179
+ **Reliable on canonical surface forms** — open-class words are tagged consistently, typically at ≥ 0.99 confidence:
180
 
181
  | Word | Predicted | Confidence |
182
  |---|---|---:|
 
187
  | الفلوس | NOUN | 0.998 |
188
  | للسوق | NOUN | 0.999 |
189
 
190
+ **Degraded on fused clitic forms** (out-of-distribution relative to the segmented training data):
191
 
192
+ | Input (raw, fused) | Predicted | Observation |
193
+ |---|---|---|
194
+ | الولد | O (0.512) | Near coin-flip confidence; fused article form unseen as a single token |
195
+ | عنديش | ADV (0.582) | Low confidence on the fused form. Note: the corpus tags عند as `ADV`, so the predicted class follows the corpus convention |
196
+ | فالزنقة | merged into a NOUN span | The fused preposition ف is not separately tagged (also affected by pipeline span aggregation) |
 
 
197
 
198
+ **Closed-class predictions to verify against corpus conventions**these are confident predictions whose correctness depends on the source corpus's annotation guidelines, which have not yet been checked for these words:
199
+
200
+ | Word | Predicted | Confidence |
201
+ |---|---|---:|
202
+ | غادي | PART | 0.988 |
203
+ | مع | CONJ | 0.996 |
204
 
205
+ **Practical takeaways:** low confidence (≈ 0.5–0.6) is a useful signal that an input form is out-of-distribution (typically fused clitics); clitic-segmented input matching the training format is more reliable; and confident predictions on function words should be interpreted relative to the corpus's own annotation scheme rather than assumed tagging conventions from other resources.
206
+
207
+ **Planned for v0.2:** removal of the label-alignment artifact, an independent held-out evaluation on raw text, verification of closed-class conventions against the source annotation guidelines, and either a paired clitic segmenter or retraining on de-segmented surface-word data.
208
 
209
  ## Known Limitations & Bias
210
 
211
+ - **Preliminary release:** v0.1 is an educational baseline, not a production tagger. Observations above are documented, not yet fixed.
212
+ - **Segmentation mismatch:** the training data is morpheme-segmented; raw text with fused clitics is out-of-distribution and degrades reliability.
213
+ - **Training artifact:** the subword label-alignment shift described in Training Data affects multi-subword words with odd label ids; impact unquantified.
214
  - **Small training corpus:** 1,225 training sentences; limited coverage of rare constructions, regional sub-dialects, and domain vocabulary.
215
+ - **In-corpus evaluation only:** no independent held-out test yet; the quantitative metrics overestimate real-world performance.
 
216
  - **Script coverage:** Arabic script only; Arabizi/Latin-script Darija is out of scope.
217
  - **Tag granularity:** numbers, punctuation, URLs, mentions, and foreign words are collapsed into `O`.
218
 
 
232
  }
233
  ```
234
 
235
+ Please also cite the base model, [SI2M-Lab/DarijaBERT](https://huggingface.co/SI2M-Lab/DarijaBERT) — see its model card for the authors' preferred citation.
 
 
 
 
 
 
 
 
 
 
236
 
237
  ## Related Models by Typica.ai
238
 
239
+ See the [TypicaAI organization page](https://huggingface.co/TypicaAI) for the full Darija NLP suite, including MAGBERT-NER (named entity recognition) and the Darija toxicity detection model ([arXiv:2505.04640](https://arxiv.org/abs/2505.04640)).
 
240
 
241
  ## Contact
242