GLiNER2 Arabic ยท Saudi โ€” entities, classification, structured records, relations

One encoder, four heads, tuned for Saudi and Gulf Arabic. This is a GLiNER2 checkpoint (boundary architecture, 287M parameters, mDeBERTa-v3 encoder) built on fastino/gliner2.5-multi-v1. The base model's extraction heads were trained on English and other European languages; the encoder had seen Arabic, the heads had not. This checkpoint trains all four heads on Arabic supervision โ€” standard Arabic news and Wikipedia, real Saudi SMS, real Gulf tweets, Saudi official documents and dialect sentences โ€” so that a single model can, from one forward pass and with no task-specific code:

head what you ask what you get
entities a list of entity types every span of each type
classification one or more tasks, each with its label set one label per task (single-label) or several (multi-label)
structured extraction a record schema (field names) a JSON record whose values are substrings of the text
relations a list of relation types (head, tail) pairs for each type

The schema is part of the input. GLiNER2 reads the task names and label names as text, so the model has to have seen Arabic schemas to answer them. Training examples carried an Arabic schema (ุงู„ู…ุดุงุนุฑ โ†’ ุฅูŠุฌุงุจูŠ / ุณู„ุจูŠ / ู…ุญุงูŠุฏ) or the English equivalent, with the same gold answer, so the finished model answers either language. Everything is zero-shot in principle โ€” you can ask for types it never saw โ€” but the tables below list what it was actually tuned on.

Architecture note. The boundary architecture pairs start and end positions directly, so any span length that fits the encoded window is reachable โ€” unlike the span architecture, which is capped at max_width: 8 tokens. Record metadata (occurrence_policy, field cardinality, anchored records) is live here.

Measured, not assumed. Every number on this card comes from held-out data with identical decoding for the base and this checkpoint; the base model's behaviour on English, other languages, unseen labels and descriptions is re-measured before every release (25 of 33 extraction sets significantly better than the base, 0 worse).

Quick start

pip install "gliner2[local]"
from gliner2.auto import AutoExtractor

# AutoExtractor reads the architecture field in config.json and picks the right
# class. Plain GLiNER2.from_pretrained is span-only and refuses this checkpoint.
model = AutoExtractor.from_pretrained("Elafnawaf/gliner2-arabic-saudi")

Normalise first โ€” this is not optional

GLiNER's word splitter is \w+(?:[-_]\w+)*|\S, and Python's \w does not match Arabic diacritics. A diacritised word shatters into one token per character and every span offset after it is meaningless. Tatweel (ู€) fails the other way: it does match \w, so it survives glued to a real word. Strip both before inference:

import re, unicodedata

_DIACRITICS = re.compile(r"[\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06ED]")
_INVISIBLE  = re.compile(r"[\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]")

def normalise(text: str) -> str:
    text = unicodedata.normalize("NFC", text)
    text = _DIACRITICS.sub("", text)       # ุญุฑูƒุงุช
    text = text.replace("\u0640", "")      # tatweel ู€
    text = _INVISIBLE.sub("", text)        # ZWJ / RLM / BOM ...
    return text

1 ยท Entities

text = normalise("ุฃุนู„ู†ุช ุดุฑูƒุฉ ุฃุฑุงู…ูƒูˆ ุงู„ุณุนูˆุฏูŠุฉ ููŠ ุงู„ุธู‡ุฑุงู† ูŠูˆู… 5 ู…ุงุฑุณ 2024 ุนู† ุฃุฑุจุงุญ ุจู„ุบุช "
                 "121 ู…ู„ูŠุงุฑ ุฏูˆู„ุงุฑุŒ ูˆูŠู…ูƒู† ุงู„ุชูˆุงุตู„ ุนุจุฑ ุงู„ุฑู‚ู… 0501234567.")

model.extract_entities(text, ["ู…ู†ุธู…ุฉ / organization", "ู…ูƒุงู† / place", "ู…ุจู„ุบ ู…ุงู„ูŠ / money",
                              "ุชุงุฑูŠุฎ / date", "ุฑู‚ู… ุฌูˆุงู„ / mobile number"])
# {'entities': {'ู…ู†ุธู…ุฉ / organization': ['ุดุฑูƒุฉ ุฃุฑุงู…ูƒูˆ ุงู„ุณุนูˆุฏูŠุฉ'],
#               'ู…ูƒุงู† / place': ['ุงู„ุธู‡ุฑุงู†'],
#               'ู…ุจู„ุบ ู…ุงู„ูŠ / money': ['121 ู…ู„ูŠุงุฑ ุฏูˆู„ุงุฑ'],
#               'ุชุงุฑูŠุฎ / date': ['5 ู…ุงุฑุณ 2024'],
#               'ุฑู‚ู… ุฌูˆุงู„ / mobile number': ['0501234567']}}

# character offsets and confidence, e.g. for redaction
model.extract_entities(text, ["ู…ู†ุธู…ุฉ / organization"], include_spans=True, include_confidence=True)
# {'entities': {'ู…ู†ุธู…ุฉ / organization': [{'text': 'ุดุฑูƒุฉ ุฃุฑุงู…ูƒูˆ ุงู„ุณุนูˆุฏูŠุฉ',
#                                         'confidence': 0.955,
#                                         'start': 6,
#                                         'end': 26}]}}

Saudi dialect, with the attached prefixes (ยซูˆยป, ยซุจู€ยป, ยซู„ู€ยป) that make one word of a preposition and a name โ€” a mention is always whole words, so the prefix is part of it:

saudi = normalise("ูƒู„ู…ุช ุฃุจูˆ ูู‡ุฏ ุฃู…ุณ ูˆู‚ุงู„ ุฅู†ู‡ ุญูˆู„ ู„ูŠ ุฎู…ุณู…ูŠุฉ ุฑูŠุงู„ ุนู„ู‰ ุญุณุงุจ ุงู„ุฑุงุฌุญูŠุŒ "
                  "ูˆุจูƒุฑุฉ ุจู†ุชู‚ุงุจู„ ุนู†ุฏ ู…ู‚ู‡ู‰ ุฑูƒู† ุงู„ู‡ูŠู„ ุจุญูŠ ุงู„ู…ู„ู‚ุง ุจุนุฏ ุงู„ู…ุบุฑุจ.")
model.extract_entities(saudi, ["ุดุฎุต / person", "ู…ู†ุธู…ุฉ / organization", "ู…ูƒุงู† / place",
                               "ู…ุจู„ุบ ู…ุงู„ูŠ / money", "ุชุงุฑูŠุฎ / date", "ูˆู‚ุช / time"])
# {'entities': {'ุดุฎุต / person': ['ุฃุจูˆ ูู‡ุฏ'],
#               'ู…ู†ุธู…ุฉ / organization': ['ู…ู‚ู‡ู‰ ุฑูƒู† ุงู„ู‡ูŠู„', 'ุงู„ุฑุงุฌุญูŠ'],
#               'ู…ูƒุงู† / place': ['ุจุญูŠ ุงู„ู…ู„ู‚ุง'],
#               'ู…ุจู„ุบ ู…ุงู„ูŠ / money': ['ุฎู…ุณู…ูŠุฉ ุฑูŠุงู„'],
#               'ุชุงุฑูŠุฎ / date': ['ูˆุจูƒุฑุฉ', 'ุฃู…ุณ'],
#               'ูˆู‚ุช / time': ['ุจุนุฏ ุงู„ู…ุบุฑุจ']}}

The entity head was trained with bilingual label names of the form ุนุฑุจูŠ / english (full list below). Use those exact strings for the best precision; plain ู…ู†ุธู…ุฉ or organization also work, and so do the short English names an investigation product sends:

doc = normalise("ุจู†ุงุกู‹ ุนู„ู‰ ุฎุทุงุจ ุงู„ู†ูŠุงุจุฉ ุงู„ุนุงู…ุฉ ุฑู‚ู… 4410233 ูˆุชุงุฑูŠุฎ 12/03/1446ู‡ู€ุŒ ูŠูุณุชุฏุนู‰ ุงู„ู…ุฏุนูˆ ุณู„ุทุงู† ุจู† ู†ุงุตุฑ ุงู„ุนุชูŠุจูŠุŒ "
                "ู‡ูˆูŠุฉ ุฑู‚ู… 1087654321ุŒ ู„ู„ุญุถูˆุฑ ุฅู„ู‰ ูุฑุน ุงู„ุฑูŠุงุถ. ุงู„ุญุณุงุจ ุงู„ุจู†ูƒูŠ SA4420000001234567891234 ู„ุฏู‰ ู…ุตุฑู ุงู„ุฅู†ู…ุงุกุŒ ุฌูˆุงู„ 0551122334.")
model.extract_entities(doc, ["person", "organization", "national_id", "bank_account", "phone", "location"])
# {'entities': {'person': ['ุณู„ุทุงู† ุจู† ู†ุงุตุฑ ุงู„ุนุชูŠุจูŠ'],
#               'organization': ['ู…ุตุฑู ุงู„ุฅู†ู…ุงุก'],
#               'national_id': ['1087654321'],
#               'bank_account': ['SA4420000001234567891234'],
#               'phone': ['0551122334'],
#               'location': ['ุงู„ุฑูŠุงุถ']}}

2 ยท Classification

review = normalise("ุงู„ุฎุฏู…ุฉ ูƒุงู†ุช ู…ู…ุชุงุฒุฉ ูˆุงู„ุชูˆุตูŠู„ ูˆุตู„ ู‚ุจู„ ุงู„ู…ูˆุนุฏุŒ ุดูƒุฑุงู‹ ู„ูƒู…")

model.classify_text(review, {
    "ุงู„ู…ุดุงุนุฑ":    ["ุฅูŠุฌุงุจูŠ", "ุณู„ุจูŠ", "ู…ุญุงูŠุฏ"],
    "ู†ูˆุน ุงู„ุฎุทุงุจ": ["ุณุคุงู„", "ุทู„ุจ", "ุชูˆุตูŠุฉ", "ุชุนุจูŠุฑ", "ุชุฃูƒูŠุฏ", "ุฃุฎุฑู‰"],
})
# {'ุงู„ู…ุดุงุนุฑ': 'ุฅูŠุฌุงุจูŠ', 'ู†ูˆุน ุงู„ุฎุทุงุจ': 'ุชุนุจูŠุฑ'}

# the same task, asked in English, with confidence
model.classify_text(review, {"sentiment": ["positive", "negative", "neutral"]}, include_confidence=True)
# {'sentiment': {'label': 'positive', 'confidence': 0.999}}

DIALECTS = ["ุฎู„ูŠุฌูŠ", "ู…ุตุฑูŠ", "ุดุงู…ูŠ", "ู…ุบุงุฑุจูŠ", "ูุตุญู‰"]
model.classify_text(normalise("ูˆุด ุชุจูŠ ุชุณูˆูŠ ุงู„ูŠูˆู…ุŸ ุฃุจูŠ ุฃุฑูˆุญ ุงู„ุณูˆู‚ ุจุณ ุงู„ุญูŠู† ุฒุญู…ุฉ ู…ุฑุฉ"), {"ุงู„ู„ู‡ุฌุฉ": DIALECTS})
# {'ุงู„ู„ู‡ุฌุฉ': 'ุฎู„ูŠุฌูŠ'}
model.classify_text(normalise("ุฃู†ุง ู…ุด ุนุงุฑู ุฃุนู…ู„ ุฅูŠู‡ ุฏู„ูˆู‚ุชูŠุŒ ุนุงูŠุฒ ุฃุฑูˆุญ ุจุณ ุงู„ุฏู†ูŠุง ุฒุญู…ุฉ ุฃูˆูŠ"), {"ุงู„ู„ู‡ุฌุฉ": DIALECTS})
# {'ุงู„ู„ู‡ุฌุฉ': 'ู…ุตุฑูŠ'}
model.classify_text(normalise("ุดูˆ ุจุฏูƒ ุชุนู…ู„ ู‡ู„ู‚ุŸ ุฃู†ุง ูƒุชูŠุฑ ุชุนุจุงู† ูˆุจุฏูŠ ู†ุงู…"), {"ุงู„ู„ู‡ุฌุฉ": DIALECTS})
# {'ุงู„ู„ู‡ุฌุฉ': 'ุดุงู…ูŠ'}
model.classify_text(normalise("ูˆุงุด ุฑุงูƒ ุฎูˆูŠุงุŸ ุจุฒุงู ุฏูŠุงู„ ุงู„ุฎุฏู…ุฉ ุงู„ูŠูˆู… ูˆู…ุง ุนู†ุฏูŠุด ุงู„ูˆู‚ุช"), {"ุงู„ู„ู‡ุฌุฉ": DIALECTS})
# {'ุงู„ู„ู‡ุฌุฉ': 'ู…ุบุงุฑุจูŠ'}
model.classify_text(normalise("ุฃุนู„ู†ุช ูˆุฒุงุฑุฉ ุงู„ุชุนู„ูŠู… ุนู† ุจุฏุก ุงู„ุชุณุฌูŠู„ ู„ู„ุนุงู… ุงู„ุฏุฑุงุณูŠ ุงู„ุฌุฏูŠุฏ"), {"ุงู„ู„ู‡ุฌุฉ": DIALECTS})
# {'ุงู„ู„ู‡ุฌุฉ': 'ูุตุญู‰'}

Dialect is the weakest head: 0.73 accuracy on a balanced five-way test (base 0.25; chance 0.20), and 5 of the 5 sentences above are answered correctly. Short tweets in Gulf, Levantine and standard Arabic share most of their words; use the answer as a hint and keep the confidence.

SMS category: fraud / ads / normal. The task is ุชุตู†ูŠู ุงู„ุฑุณุงู„ุฉ โ†’ ุงุญุชูŠุงู„ / ุฅุนู„ุงู† / ุนุงุฏูŠ, or in English label โ†’ fraud / ads / normal; the finer ู†ูˆุน ุงู„ุฑุณุงู„ุฉ / message type has five labels (ุงุญุชูŠุงู„ fraud, ุฅุนู„ุงู† advertisement, ุดูƒูˆู‰ complaint, ุฅุดุนุงุฑ notification, ู…ุญุงุฏุซุฉ ุดุฎุตูŠุฉ personal).

CATEGORY = {"ุชุตู†ูŠู ุงู„ุฑุณุงู„ุฉ": ["ุงุญุชูŠุงู„", "ุฅุนู„ุงู†", "ุนุงุฏูŠ"]}

model.classify_text(normalise("ุนู…ูŠู„ STC ุงู„ุนุฒูŠุฒ ุฑุตูŠุฏ ู†ู‚ุงุทูƒ ุงู„ุญุงู„ูŠ ู‡ูˆ 3134 ูˆุณุชู†ุชู‡ูŠ ุตู„ุงุญูŠุฉ ู‡ุฐู‡ ุงู„ู†ู‚ุงุท ุฎู„ุงู„ ุซู„ุงุซุฉ ุฃูŠุงู…ุŒ ุงุณุชุจุฏู„ู‡ุง ุงู„ุขู† ุนุจุฑ ุงู„ุฑุงุจุท https://bit.ly/3xYzAbC"), CATEGORY, include_confidence=True)
# {'ุชุตู†ูŠู ุงู„ุฑุณุงู„ุฉ': {'label': 'ุงุญุชูŠุงู„', 'confidence': 1.0}}
model.classify_text(normalise("ุงู„ุณู„ุงู… ุนู„ูŠูƒู… ูƒูŠููƒ ูŠุง ู‚ู„ุจูŠ ู…ุนูƒ ุฃู… ููŠุตู„ ู‡ุฐุง ุฑู‚ู…ูŠ ุงู„ุฌุฏูŠุฏุŒ ุจุบูŠุช ู…ู†ูƒ 1200 ุฑูŠุงู„ ุณู„ู ูˆุฃุฑุฌุนู‡ุง ุงู„ุฎู…ูŠุณ"), CATEGORY, include_confidence=True)
# {'ุชุตู†ูŠู ุงู„ุฑุณุงู„ุฉ': {'label': 'ุงุญุชูŠุงู„', 'confidence': 1.0}}
model.classify_text(normalise("ุฎุตู… 30% ุนู„ู‰ ุฌู…ูŠุน ุงู„ู…ูƒูŠูุงุช ู„ุฏู‰ ู…ุนุฑุถ ุงู„ู†ุฎุจุฉ ุญุชู‰ ู†ู‡ุงูŠุฉ ุงู„ุฃุณุจูˆุนุŒ ุงู„ุชูˆุตูŠู„ ูˆุงู„ุชุฑูƒูŠุจ ู…ุฌุงู†ุงู‹"), CATEGORY, include_confidence=True)
# {'ุชุตู†ูŠู ุงู„ุฑุณุงู„ุฉ': {'label': 'ุฅุนู„ุงู†', 'confidence': 1.0}}
model.classify_text(normalise("ุดุฑุงุก ุนุจุฑ ุงู„ุฅู†ุชุฑู†ุช ุจุทุงู‚ุฉ ู…ุฏู‰ 4321 ู…ุจู„ุบ 150 ุฑูŠุงู„ ู„ุฏู‰ ู…ุชุฌุฑ ุฌุฑูŠุฑ ููŠ 02/06/2024"), CATEGORY, include_confidence=True)
# {'ุชุตู†ูŠู ุงู„ุฑุณุงู„ุฉ': {'label': 'ุนุงุฏูŠ', 'confidence': 1.0}}

# English task and labels, same messages
model.classify_text(normalise("ุนู…ูŠู„ STC ุงู„ุนุฒูŠุฒ ุฑุตูŠุฏ ู†ู‚ุงุทูƒ ุงู„ุญุงู„ูŠ ู‡ูˆ 313..."), {"label": ["fraud", "ads", "normal"]}, include_confidence=True)
# {'label': {'label': 'fraud', 'confidence': 1.0}}

On the careful gold this checkpoint finds 94% of the fraud messages at 87% precision (base: 12% recall). Dedicated char n-gram classifiers on the same messages: classifier v1 (Qwen labels) 0.806 (fraud recall 0.65); classifier v2 (rubric labels) 0.879 (fraud recall 0.94).

3 ยท Structured records (JSON)

news = normalise("ุชุฃุณุณุช ุดุฑูƒุฉ ุงู„ุงุชุตุงู„ุงุช ุงู„ุณุนูˆุฏูŠุฉ ุนุงู… 1998 ูˆู…ู‚ุฑู‡ุง ุงู„ุฑูŠุงุถุŒ "
                 "ูˆูŠุฑุฃุณู‡ุง ุงู„ู…ู‡ู†ุฏุณ ุนู„ูŠุงู† ุงู„ูˆุชูŠุฏ.")

model.extract_json(news, {"ุดุฑูƒุฉ": ["ุงู„ุงุณู…", "ุงู„ู…ู‚ุฑ", "ุณู†ุฉ ุงู„ุชุฃุณูŠุณ", "ุงู„ุฑุฆูŠุณ"]})
# {'ุดุฑูƒุฉ': [{'ุงู„ุงุณู…': ['ุดุฑูƒุฉ ุงู„ุงุชุตุงู„ุงุช ุงู„ุณุนูˆุฏูŠุฉ'],
#            'ุงู„ู…ู‚ุฑ': ['ุงู„ุฑูŠุงุถ'],
#            'ุณู†ุฉ ุงู„ุชุฃุณูŠุณ': ['1998'],
#            'ุงู„ุฑุฆูŠุณ': ['ุนู„ูŠุงู† ุงู„ูˆุชูŠุฏ']}]}

Field values are lists (a field may occur more than once) and extraction is extractive: every value should be a substring of the input. A value that is not is a hallucination โ€” log it.

4 ยท Relations

model.extract_relations(news, ["ุงู„ู…ู‚ุฑ", "ุชุงุฑูŠุฎ ุงู„ุชุฃุณูŠุณ", "ุงู„ู…ู‡ู†ุฉ"])
# {'relation_extraction': {'ุงู„ู…ู‚ุฑ': [['ุดุฑูƒุฉ ุงู„ุงุชุตุงู„ุงุช ุงู„ุณุนูˆุฏูŠุฉ', 'ุงู„ุฑูŠุงุถ']],
#                          'ุชุงุฑูŠุฎ ุงู„ุชุฃุณูŠุณ': [['ุดุฑูƒุฉ ุงู„ุงุชุตุงู„ุงุช ุงู„ุณุนูˆุฏูŠุฉ', '1998']],
#                          'ุงู„ู…ู‡ู†ุฉ': []}}

model.extract_relations(news, ["headquarters location", "inception"])
# {'relation_extraction': {'headquarters location': [['ุดุฑูƒุฉ ุงู„ุงุชุตุงู„ุงุช ุงู„ุณุนูˆุฏูŠุฉ', 'ุงู„ุฑูŠุงุถ']],
#                          'inception': [['ุดุฑูƒุฉ ุงู„ุงุชุตุงู„ุงุช ุงู„ุณุนูˆุฏูŠุฉ', '1998']]}}

Everything at once

from gliner2 import Schema

schema = (Schema()
          .entities(["ุดุฎุต / person", "ู…ู†ุธู…ุฉ / organization", "ู…ูƒุงู† / place"])
          .classification("ุงู„ู…ุดุงุนุฑ", ["ุฅูŠุฌุงุจูŠ", "ุณู„ุจูŠ", "ู…ุญุงูŠุฏ"])
          .structure("ุดุฑูƒุฉ").field("ุงู„ุงุณู…").field("ุงู„ู…ู‚ุฑ")
          .relations(["ุงู„ู…ู‚ุฑ"]))
model.extract(news, schema)
# {'ุดุฑูƒุฉ': [{'ุงู„ุงุณู…': ['ุดุฑูƒุฉ ุงู„ุงุชุตุงู„ุงุช ุงู„ุณุนูˆุฏูŠุฉ'], 'ุงู„ู…ู‚ุฑ': ['ุงู„ุฑูŠุงุถ']}],
#  'entities': {'ุดุฎุต / person': ['ุนู„ูŠุงู† ุงู„ูˆุชูŠุฏ'],
#               'ู…ู†ุธู…ุฉ / organization': ['ุดุฑูƒุฉ ุงู„ุงุชุตุงู„ุงุช ุงู„ุณุนูˆุฏูŠุฉ'],
#               'ู…ูƒุงู† / place': ['ุงู„ุฑูŠุงุถ']},
#  'ุงู„ู…ุดุงุนุฑ': 'ู…ุญุงูŠุฏ',
#  'relation_extraction': {'ุงู„ู…ู‚ุฑ': [['ุดุฑูƒุฉ ุงู„ุงุชุตุงู„ุงุช ุงู„ุณุนูˆุฏูŠุฉ', 'ุงู„ุฑูŠุงุถ']]}}

5 ยท Multi-label classification

One task, several true labels. Ask with multi_label=True through the schema builder:

ticket = normalise("ุชูˆุงุตู„ ู…ุนู†ุง ุงู„ุนู…ูŠู„ ุณุนูˆุฏ ุงู„ุฏูˆุณุฑูŠุŒ ุฑู‚ู… ุงู„ู‡ูˆูŠุฉ 1098765432ุŒ ุนุจุฑ ุงู„ุฌูˆุงู„ 0551234567 "
                   "ุจุฎุตูˆุต ูุงุชูˆุฑุฉ ุจู‚ูŠู…ุฉ 450 ุฑูŠุงู„ุงู‹ ุตุงุฏุฑุฉ ุจุชุงุฑูŠุฎ 3 ู…ุงูŠูˆ 2024 ู…ู† ูุฑุน ุงู„ุฑูŠุงุถ.")
TYPES = ["ุดุฎุต / person", "ู…ู†ุธู…ุฉ / organization", "ู…ูƒุงู† / place", "ุชุงุฑูŠุฎ / date",
         "ู…ุจู„ุบ ู…ุงู„ูŠ / money", "ุฑู‚ู… ุฌูˆุงู„ / mobile number", "ุฑู‚ู… ุงู„ู‡ูˆูŠุฉ ุงู„ูˆุทู†ูŠุฉ / national id number"]

model.extract(ticket, Schema().classification("ุฃู†ูˆุงุน ุงู„ูƒูŠุงู†ุงุช", TYPES, multi_label=True))
# {'ุฃู†ูˆุงุน ุงู„ูƒูŠุงู†ุงุช': ['ุดุฎุต / person',
#                     'ู…ูƒุงู† / place',
#                     'ุชุงุฑูŠุฎ / date',
#                     'ู…ุจู„ุบ ู…ุงู„ูŠ / money',
#                     'ุฑู‚ู… ุฌูˆุงู„ / mobile number',
#                     'ุฑู‚ู… ุงู„ู‡ูˆูŠุฉ ุงู„ูˆุทู†ูŠุฉ / national id number']}

6 ยท Records with choice fields and list fields

A choices=[...] field is a classification inside a record: its value comes from the list, not from the text. dtype="list" lets a field hold several values.

record = (Schema().structure("ุณุฌู„")
          .field("ุดุฎุต / person", dtype="list")
          .field("ุฑู‚ู… ุงู„ู‡ูˆูŠุฉ ุงู„ูˆุทู†ูŠุฉ / national id number")
          .field("ูŠุญุชูˆูŠ ุจูŠุงู†ุงุช ุดุฎุตูŠุฉ", choices=["ู†ุนู…", "ู„ุง"]))

model.extract(ticket, record)
# {'ุณุฌู„': [{'ุดุฎุต / person': ['ุณุนูˆุฏ ุงู„ุฏูˆุณุฑูŠ'],
#           'ุฑู‚ู… ุงู„ู‡ูˆูŠุฉ ุงู„ูˆุทู†ูŠุฉ / national id number': ['1098765432'],
#           'ูŠุญุชูˆูŠ ุจูŠุงู†ุงุช ุดุฎุตูŠุฉ': ['ู†ุนู…']}]}

Do not let the model's flag be the only gate on personal data: derive it from the extracted fields and keep the choice field as a second opinion.

A choice field that should return several of its options at once does not work in this checkpoint: a record-type field over the entity types (.field("ู†ูˆุน ุงู„ุณุฌู„", choices=TYPES), which an earlier card of this repository showed returning two types) comes back empty on the same text. Ask that question as a multi-label classification (section 5), which answers it.

7 ยท Several records of one name from one text

meeting = normalise("ุญุถุฑ ุงู„ุงุฌุชู…ุงุน ุงู„ู…ู‡ู†ุฏุณ ูู‡ุฏ ุงู„ุนุชูŠุจูŠ ู…ู† ุดุฑูƒุฉ ุฃุฑุงู…ูƒูˆุŒ ูˆุงู„ุฏูƒุชูˆุฑุฉ ุฑูŠู… ุงู„ุดู‡ุฑูŠ ู…ู† "
                    "ุฌุงู…ุนุฉ ุงู„ู…ู„ูƒ ุณุนูˆุฏุŒ ูˆุงู„ุฃุณุชุงุฐ ู…ุงุฌุฏ ุงู„ู‚ุญุทุงู†ูŠ ู…ู† ู‡ูŠุฆุฉ ุงู„ุงุชุตุงู„ุงุช.")

model.extract(meeting, Schema().structure("ู…ุดุงุฑูƒ", mode="natural", occurrence_policy="all")
                                .field("ุงู„ุงุณู…").field("ุงู„ุฌู‡ุฉ"))
# {'ู…ุดุงุฑูƒ': [{'ุงู„ุงุณู…': 'ูู‡ุฏ ุงู„ุนุชูŠุจูŠ', 'ุงู„ุฌู‡ุฉ': ['ุดุฑูƒุฉ ุฃุฑุงู…ูƒูˆ', 'ุฌุงู…ุนุฉ ุงู„ู…ู„ูƒ ุณุนูˆุฏ']},
#            {'ุงู„ุงุณู…': 'ุฑูŠู… ุงู„ุดู‡ุฑูŠ', 'ุงู„ุฌู‡ุฉ': ['ุดุฑูƒุฉ ุฃุฑุงู…ูƒูˆ', 'ุฌุงู…ุนุฉ ุงู„ู…ู„ูƒ ุณุนูˆุฏ']},
#            {'ุงู„ุงุณู…': 'ู…ุงุฌุฏ ุงู„ู‚ุญุทุงู†ูŠ', 'ุงู„ุฌู‡ุฉ': ['ุดุฑูƒุฉ ุฃุฑุงู…ูƒูˆ', 'ุฌุงู…ุนุฉ ุงู„ู…ู„ูƒ ุณุนูˆุฏ', 'ู‡ูŠุฆุฉ ุงู„ุงุชุตุงู„ุงุช']}]}

This is the weakest shape: read the output above before relying on it. When you need every participant paired with the right organisation, ask the entity head, which returns them all, and pair by proximity yourself:

model.extract_entities(meeting, ["ุดุฎุต / person", "ู…ู†ุธู…ุฉ / organization"])
# {'entities': {'ุดุฎุต / person': ['ูู‡ุฏ ุงู„ุนุชูŠุจูŠ', 'ู…ุงุฌุฏ ุงู„ู‚ุญุทุงู†ูŠ', 'ุฑูŠู… ุงู„ุดู‡ุฑูŠ'],
#               'ู…ู†ุธู…ุฉ / organization': ['ุดุฑูƒุฉ ุฃุฑุงู…ูƒูˆ', 'ุฌุงู…ุนุฉ ุงู„ู…ู„ูƒ ุณุนูˆุฏ', 'ู‡ูŠุฆุฉ ุงู„ุงุชุตุงู„ุงุช']}}

8 ยท New labels, explained rather than named

The schema is text, so a label the model never saw can carry a description. Pass a dict instead of a list, for entity types and for classification labels alike:

model.extract(ticket, Schema().entities({
    "ุฑู‚ู… ู…ุฑุฌุนูŠ": "ุฑู‚ู… ูŠุนุฑู‘ู ุนู…ูŠู„ุงู‹ ุฃูˆ ูˆุซูŠู‚ุฉุŒ ู…ุซู„ ุฑู‚ู… ุงู„ู‡ูˆูŠุฉ ุฃูˆ ุฑู‚ู… ุงู„ูุงุชูˆุฑุฉ",
    "ู…ุจู„ุบ":      "ู‚ูŠู…ุฉ ู…ุงู„ูŠุฉ ู…ุน ุนู…ู„ุชู‡ุง",
}))
# {'entities': {'ุฑู‚ู… ู…ุฑุฌุนูŠ': [], 'ู…ุจู„ุบ': ['450 ุฑูŠุงู„ุง']}}

model.extract(ticket, Schema().classification("ู†ูˆุน ุงู„ุทู„ุจ", {
    "ุดูƒูˆู‰":     "ุงู„ุนู…ูŠู„ ุบูŠุฑ ุฑุงุถู ุนู† ุฎุฏู…ุฉ ุฃูˆ ูุงุชูˆุฑุฉ",
    "ุงุณุชูุณุงุฑ":  "ุงู„ุนู…ูŠู„ ูŠุณุฃู„ ุนู† ู…ุนู„ูˆู…ุฉ",
    "ุทู„ุจ ุฎุฏู…ุฉ": "ุงู„ุนู…ูŠู„ ูŠุฑูŠุฏ ุชูุนูŠู„ ุฃูˆ ุฅู„ุบุงุก ุฎุฏู…ุฉ",
}))
# {'ู†ูˆุน ุงู„ุทู„ุจ': 'ุงุณุชูุณุงุฑ'}

ุฑู‚ู… ู…ุฑุฌุนูŠ is also one of the trained document labels (the reference number of an official document). In this example the description does not widen it to the identity number, which an earlier checkpoint in this repository returned here: ask for ุฑู‚ู… ุงู„ู‡ูˆูŠุฉ ุงู„ูˆุทู†ูŠุฉ / national id number by name.

9 ยท Batches and long documents

Every extract_* call has a batch_* twin that takes a list of texts, and a *_long twin that chunks a document (default 384 tokens with 64 of overlap) and merges the spans:

model.batch_extract_entities([ticket, meeting], ["ุดุฎุต / person", "ู…ู†ุธู…ุฉ / organization"], batch_size=8)
# [{'entities': {'ุดุฎุต / person': ['ุณุนูˆุฏ ุงู„ุฏูˆุณุฑูŠ'], 'ู…ู†ุธู…ุฉ / organization': []}},
#  {'entities': {'ุดุฎุต / person': ['ูู‡ุฏ ุงู„ุนุชูŠุจูŠ', 'ู…ุงุฌุฏ ุงู„ู‚ุญุทุงู†ูŠ', 'ุฑูŠู… ุงู„ุดู‡ุฑูŠ'],
#                'ู…ู†ุธู…ุฉ / organization': ['ุดุฑูƒุฉ ุฃุฑุงู…ูƒูˆ', 'ุฌุงู…ุนุฉ ุงู„ู…ู„ูƒ ุณุนูˆุฏ', 'ู‡ูŠุฆุฉ ุงู„ุงุชุตุงู„ุงุช']}}]

model.extract_entities_long(long_document, ["ุดุฎุต / person", "ุฑู‚ู… ุฌูˆุงู„ / mobile number"],
                            chunk_size=384, chunk_overlap=64, include_spans=True)

threshold (default 0.5) is accepted by every call; lower it for recall, raise it for precision. For case files and other long documents, windows of about 1,500 characters gave the best recall in our tests.

What it was trained to answer

Entity types

General, 17 bilingual names: ุดุฎุต / person, ู…ู†ุธู…ุฉ / organization, ู…ูƒุงู† / place, ุนู†ูˆุงู† / address, ุชุงุฑูŠุฎ / date, ูˆู‚ุช / time, ู…ุจู„ุบ ู…ุงู„ูŠ / money, ู†ุณุจุฉ ู…ุฆูˆูŠุฉ / percentage, ุฑู‚ู… ุฌูˆุงู„ / mobile number, ุฑู‚ู… ุงู„ู‡ูˆูŠุฉ ุงู„ูˆุทู†ูŠุฉ / national id number, ู…ูˆู‚ุน ุฅู„ูƒุชุฑูˆู†ูŠ / website, ู…ุทุงุฑ / airport, ุชุฑุชูŠุจ / ordinal, ุนุฏุฏ / cardinal number, ุนู…ู„ุฉ / currency, ูƒู…ูŠุฉ / quantity, ูˆุญุฏุฉ ู‚ูŠุงุณ / unit of measurement. Official documents, six more: ุฑู‚ู… ุงู„ุณุฌู„ ุงู„ุชุฌุงุฑูŠ / commercial register number, ุฑู‚ู… ุงู„ุขูŠุจุงู† / iban, ุจุฑูŠุฏ ุฅู„ูƒุชุฑูˆู†ูŠ / email, ู„ูˆุญุฉ ู…ุฑูƒุจุฉ / vehicle plate, ุฑู‚ู… ู…ุฑุฌุนูŠ / reference number, ู…ู†ุตุจ / job title. Two more since round 14, with ุนู…ู„ุฉ / currency now meaning a currency named without an amount: ู…ู†ุตุฉ / platform (an app, platform or online service by name, not a URL) and ู…ุฏุฉ / duration (a number with a unit of time). Short product names: person, organization, location, bank_account, phone, email, national_id, passport, vehicle. Real SMS, Arabic or English names: mobile number, iban, email, website, money, percentage, date, time, person, organization, place.

Classification tasks

task (ar) task (en) labels
ุชุตู†ูŠู ุงู„ุฑุณุงู„ุฉ label ุงุญุชูŠุงู„ (fraud), ุฅุนู„ุงู† (ads), ุนุงุฏูŠ (normal)
ู†ูˆุน ุงู„ุฑุณุงู„ุฉ message type ุงุญุชูŠุงู„ (fraud), ุฅุนู„ุงู† (advertisement), ุดูƒูˆู‰ (complaint), ุฅุดุนุงุฑ (notification), ู…ุญุงุฏุซุฉ ุดุฎุตูŠุฉ (personal)
ุงู„ู„ู‡ุฌุฉ dialect ู…ุตุฑูŠ (egypt), ุฎู„ูŠุฌูŠ (gulf), ุดุงู…ูŠ (levant), ู…ุบุงุฑุจูŠ (magreb), ูุตุญู‰ (msa)
ุงู„ุณุฎุฑูŠุฉ sarcasm ุบูŠุฑ ุณุงุฎุฑ (non-sarcastic), ุณุงุฎุฑ (sarcastic)
ุงู„ู…ุดุงุนุฑ sentiment ุณู„ุจูŠ (negative), ู…ุญุงูŠุฏ (neutral), ุฅูŠุฌุงุจูŠ (positive)
ู†ูˆุน ุงู„ุฎุทุงุจ speech act ุชุฃูƒูŠุฏ (Assertion), ุชูˆุตูŠุฉ (Recommendation), ุชุนุจูŠุฑ (Expression), ุณุคุงู„ (Question), ุทู„ุจ (Request), ุฃุฎุฑู‰ (Miscellaneous)
ุงู„ู…ูˆุถูˆุน topic ุชู‚ู†ูŠุฉ (Tech), ุงู‚ุชุตุงุฏ (Finance), ุณูŠุงุณุฉ (Politics), ุฏูŠู† (Religion), ุทุจ (Medical), ุซู‚ุงูุฉ (Culture), ุฑูŠุงุถุฉ (Sports)

Relation types (32, Wikidata predicates from REDFM)

author ุงู„ู…ุคู„ู ยท capital ุงู„ุนุงุตู…ุฉ ยท cast member ู…ู† ุทุงู‚ู… ุงู„ุนู…ู„ ยท characters ุงู„ุดุฎุตูŠุงุช ยท child ุงู„ุงุจู† ยท country ุงู„ุฏูˆู„ุฉ ยท country of citizenship ุจู„ุฏ ุงู„ุฌู†ุณูŠุฉ ยท director ุงู„ู…ุฎุฑุฌ ยท follows ูŠุชุจุน ยท founded by ุฃุณุณู‡ุง ยท genre ุงู„ู†ูˆุน ยท headquarters location ุงู„ู…ู‚ุฑ ยท inception ุชุงุฑูŠุฎ ุงู„ุชุฃุณูŠุณ ยท instance of ู†ูˆุน ู…ู† ยท league ุงู„ุฏูˆุฑูŠ ยท located in or next to body of water ูŠู‚ุน ุนู„ู‰ ู…ุณุทุญ ู…ุงุฆูŠ ยท location ุงู„ู…ูˆู‚ุน ยท manufacturer ุงู„ุดุฑูƒุฉ ุงู„ู…ุตู†ุนุฉ ยท member of ุนุถูˆ ููŠ ยท mouth of the watercourse ู…ุตุจ ุงู„ู†ู‡ุฑ ยท named after ุณู…ูŠ ู†ุณุจุฉ ุฅู„ู‰ ยท notable work ุนู…ู„ ุจุงุฑุฒ ยท occupation ุงู„ู…ู‡ู†ุฉ ยท owned by ู…ู…ู„ูˆูƒ ู„ู€ ยท part of ุฌุฒุก ู…ู† ยท participant ู…ุดุงุฑูƒ ยท place of birth ู…ูƒุงู† ุงู„ู…ูŠู„ุงุฏ ยท replaces ูŠุญู„ ู…ุญู„ ยท shares border with ูŠุญุฏ ยท sibling ุดู‚ูŠู‚ ยท sport ุงู„ุฑูŠุงุถุฉ ยท spouse ุงู„ุฒูˆุฌ

Document relations (bilingual names): ุฑู‚ู… ู‡ูˆูŠุฉ ุงู„ุดุฎุต / person national id, ุณุฌู„ ุชุฌุงุฑูŠ ุงู„ุฌู‡ุฉ / organization commercial register, ุจู†ูƒ ุงู„ุขูŠุจุงู† / iban bank, ุตุงุญุจ ุงู„ุญุณุงุจ / account holder, ูŠุนู…ู„ ููŠ / works for, ูŠุดุบู„ ู…ู†ุตุจ / holds position, ู…ุงู„ูƒ / owner of. Product relations: works_for, owns, director_of, paid, transferred_to, located_in, family_of, associate_of, contacted.

Results

Measured on held-out data before and after fine-tuning. "Before" is the base checkpoint fastino/gliner2.5-multi-v1 answering the same schemas with the same decoding (threshold 0.5, overlap flat, max_len 384). ฮ” is the paired-bootstrap difference with its 95 % interval. The full run is 20_Model_vs_Base_Evaluation.ipynb (2026-11-26); evaluation.json in this repo holds every number.

Extraction (micro F1)

test set rows before after ฮ” [95 % CI]
Real Saudi SMS, human-reviewed gold 400 0.553 0.857 +0.304 [+0.260, +0.349]
Real Gulf tweets, blind careful labels 250 0.538 0.824 +0.286 [+0.243, +0.333]
Saudi gold sentences (dialect + standard) 42 0.758 0.947 +0.189 [+0.127, +0.252]
Short Saudi texts (written by ChatGPT, held out) 60 0.475 0.955 +0.480 [+0.411, +0.555]
Saudi official documents (held out) 30 0.622 0.935 +0.314 [+0.269, +0.362]
Standard Arabic news (IAHLT) 500 0.614 0.847 +0.233 [+0.201, +0.264]
Numeric / temporal types (Wojood) 364 0.469 0.825 +0.356 [+0.315, +0.395]
Wikipedia (WikiANN ar) 406 0.578 0.736 +0.158 [+0.120, +0.198]
Levantine dialect (ShamNER) 500 0.249 0.452 +0.203 [+0.123, +0.275]
English (WikiANN en) 500 0.538 0.740 +0.202 [+0.169, +0.239]
Hindi (WikiANN hi) 200 0.198 0.744 +0.545 [+0.469, +0.621]
Relations: REDFM Arabic, human-revised 690 0.178 0.463 +0.284 [+0.253, +0.315]
Structured records, Arabic 5 0.618 0.909 +0.291 [+0.160, +0.420]

Across all 33 extraction sets: significantly better on 25, significantly worse on 0.

Classification (accuracy / macro-F1; each task asked alone, Arabic and English askings pooled)

task and test rows before previous release after
SMS category: fraud / ads / normal (careful gold) 546 0.313 / 0.262 0.898 / 0.897 0.899 / 0.898
SMS message type, 5-way (careful gold) 537 0.198 / 0.185 0.890 / 0.872 0.892 / 0.874
Dialect, balanced set (250 per dialect) 1,250 0.248 / 0.222 0.728 / 0.726 0.727 / 0.725
Dialect, ArSarcasm v2 test (77 % standard Arabic) 2,956 0.374 / 0.220 0.577 / 0.410 0.587 / 0.412
Sentiment, ArSarcasm v2 test 2,956 0.546 / 0.492 0.663 / 0.615 0.665 / 0.618
Sarcasm, ArSarcasm v2 test 2,956 0.527 / 0.499 0.742 / 0.703 0.738 / 0.699

The SMS tests are 627 held-out real messages. "Careful gold" is a blind re-read under a written rubric; the labels earlier releases used (an LLM's message type) agree with it on 75 % of the messages and call most phishing notices notification. On the careful gold this checkpoint finds 94% of the fraud messages at 87% precision (base: 12% recall). Dedicated char n-gram classifiers on the same messages: classifier v1 (Qwen labels) 0.806 (fraud recall 0.65); classifier v2 (rubric labels) 0.879 (fraud recall 0.94).

Scam type of a fraud message: a companion classifier

The checkpoint says whether a message is fraud. It does not say which kind. Round 15 tried to teach it that, and a small character n-gram classifier trained on the same labels scored higher than every fine-tuned candidate. So the scam type ships beside the model, not inside it: one 8 MB file in scam_type/, read with numpy alone in about 0.2 ms a message.

import sys
from huggingface_hub import snapshot_download

d = snapshot_download("Elafnawaf/gliner2-arabic-saudi", allow_patterns="scam_type/*")
sys.path.insert(0, f"{d}/scam_type")
from scam_type import ScamType

clf = ScamType(f"{d}/scam_type")
clf.read("ุดุญู†ุชูƒ ู…ุชูˆู‚ูุฉ ููŠ ู…ุญุทุฉ ุงู„ุชูˆุฒูŠุนุŒ ุงุฏูุน ุฑุณูˆู… ุงู„ุชูˆุตูŠู„ ุนุจุฑ ุงู„ุฑุงุจุท")
# {'code': 'PARCEL_DELIVERY', 'label': 'ุดุญู†ุฉ ูˆุชูˆุตูŠู„', 'label_en': 'parcel delivery', 'confidence': 0.9998, 'second': 'OTHER', 'second_confidence': 0.0001, 'band': 'high'}

How to use it.

  • Ask it only about messages that are fraud: the answer of this checkpoint's ุชุตู†ูŠู ุงู„ุฑุณุงู„ุฉ task, or a user's own report. The classifier has no "not a scam" answer and names a kind for any text it can read.
  • Go by the confidence. band is high from 0.8, medium from 0.5, low under that; the table below says how often each is right.
  • read returns None when it knows nothing in the message (another language, a bare number).
  • The loader normalises the text itself, as in "Normalise first", and writes every digit as 0.
code label English covers
BANK_PHISHING ุงู†ุชุญุงู„ ุจู†ูƒ bank impersonation a bank, card or wallet: account stopped, update your data, card details asked
GOV_IMPERSONATION ุงู†ุชุญุงู„ ุฌู‡ุฉ ุญูƒูˆู…ูŠุฉ government impersonation a government body or platform: Absher, Nafath, traffic fines, police, ministries
PARCEL_DELIVERY ุดุญู†ุฉ ูˆุชูˆุตูŠู„ parcel delivery a parcel held or waiting: customs or delivery fee, address needed, any courier
JOB_RECRUITMENT ูˆุธูŠูุฉ ูˆุนู…ู„ ู…ู† ุงู„ู…ู†ุฒู„ job offer work offered: part-time or remote work, task jobs, daily pay, a recruiter's opener
INVESTMENT_STOCKS ุงุณุชุซู…ุงุฑ ูˆุชุฏุงูˆู„ investment money that grows: trading, shares, crypto, recommendation groups, sure profit
LOAN_SUPPORT_FEE ู‚ุฑุถ ุฃูˆ ุฏุนู… ู…ู‚ุงุจู„ ุฑุณูˆู… loan or support for a fee money promised to the receiver: loans, financing, support or aid, usually for a fee
PRIZE_LOTTERY ุฌุงุฆุฒุฉ ูˆู…ุณุงุจู‚ุฉ prize you won: prize, draw, competition, a gift with a claim step
LOYALTY_POINTS ู†ู‚ุงุท ูˆู…ูƒุงูุขุช loyalty points points or rewards about to expire or waiting to be redeemed
CHARITY_APPEAL ุชุจุฑุน ูˆุตุฏู‚ุฉ charity the receiver is asked to give: donations, a stranger's plea for help
FORGED_MEDICAL ุชู‚ุงุฑูŠุฑ ุทุจูŠุฉ medical reports sick leave or medical reports for sale
DEBT_LEGAL_THREAT ุชู‡ุฏูŠุฏ ุจู‚ุถูŠุฉ ุฃูˆ ุฏูŠู† debt or legal threat the receiver is said to owe money or to face a case: arrears, court, lawyer
NUMBER_CHANGE_LURE ุชุบูŠูŠุฑ ุฑู‚ู… ุฃูˆ ุฑู‚ู… ุฎุงุทุฆ new number or wrong number a social opener: "this is my new number", a false relative, wrong number, romance
OTHER ุฃุฎุฑู‰ other fraud of none of the twelve kinds above

Measured on 838 real fraud messages, held out from training by campaign. Each was read blind under a written rubric by an AI assistant, a language model was the second reader, and the rows where they differed were read a second time. No person has reviewed these labels yet: the scores are against a careful reading, not against a human gold.

accuracy macro-F1
keyword rules on the same messages 0.492 0.507
this classifier 0.815 0.820 [0.791, 0.846]
confidence share of messages answer is right right answer among the first two
high, 0.8 or more 71 % 0.943 0.975
medium, 0.5 to 0.8 20 % 0.539 0.805
low, under 0.5 9 % 0.419 0.730
label messages precision recall F1
ุดุญู†ุฉ ูˆุชูˆุตูŠู„ 80 0.94 0.96 0.95
ุงุณุชุซู…ุงุฑ ูˆุชุฏุงูˆู„ 62 0.98 0.90 0.94
ุชู‚ุงุฑูŠุฑ ุทุจูŠุฉ 46 0.88 0.98 0.93
ูˆุธูŠูุฉ ูˆุนู…ู„ ู…ู† ุงู„ู…ู†ุฒู„ 130 0.97 0.88 0.92
ู†ู‚ุงุท ูˆู…ูƒุงูุขุช 31 0.91 0.94 0.92
ุฌุงุฆุฒุฉ ูˆู…ุณุงุจู‚ุฉ 29 0.85 0.79 0.82
ุชู‡ุฏูŠุฏ ุจู‚ุถูŠุฉ ุฃูˆ ุฏูŠู† 48 0.76 0.88 0.82
ุชุจุฑุน ูˆุตุฏู‚ุฉ 59 0.79 0.81 0.80
ู‚ุฑุถ ุฃูˆ ุฏุนู… ู…ู‚ุงุจู„ ุฑุณูˆู… 59 0.70 0.92 0.79
ุงู†ุชุญุงู„ ุฌู‡ุฉ ุญูƒูˆู…ูŠุฉ 45 0.81 0.64 0.72
ุชุบูŠูŠุฑ ุฑู‚ู… ุฃูˆ ุฑู‚ู… ุฎุงุทุฆ 51 0.58 0.90 0.71
ุงู†ุชุญุงู„ ุจู†ูƒ 34 0.71 0.65 0.68
ุฃุฎุฑู‰ 164 0.74 0.60 0.66

Limits. The weak labels are ยซุงู†ุชุญุงู„ ุจู†ูƒยป (recall 0.65), ยซุงู†ุชุญุงู„ ุฌู‡ุฉ ุญูƒูˆู…ูŠุฉยป (0.64) and ยซุฃุฎุฑู‰ยป (0.60). ยซุชุบูŠูŠุฑ ุฑู‚ู… ุฃูˆ ุฑู‚ู… ุฎุงุทุฆยป is over-called (precision 0.58): conversational scams of several kinds look like it. The training messages are fraud reported in Saudi Arabia, mostly Arabic with some English; nothing else was measured.

What the file holds. 190,454 character n-grams of two to five characters, their weights and the coefficients of a logistic regression, trained on 33,715 labelled fraud messages. The messages are not published. Every digit was written as 0 before training, so the file holds no phone number, account number or identity number. N-grams never cross a word boundary, and the ones containing "@" are left out, so no sentence and no e-mail address can be put back together from it. scam_type/reference.json holds invented messages with the expected answers, to check an installation; scam_type/evaluation.json holds every number above.

Training data

Counts are examples in the final training mix (mix_manifest.json). Held-out test texts are excluded when a mix is built, and the invented names of the synthetic test sets are on a blocklist.

block used for examples
IAHLT, WikiANN, Wojood sample, ShamNER, synthetic Saudi PII, generated Saudi-dialect sentences, weak labels on news and Gulf tweets entities 42,003
Real Saudi SMS (LLM silver labels, every training message re-read; real identifiers, never published) + truncated copies entities 12,434
Real Gulf tweets, careful blind labels + truncated copies entities 8,284
Synthetic Saudi official documents (tenders, deeds, statements, prosecution orders) entities 15,722
Product label names on multi-segment documents entities, relations 8,855
SREDFM Arabic relations 16,000
Generated Saudi records structured extraction, multi-label 8,695
ArSarcasm v1 + v2, ArSAS, SANAD sentiment, sarcasm, speech act, topic 22,493
ArSarcasm + IADD, class-balanced, dialect asked alone dialect 33,500
Real SMS with rubric labels (1,727 blind reads, corrected LLM types, pseudo-labelled reports), class-balanced, asked alone SMS category and type 23,996
Base-model replay and WikiANN in en / fr / de / hi / zh retention of the base behaviour 14,153
Public Arabic tweets and comments labelled by MARBERT teacher classifiers (confidence 0.8 or more), class-balanced, asked alone sentiment, dialect 22,886
The base model's own labels on English PII text, the whole PII label family asked together retention of English PII number types 5,954
Gold English PII, train split of KhalidAlharbi377/pii-detection-multisource-en-saudi-arabic (CC BY 4.0), negatives limited to each source's own label set English PII detection 6,000
SMS category v2: the fraud / ads / normal and five-type rows relabelled under the rule the gold test uses (an unsure override of the first labeller is kept only when a cross-fitted teacher that never saw it agrees); personal chat is a third of the normal class, with short public everyday sentences among its rows SMS category 7,000
Document sentences with the previous release's job titles and this lineage's own reading of every other label job titles on unseen documents 3,000
Public tweets and news sentences weakly labelled with closed lists and number-unit patterns, ambiguous sentences left out the labels ู…ู†ุตุฉ / platform, ู…ุฏุฉ / duration, bare ุนู…ู„ุฉ / currency 3,000

Schema language was Arabic for about half of the examples and English for the rest, always with the same gold answer.

Training details

run examples epochs batch learning rates encoder layers trained time on one L4
1. classification stage U_stage2_e2e5_s42 from T_contS_s42 90,573 5 8 ร— 2 encoder 2e-05, heads 0.0002 layers 4 to 11 2.6 h
2. full mix U_contStage2_s42 from U_stage2_e2e5_s42 195,586 1 1 ร— 16 encoder 2e-06, heads 0.0002 layers 4 to 11 4.7 h
3. classification stage V_stage3_unf_s42 from U_contStage2_s42 101,073 3 8 ร— 2 encoder 2e-05, heads 0.0002 all 12 1.8 h
4. full mix V_contStage3_s42 from V_stage3_unf_s42 206,087 1 1 ร— 16 encoder 2e-06, heads 0.0002 all 12 5.2 h
5. classification stage V_stage4_fix_s42 from V_contStage3_s42 101,073 3 8 ร— 2 encoder 2e-05, heads 0.0002 all 12 1.9 h
6. full mix V_contStage4_s42 from V_stage4_fix_s42 206,087 1 1 ร— 16 encoder 2e-06, heads 0.0002 all 12 6.1 h
7. repair pass (mix sample + PII replay) V_repair1_s42 from V_contStage4_s42 23,993 1 1 ร— 16 encoder 2e-06, heads 0.0002 all 12 0.8 h
8. classification stage W_stage4d_s42 from V_contStage3_s42 151,960 3 8 ร— 2 encoder 2e-05, heads 0.0002 all 12 2.8 h
9. full mix W_contStage4d_s42 from W_stage4d_s42 234,927 1 1 ร— 16 encoder 2e-06, heads 0.0002 all 12 6.0 h
10. weight average X_soup50_s42 = 0.5 ร— V_repair1_s42 + 0.5 ร— W_contStage4d_s42 no training
11. repair pass (mix sample + SMS category v2 + gold English PII + job-title replay + platform / duration / currency rows) Y_repair8_s42 from X_soup50_s42 36,053 1 1 ร— 16 encoder 2e-06, heads 0.0002 all 12 1.3 h
12. weight average Z_soup8_a70_s42 = 0.3 ร— X_soup50_s42 + 0.7 ร— Y_repair8_s42 no training
13. repair pass (mix sample + SMS category v2 + relations_r15 + gold English PII + job-title replay + platform / duration / currency rows) R15_C2_s42 from Z_soup8_a70_s42 52,056 1 1 ร— 16 encoder 5e-06, heads 0.0002 all 12 1.4 h
14. weight average R15_C2_a50_s42 = 0.5 ร— Z_soup8_a70_s42 + 0.5 ร— R15_C2_s42 no training

Full fine-tune (no LoRA) with the embeddings frozen in every run. The earlier runs also froze the first four encoder layers; the later ones train all twelve, because dialect is a lexical task and its head did not train with the lower layers frozen. Training ran in fp32 (bf16 autocast overflows this model's boundary head) with a linear schedule and 10 % warm-up. A classification stage asks the classification tasks alone at a real encoder step; the full-mix pass that follows trains everything together at a small step, and the release is the checkpoint that passes the retention gate against the base and the Saudi / Arabic guard. A weight average is the element-wise mean of two checkpoints that were trained from the same ancestor on overlapping data; it is scored and gated like any trained checkpoint. From this release on the English PII slice is trained with the gold of that dataset's train split: its score shows a skill of the model, and no longer what was kept from the base model. The other retention slices keep that role. How this release was picked: the rule written before training named four checkpoints (two repair passes and their 0.7 averages with the previous release). Each scored about 0.009 lower than the previous release on the entities of the SMS gold, so none was taken. The 0.5 average was tried after seeing that. It is level with or better than the previous release on every slice of the same rule, and its result should be read with that order of events in mind.

Intended use and limitations

Built for Arabic text analytics on Saudi customer-service, messaging, social and official-document text: PII detection and redaction, fraud / advertisement triage of SMS, sentiment / dialect tagging, pulling structured records out of messages, and light knowledge-graph population.

  • Mentions are whole words. A prefix written attached to a name (ยซูˆููŠุตู„ยป, ยซุจุงู„ุฑูŠุงุถยป) is part of the mention; strip it downstream if you need the bare name.
  • SMS category. The labels follow one written rubric (fraud = a scam attempt or part of one; ads = a commercial offer with no clear deception; normal = everything else). Truncated previews of 60 characters are often undecidable even for a person; treat low-confidence answers as "needs review". For the highest accuracy run the dedicated classifier next to the model and send disagreements to a person.
  • Dialect is the hardest classification task: tweet-level dialect labels are noisy and Gulf, Levantine and standard Arabic share most short sentences. Read the per-class recall in evaluation.json before relying on it.
  • Relation predicates come from Wikipedia / Wikidata (ุงู„ู…ู‡ู†ุฉ, ุงู„ุนุงุตู…ุฉ, ุงู„ุฒูˆุฌ). Domain relations work zero-shot but are not what the head was tuned on.
  • Several records of one name from one text is the weakest shape (section 7).
  • Label conventions. ู…ูˆู‚ุน ุฅู„ูƒุชุฑูˆู†ูŠ / website is a URL or a domain, ูˆู‚ุช / time a clock time and ู…ุจู„ุบ ู…ุงู„ูŠ / money an amount with its currency, as in the Saudi gold sets. Three other things have labels of their own, trained in this release: ู…ู†ุตุฉ / platform for the name of an app or online service (ยซุชูˆูŠุชุฑยป, ยซุฃุจุดุฑยป), ู…ุฏุฉ / duration for a number with a unit of time (ยซ30 ุฏู‚ูŠู‚ุฉยป, ยซูŠูˆู…ูŠู†ยป) and ุนู…ู„ุฉ / currency for a currency named without an amount (ยซุงู„ุฏูˆู„ุงุฑยป). They were trained on weakly labelled public text: a company named as a company (ยซุดุฑูƒุฉ ุบูˆุบู„ยป) and a length of time without a number (ยซุจุนุฏ ุฃุณุจูˆุนยป) are not covered. A standalone now-word (ยซุงู„ูŠูˆู…ยป, ยซุงู„ู„ูŠู„ุฉยป, ยซุงู„ุขู†ยป) is not a date; ยซุฃู…ุณยป and ยซุจูƒุฑุฉยป are.
  • Scanned documents. The model reads what the OCR returns. The stock Tesseract Arabic model has no output characters for the Arabic-Indic digits ูข-ูฉ, the Arabic comma or ูช, so dates, identity numbers and amounts written with them never reach the model; use an OCR model that has them (fine-tuning Tesseract for 13 extra characters was enough here: 1 -> 304 of 334 such mentions readable). Tesseract also reads ordinary 10-16 pt print best when the page is rendered near 150 dpi, not 300.
  • PDF tables. A PDF text layer can fuse neighbouring table cells (ยซ1010584732ุฑู‚ู… ุงู„ุณุฌู„ยป). The model returns whole whitespace tokens, so separate such tokens before calling it.
  • Structured extraction is extractive. A returned value that is not a substring of the input is a hallucination; check in production.
  • Not a replacement for a rules layer on identifiers: pair the ุฑู‚ู… ุงู„ู‡ูˆูŠุฉ ุงู„ูˆุทู†ูŠุฉ and ุฑู‚ู… ุฌูˆุงู„ types with a regex validator (Arabic-Indic digits included).
  • The real SMS used in training contain personal identifiers and are not published; the model only saw them.

Files

file purpose
model.safetensors, config.json, encoder_config/ weights and architecture
tokenizer.json, tokenizer_config.json, special_tokens_map.json mDeBERTa tokenizer
evaluation.json notebook 20's report: every before / after number on this card
retention_and_guard_gate.json the release gate (retention vs the base, Saudi / Arabic guard)
mix_manifest.json, pins.yaml training recipe, block sizes, pinned decoding and base revision
inference_config.json entity labels and the decoding threshold, task names in both languages, relation types, benchmark numbers
scam_type/ the companion scam-type classifier: scam_type.npz (n-grams, weights, coefficients), scam_type.py (numpy loader), evaluation.json, reference.json (invented messages with the expected answers)

Earlier checkpoint in this repository. Until 26 November 2026 this repository held the round-14 checkpoint (tag r14; the round-2 checkpoint is at tag r2). It is still there under its revision: AutoExtractor.from_pretrained("Elafnawaf/gliner2-arabic-saudi", revision="25f8468955cdb8781fd21d4441d6e7b9c6300c5f").

Credits

GLiNER2 by Fastino AI (fastino/gliner2.5-multi-v1, Apache-2.0). Data: WikiANN (Pan et al.), IAHLT Arabic NER, Wojood (Jarrar et al.), ShamNER, ArSarcasm (Abu Farha & Magdy), ArSAS (Elmadany et al.), SANAD (Einea et al.), IADD (Zahir), REDFM / SREDFM (Huguet Cabot et al.), and the English texts of PII Detection Multisource EN + Saudi/Arabic (K. Alharbi, CC BY 4.0), used without their annotations: the base model labels them for the replay blocks. Licence of this checkpoint follows the most restrictive source, CC BY-SA 4.0.

Downloads last month
59
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/gliner2-arabic-saudi

Finetuned
(21)
this model

Datasets used to train Elafnawaf/gliner2-arabic-saudi