GLiNER2 Arabic Multi-Task โ€” entities, classification, structured records, relations

One encoder, four heads, all fine-tuned for 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 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. Half of the training examples carried an Arabic schema (ุงู„ู…ุดุงุนุฑ โ†’ ุฅูŠุฌุงุจูŠ / ุณู„ุจูŠ / ู…ุญุงูŠุฏ) and half 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.

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-multitask")

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", "ุฑู‚ู… ุฌูˆุงู„ / mobile number"])
# {'entities': {'ู…ู†ุธู…ุฉ / organization': ['ุฃุฑุงู…ูƒูˆ ุงู„ุณุนูˆุฏูŠุฉ'],
#               'ู…ูƒุงู† / place': ['ุงู„ุธู‡ุฑุงู†'],
#               'ู…ุจู„ุบ ู…ุงู„ูŠ / money': ['121 ู…ู„ูŠุงุฑ ุฏูˆู„ุงุฑ'],
#               'ุฑู‚ู… ุฌูˆุงู„ / 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.866, 'start': 11, 'end': 26}]}}

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.

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.998}}

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

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. Richer schemas from the gliner2 API (ChoiceField for a classification inside a record, list-valued fields, several records of the same name under an occurrence_policy) are supported and were part of training.

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:

from gliner2 import Schema

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',
#                    'ุฑู‚ู… ุฌูˆุงู„ / mobile number', 'ุฑู‚ู… ุงู„ู‡ูˆูŠุฉ ุงู„ูˆุทู†ูŠุฉ / national id number']}

On held-out data this returns the exact label set 77% of the time (per-label F1 0.94). It is a cheap first pass before running the entity head on a large corpus.

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. Together they give you an extracted record plus a decision in one call, which is the shape a PDPL redaction log needs.

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

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

Read the last line carefully. On the held-out set the record-type field is right 96% of the time and the personal-data flag 100%, but on fresh support text the flag under-fires, as above, where an ID number is present and the answer should be ู†ุนู…. Do not let the model's flag be the only gate: derive it from the extracted fields (bool(record["ุดุฎุต / person"] or record["ุฑู‚ู… ุงู„ู‡ูˆูŠุฉ ุงู„ูˆุทู†ูŠุฉ / national id number"])) and keep the choice field as a second opinion.

7 ยท Several records of one name from one text

Records were trained with mode/occurrence_policy metadata so that one text can yield a list of records. This is the weakest shape in the current checkpoint:

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

model.extract(meeting, Schema().structure("ู…ุดุงุฑูƒ", mode="natural", occurrence_policy="all")
                                .field("ุงู„ุงุณู…").field("ุงู„ุฌู‡ุฉ"))
# {'ู…ุดุงุฑูƒ': [{'ุงู„ุงุณู…': 'ูู‡ุฏ ุงู„ุนุชูŠุจูŠ', 'ุงู„ุฌู‡ุฉ': ['ุฃุฑุงู…ูƒูˆ']}]}      <- one of three

Held-out pair F1 is 0.68 with recall as the limit (about one record returned per two or three in gold). When you need every participant, ask the entity head, which does return 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': {'ุฑู‚ู… ู…ุฑุฌุนูŠ': ['1098765432'], 'ู…ุจู„ุบ': ['450 ุฑูŠุงู„ุงู‹']}}

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

Relation descriptions are accepted by the API but did not help this checkpoint on business relations (ุดุฑุงูƒุฉ, ุงุณุชุญูˆุงุฐ came back empty); the relation head knows the 32 Wikidata predicates listed below.

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, threshold=0.3)
# [{'entities': {'ุดุฎุต / person': ['ุณุนูˆุฏ ุงู„ุฏูˆุณุฑูŠ'], 'ู…ู†ุธู…ุฉ / organization': []}},
#  {'entities': {'ุดุฎุต / person': ['ูู‡ุฏ ุงู„ุนุชูŠุจูŠ', 'ุฑูŠู… ุงู„ุดู‡ุฑูŠ'],
#                'ู…ู†ุธู…ุฉ / organization': ['ุฃุฑุงู…ูƒูˆ', 'ุฌุงู…ุนุฉ ุงู„ู…ู„ูƒ ุณุนูˆุฏ', 'ู‡ูŠุฆุฉ ุงู„ุงุชุตุงู„ุงุช']}}]

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

Batching sorts by length internally; on one L4 the entity head scores about 200 sentences per second at batch 8.

threshold (default 0.5) is accepted by every call; lower it for recall, raise it for precision. Per-label entity thresholds tuned on the dev set are in inference_config.json, together with every task name and label set the model was trained on, in both languages.

What it was trained to answer

Entity types (17)

ุชุงุฑูŠุฎ / date, ุชุฑุชูŠุจ / ordinal, ุฑู‚ู… ุงู„ู‡ูˆูŠุฉ ุงู„ูˆุทู†ูŠุฉ / national id number, ุฑู‚ู… ุฌูˆุงู„ / mobile number, ุดุฎุต / person, ุนุฏุฏ / cardinal number, ุนู…ู„ุฉ / currency, ุนู†ูˆุงู† / address, ูƒู…ูŠุฉ / quantity, ู…ุจู„ุบ ู…ุงู„ูŠ / money, ู…ุทุงุฑ / airport, ู…ูƒุงู† / place, ู…ู†ุธู…ุฉ / organization, ู…ูˆู‚ุน ุฅู„ูƒุชุฑูˆู†ูŠ / website, ู†ุณุจุฉ ู…ุฆูˆูŠุฉ / percentage, ูˆุญุฏุฉ ู‚ูŠุงุณ / unit of measurement, ูˆู‚ุช / time

Classification tasks

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

Relation types (32, Wikidata predicates from REDFM)

English Arabic
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 ุงู„ุฒูˆุฌ

Results

Measured on held-out Arabic before and after the multi-task fine-tune. "Before" is the base checkpoint fastino/gliner2.5-multi-v1 answering the same Arabic schemas.

head metric before after
entities span-exact micro-F1 (1,500 test sentences, 17 types) 0.352 0.693
structure field-level F1 (600 held-out records) 0.242 0.791
relations triple F1 on REDFM Arabic, human-revised (344 sentences) 0.171 0.406

Classification accuracy (600 held-out examples, per task)

task before after
dialect 0.265 0.618
entity types present 0.438 0.625
sarcasm 0.264 0.806
sentiment 0.588 0.758
speech act 0.168 0.814
topic 0.657 0.971
ุฃู†ูˆุงุน ุงู„ูƒูŠุงู†ุงุช 0.538 0.692
ุงู„ุณุฎุฑูŠุฉ 0.712 0.797
ุงู„ู„ู‡ุฌุฉ 0.222 0.571
ุงู„ู…ุดุงุนุฑ 0.639 0.732
ุงู„ู…ูˆุถูˆุน 0.768 0.970
ู†ูˆุน ุงู„ุฎุทุงุจ 0.319 0.782

Relations are scored on Babelscape/REDFM Arabic, which is human-revised and has no Arabic train split. Training used Babelscape/SREDFM Arabic, which is automatically annotated โ€” so the relation number is measured against people, not against the annotator the model learned from. evaluation.json in this repo holds the full gate report.

The four extra shapes were scored separately on held-out dev examples (before โ†’ after): multi-label per-label F1 0.58 โ†’ 0.94, choice-field record type 0.01 โ†’ 0.96 and personal-data flag 0.04 โ†’ 1.00, several-records-per-text pair F1 0.53 โ†’ 0.68, named-role relations triple F1 0.32 โ†’ 0.51 (identical when asked as plain head/tail, so treat it as an ordinary relation result).

Training data

All supervision is public and Arabic. Each source is capped so that no head dominates the summed loss; the caps below are the number of examples drawn per source.

source used for examples link
WikiANN + IAHLT + Wojood sample + synthetic Saudi PII entities 40,000 entities
ArSarcasm sentiment, sarcasm, dialect 12,000 sarcasm
ArSAS speech act, sentiment 14,000 arsas
SANAD news topic 14,000 sanad
SREDFM (ar) relations + free structure records 22,000 sredfm
entity gold โ†’ records structured extraction 14,000 โ€”
derived multi-label classification 10,000 โ€”
derived records with ChoiceField / list fields 14,000 โ€”
derived several records per text 7,000 โ€”
derived relations with named roles 7,000 โ€”

Entity corpus (64,365 MSA sentences, converted to character offsets, 17 bilingual labels): wikiann 32,600, iahlt-mafat 26,449, synthetic-pii 4,380, wojood-sample 936. The synthetic PII sentences add Saudi national IDs, mobile numbers, addresses and websites, which none of the public corpora annotate.

The ner_struct, multilabel, rich_records, multi_instance and named_roles sets are derived from the entity gold spans and from SREDFM's typed entities: the same text re-expressed as a record, a multi-label task, a record with a ChoiceField, several records of one name, and relations with named roles. They teach capabilities the plain form does not exercise. Schema language was Arabic for 50% of examples and English for the rest, always with the same gold answer.

Training details

base checkpoint fastino/gliner2.5-multi-v1
trainable parameters 287,355,159 (full fine-tune, no LoRA)
examples 113,003 train / 7,215 dev after dropping 33 examples longer than 384 tokens
epochs 2 (14,126 optimizer steps)
batch 2 ร— gradient accumulation 8 = effective 16
learning rates encoder 1e-5, task heads 5e-4, linear schedule, 10% warm-up
regularisation weight decay 0.01, gradient clipping 1.0
precision fp32 โ€” with bf16 autocast this model's boundary head overflows within ~300 steps and every weight becomes NaN; fp32 was both stable and faster on an L4
hardware 1 ร— NVIDIA L4 (24 GB), 4.6 h
checkpoint selection lowest dev loss (evaluated every 1,766 steps)

Intended use and limitations

Built for Arabic text analytics on customer-service, social and news text: PII detection and redaction, intent/sentiment/dialect tagging, pulling structured records out of messages, and light knowledge-graph population.

  • Dialects. The entity corpus is Modern Standard Arabic. Dialect supervision comes only from ArSarcasm's five-way dialect label; Gulf coverage beyond that is untested.
  • Relation predicates come from Wikipedia/Wikidata (ุงู„ู…ู‡ู†ุฉ, ุงู„ุนุงุตู…ุฉ, ุงู„ุฒูˆุฌ). They are not domain relations for customer service or media monitoring; asking for such types works zero-shot but is not what the head was tuned on.
  • Ask for dates, amounts and percentages in short type lists. On natural prose the entity head drops ุชุงุฑูŠุฎ / date, ู…ุจู„ุบ ู…ุงู„ูŠ / money and ู†ุณุจุฉ ู…ุฆูˆูŠุฉ / percentage when they are requested together with the full 8-type list, yet finds them (0.7โ€“0.9 confidence) when asked with three or four types. Training passed all 17 labels as explicit negatives on WikiANN/IAHLT sentences, which taught "long list + prose = no numbers"; those types are also 57โ€“100% synthetic in training, so their held-out scores measure the template. Until the next round, call the entity head twice: once for person/organization/place, once for the numeric types.
  • Structured extraction is extractive. A returned value that is not a substring of the input is a hallucination; the evaluation counted zero on the held-out set, but check in production.
  • Classification collapse and overconfidence. Dialect, sarcasm and sentiment lean heavily on the majority label (ูุตุญู‰, ุบูŠุฑ ุณุงุฎุฑ, ู…ุญุงูŠุฏ), and the reported confidence is near 1.0 even when wrong, so it is not a usable signal for those tasks. Topic, speech act and message type are reliable.
  • Not a replacement for a rules layer on identifiers: pair the ุฑู‚ู… ุงู„ู‡ูˆูŠุฉ ุงู„ูˆุทู†ูŠุฉ and ุฑู‚ู… ุฌูˆุงู„ types with a regex validator (Arabic-Indic digits included).

Files

file purpose
model.safetensors, config.json, encoder_config/ weights and architecture
tokenizer.json, tokenizer_config.json, special_tokens_map.json mDeBERTa tokenizer
inference_config.json every trained task name / label set (ar + en), per-label entity thresholds, normaliser note
evaluation.json the before/after gate report the numbers above come from

Credits

GLiNER2 by Fastino AI (fastino/gliner2.5-multi-v1, Apache-2.0). Data: WikiANN (Pan et al.), IAHLT Arabic NER, ArSarcasm (Abu Farha & Magdy), ArSAS (Elmadany et al.), SANAD (Einea et al.), REDFM / SREDFM (Huguet Cabot et al.). Licence of this checkpoint follows the most restrictive source, CC BY-SA 4.0.

Downloads last month
-
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-multitask

Finetuned
(2)
this model

Datasets used to train Elafnawaf/gliner2-arabic-multitask