Instructions to use Elafnawaf/gliner-arabic-ner with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- GLiNER
How to use Elafnawaf/gliner-arabic-ner with GLiNER:
from gliner import GLiNER model = GLiNER.from_pretrained("Elafnawaf/gliner-arabic-ner") - Notebooks
- Google Colab
- Kaggle
Arabic NER โ fine-tuned GLiNER
Zero-shot-capable span NER for Arabic, fine-tuned on 17 entity types including Saudi national ID numbers and mobile numbers.
Fine-tuned from NAMAA-Space/gliner_arabic-v2.1.
Quick start
from gliner import GLiNER
model = GLiNER.from_pretrained("Elafnawaf/gliner-arabic-ner")
labels = ['ุดุฎุต / person', 'ู
ูุธู
ุฉ / organization', 'ู
ูุงู / place', 'ุนููุงู / address']
text = "ุฒุงุฑ ุงูู
ููุฏุณ ููุฏ ุงูุนุชูุจู ู
ูุฑ ุฃุฑุงู
ูู ูู ุงูุธูุฑุงู."
for e in model.predict_entities(text, labels, threshold=0.6, flat_ner=False):
print(e["label"], "->", e["text"])
The model is half the system
This repo also ships pipeline.py, which adds the regex layer, the per-label thresholds and the format validator that the published metrics were measured with.
from huggingface_hub import snapshot_download
import sys; sys.path.insert(0, snapshot_download('Elafnawaf/gliner-arabic-ner'))
from pipeline import extract
for e in extract('ุณุฌู ุงูุฏุฎูู ุจุฑูู
ุงููููุฉ 1098765432'):
print(e['source'], e['label'], e['text'])
11 of the 17 labels are answered by deterministic regexes rather than the network โ national IDs, phone numbers, percentages, money, times and similar shapes. A regex is more reliable at those than any amount of training, and it needs no data. The remaining 6 are the model's.
Labels
Model-owned (6): ุดุฎุต / person, ู ูุธู ุฉ / organization, ู ูุงู / place, ุนููุงู / address, ู ุทุงุฑ / airport, ุชุงุฑูุฎ / date
Rule-owned (11): ุชุฑุชูุจ / ordinal, ุฑูู ุงููููุฉ ุงููุทููุฉ / national id number, ุฑูู ุฌูุงู / mobile number, ุนุฏุฏ / cardinal number, ุนู ูุฉ / currency, ูู ูุฉ / quantity, ู ุจูุบ ู ุงูู / money, ู ููุน ุฅููุชุฑููู / website, ูุณุจุฉ ู ุฆููุฉ / percentage, ูุญุฏุฉ ููุงุณ / unit of measurement, ููุช / time
Labels are model input in GLiNER, so you can ask for types outside this list โ accuracy on those is not measured here.
Results
Held-out test split, span-exact match, 14,707 gold entities.
| micro-F1 | |
|---|---|
| zero-shot, before fine-tuning | 0.3859 |
| after fine-tuning | 0.7426 |
| model-owned labels only | 0.7297 |
Trained for 12069 steps.
Limitations โ read these
Modern Standard Arabic only. Every training corpus is MSA. Published work on Arabic NER reports losses of up to 38% F1 on out-of-distribution dialects, so treat Gulf, Levantine or Maghrebi input as untested.
Measured on public corpora, not on production text. The test split is drawn from the same corpora and annotation guidelines as the training data. Expect lower accuracy on text from a different domain.
Span conventions are inherited from the training corpora. Whether a title like
ุงูุฃู
ูุฑ or a head noun like ุดุฑูุฉ falls inside a span follows those corpora's
conventions, which may not match yours.
Normalize before you tokenize. Arabic diacritics are not matched by Python's
\w, so undiacritized input is required for correct spans โ pipeline.py handles
this, and does the offset mapping back to your original string. If you call the
model directly, do it yourself.
Training data
WikiANN (ar), IAHLT MAFAT Arabic NER, the public Wojood sample, plus a synthetic generator for Saudi ID and contact formats. Every ID and phone number in the training data is randomly generated; no real personal data was used.
Citation
Built on GLiNER (Zaratiana et al., 2023).
- Downloads last month
- 5
Model tree for Elafnawaf/gliner-arabic-ner
Base model
urchade/gliner_multi-v2.1