GLiNER2.5 base-v1 (ONNX)

ONNX export of fastino/gliner2.5-base-v1 β€” the boundary architecture (BoundaryExtractor), which predicts where entities start and end instead of scoring a fixed-width span grid.

This is the English, deberta-v3-base member of the GLiNER2.5 family (194M parameters). Its multilingual sibling is exported at DanKau/g2.5-multi-v1-onnx.

Exported for SecuPi's unstructured AI service (SPAI), which runs it through ONNX Runtime from Java. Published so that service can fetch it without a PyTorch dependency; anyone else is welcome to use it under the same licence as the base model.

Files

file what it is
onnx/encoder.onnx deberta-v3-base encoder over the schema prompt + text
onnx/boundary.onnx the whole boundary head: boundary encoder, query head, candidate pool and pair scorer
onnx/classifier.onnx classification head, Linear(768β†’1536) β†’ ReLU β†’ Linear(1536β†’1)
gliner2_config.json, config.json special-token ids and ONNX file map
tokenizer.json, tokenizer_config.json tokenizer

The special-token ids are not the same as the multilingual export's. This checkpoint's are 128001–128010 (deberta-v3-base); g2.5-multi-v1's are 250102–250111 (mDeBERTa). Read them from gliner2_config.json rather than hard-coding either set β€” the wrong ids still produce a well-formed prompt.

How to run it

The prompt is the GLiNER2 one:

( [P] entities ( [E] label … ) ) [SEP_TEXT] <lowercased text>
  1. Run encoder.onnx over that.

  2. query_states = hidden states at the [E] positions β†’ [1, n_labels, 768]. token_states = hidden state at the first sub-token of each word β†’ [1, n_words, 768] (token_pooling: "first" β€” the head sees words, not sub-tokens).

  3. Run onnx/boundary.onnx:

    input shape
    token_states [1, n_words, 768]
    text_mask [1, n_words] bool
    query_states [1, n_labels, 768]
    query_mask [1, n_labels] bool
    output shape
    pair_logits [1, n_labels, 192]
    candidate_indices [1, n_labels, 192, 2]
    candidate_valid [1, n_labels, 192] bool
    null_logits [1, n_labels]
  4. A candidate is an entity when candidate_valid and sigmoid(pair_logit) >= threshold. Its indices are word boundaries with an exclusive end: (1, 3) means words[1:3].

  5. The pool intentionally contains overlapping spans of the same label. Keep the highest-scoring and drop anything overlapping it, per label, to match the reference implementation.

For classification the prompt swaps two tokens β€” ( [P] category ( [L] label … ) ) [SEP_TEXT] … β€” and classifier.onnx scores the hidden state at each [L] marker, one call for the whole label set (hidden_state [n,768] -> logit [n,1]).

A runnable version of the extraction path, which diffs its output against native PyTorch, ships with the export tooling as verify_gliner25_export.py.

Export notes

Two source-level obstacles are worked around at export time, identically to the multilingual export:

  • torch.sort(..., stable=True) lowers to aten::sort's out-variant, which has no ONNX symbolic. Stability is preserved rather than dropped where it is load-bearing β€” the candidate dedup sorts integer keys because they contain duplicates β€” by folding the position into the key.
  • torch.eye(n, dtype=torch.bool) becomes EyeLike, for which ONNX Runtime has no boolean kernel; an arange comparison produces the same mask.

Verified against native PyTorch

Identical sets of valid candidates (0 missing, 0 extra) at every shape tried, traced on 63 words Γ— 6 labels and checked at 9Γ—3, 26Γ—4 and 13Γ—2:

check max|diff|
sort/eye patch vs unpatched PyTorch 1.91e-06
ONNX vs PyTorch, traced sample 1.72e-05
ONNX vs PyTorch, other shapes ≀ 1.72e-05

Both heads are additionally replayed from Java against native-PyTorch fixtures β€” 12 extraction cases and 8 classification cases β€” by GB25NerFixtureTest and GB25ClassificationFixtureTest.

Provenance

Exported from fastino/gliner2.5-base-v1 at revision 72ac19b486cd4557424c8d61114e7530c243e9b0, with gliner2==2.0.0, transformers==5.16.1, torch==2.13.0, opset 18.

Licence

Apache 2.0, inherited from the base model. This repository redistributes the same weights in a different serialisation; all credit for the model belongs to Fastino.

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for DanKau/gliner2.5-base-v1-onnx

Quantized
(2)
this model