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
Safetensors
Model size
0.3B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Elafnawaf/gliner-arabic-ner

Finetuned
(1)
this model

Paper for Elafnawaf/gliner-arabic-ner