Instructions to use Elafnawaf/gliner2-arabic-saudi with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- GLiNER2
How to use Elafnawaf/gliner2-arabic-saudi with GLiNER2:
from gliner2 import AutoExtractor extractor = AutoExtractor.from_pretrained("Elafnawaf/gliner2-arabic-saudi") # Extract entities text = "Apple CEO Tim Cook announced iPhone 15 in Cupertino yesterday." result = extractor.extract_entities(text, ["company", "person", "product", "location"]) print(result) - Notebooks
- Google Colab
- Kaggle
- GLiNER2 Arabic ยท Saudi โ entities, classification, structured records, relations
- Quick start
- Normalise first โ this is not optional
- 1 ยท Entities
- 2 ยท Classification
- 3 ยท Structured records (JSON)
- 4 ยท Relations
- Everything at once
- 5 ยท Multi-label classification
- 6 ยท Records with choice fields and list fields
- 7 ยท Several records of one name from one text
- 8 ยท New labels, explained rather than named
- 9 ยท Batches and long documents
- What it was trained to answer
- Results
- Scam type of a fraud message: a companion classifier
- Training data
- Training details
- Intended use and limitations
- Files
- Credits
- Quick start
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.
bandishighfrom 0.8,mediumfrom 0.5,lowunder that; the table below says how often each is right. readreturnsNonewhen 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.jsonbefore 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.
ู ููุน ุฅููุชุฑููู / websiteis a URL or a domain,ููุช / timea clock time andู ุจูุบ ู ุงูู / moneyan amount with its currency, as in the Saudi gold sets. Three other things have labels of their own, trained in this release:ู ูุตุฉ / platformfor the name of an app or online service (ยซุชููุชุฑยป, ยซุฃุจุดุฑยป),ู ุฏุฉ / durationfor a number with a unit of time (ยซ30 ุฏูููุฉยป, ยซููู ููยป) andุนู ูุฉ / currencyfor 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
Model tree for Elafnawaf/gliner2-arabic-saudi
Base model
fastino/gliner2.5-multi-v1