Downloads · 30 days
174
44% of all-time downloads
DanKau/gliner2.5-base-v1-onnx
gliner2.5-base-v1-onnx is a text classification model from DanKau. Use it when you need a label for a piece of text. It is set up for onnx. The card lists the license as apache-2.0.
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.
Downloads · 30 days
174
44% of all-time downloads
All-time downloads
394
Public
Repo size
746 MB
Likes
0
Public
Click a slice to open those files.
.onnx746 MB · 99%
From the Hugging Face model README
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.
| 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.
The prompt is the GLiNER2 one:
( [P] entities ( [E] label … ) ) [SEP_TEXT] <lowercased text>
Run encoder.onnx over that.
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).
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] |
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].
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.
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.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.
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.
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.