Token Classification
ONNX
GLiNER2
English
onnxruntime
named-entity-recognition
zero-shot
natural-language-inference
deberta-v3
on-device
iris
Instructions to use iris-hq/iris-names with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- GLiNER2
How to use iris-hq/iris-names with GLiNER2:
from gliner2 import AutoExtractor extractor = AutoExtractor.from_pretrained("iris-hq/iris-names") # 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
Iris name models 1: GLiNER 2.5 Base (ONNX, entity path) and DeBERTa-v3 NLI (Q4F16)
Browse files- .gitattributes +2 -0
- LICENSES.md +62 -0
- README.md +190 -0
- deberta-nli/config.json +44 -0
- deberta-nli/model.onnx +3 -0
- deberta-nli/model.onnx_data +3 -0
- deberta-nli/tokenizer.json +0 -0
- deberta-nli/tokenizer_config.json +1 -0
- gliner25/boundary_head.onnx +3 -0
- gliner25/config.json +134 -0
- gliner25/encoder/model.onnx +3 -0
- gliner25/encoder/model.onnx_data +3 -0
- gliner25/tokenizer.json +0 -0
- gliner25/tokenizer_config.json +1 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
deberta-nli/model.onnx_data filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
gliner25/encoder/model.onnx_data filter=lfs diff=lfs merge=lfs -text
|
LICENSES.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Third-Party Model Licenses (`iris-names-1`)
|
| 2 |
+
|
| 3 |
+
## 1. GLiNER 2.5 Base (`gliner25/`)
|
| 4 |
+
|
| 5 |
+
- **Upstream Repository:** [`fastino/gliner2.5-base-v1`](https://huggingface.co/fastino/gliner2.5-base-v1)
|
| 6 |
+
- **Pinned Revision:** `07d99c0ba5d15cb3b24e0a236fa99bdd4ef87a5c`
|
| 7 |
+
- **Author:** Fastino AI (`fastino-ai/GLiNER2`)
|
| 8 |
+
- **Base Encoder:** [`microsoft/deberta-v3-base`](https://huggingface.co/microsoft/deberta-v3-base) (MIT License)
|
| 9 |
+
- **License:** Apache License 2.0
|
| 10 |
+
|
| 11 |
+
```text
|
| 12 |
+
Copyright 2025-2026 Fastino AI
|
| 13 |
+
|
| 14 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 15 |
+
you may not use this file except in compliance with the License.
|
| 16 |
+
You may obtain a copy of the License at
|
| 17 |
+
|
| 18 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 19 |
+
|
| 20 |
+
Unless required by applicable law or agreed to in writing, software
|
| 21 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 22 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 23 |
+
See the License for the specific language governing permissions and
|
| 24 |
+
limitations under the License.
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
## 2. DeBERTa-v3 Base MNLI-FEVER-ANLI (`deberta-nli/`)
|
| 30 |
+
|
| 31 |
+
- **Upstream ONNX Port:** [`Xenova/DeBERTa-v3-base-mnli-fever-anli`](https://huggingface.co/Xenova/DeBERTa-v3-base-mnli-fever-anli) (`onnx/model_q4f16.onnx`, repackaged with external data)
|
| 32 |
+
- **Pinned Revision (Xenova):** `72a1ce83a0144efaf828b3c3844320a61197a53d`
|
| 33 |
+
- **Upstream PyTorch Checkpoint:** [`MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli`](https://huggingface.co/MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli) (revision `ef67fd0301dd3eebc5eed7fd3fae0ef2fc0bbd0a`)
|
| 34 |
+
- **Author:** Moritz Laurer (ONNX conversion and Q4F16 quantization by Joshua Lochner / Xenova; base model `microsoft/deberta-v3-base` by Microsoft)
|
| 35 |
+
- **Model License:** MIT License
|
| 36 |
+
- **Training Data Notice (ANLI):** This checkpoint was fine-tuned on MultiNLI, FEVER-NLI, and Adversarial NLI (ANLI). The ANLI dataset is licensed under **CC BY-NC 4.0** (Creative Commons Attribution-NonCommercial 4.0 International; Nie et al., 2020).
|
| 37 |
+
|
| 38 |
+
```text
|
| 39 |
+
MIT License
|
| 40 |
+
|
| 41 |
+
Copyright (c) Microsoft Corporation (DeBERTa-v3 base architecture and weights)
|
| 42 |
+
Copyright (c) Moritz Laurer (MNLI/FEVER/ANLI fine-tuned checkpoint)
|
| 43 |
+
Copyright (c) Joshua Lochner / Xenova (ONNX export and Q4F16 quantization)
|
| 44 |
+
|
| 45 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 46 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 47 |
+
in the Software without restriction, including without limitation the rights
|
| 48 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 49 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 50 |
+
furnished to do so, subject to the following conditions:
|
| 51 |
+
|
| 52 |
+
The above copyright notice and this permission notice shall be included in all
|
| 53 |
+
copies or substantial portions of the Software.
|
| 54 |
+
|
| 55 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 56 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 57 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 58 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 59 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 60 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 61 |
+
SOFTWARE.
|
| 62 |
+
```
|
README.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: apache-2.0-and-mit
|
| 4 |
+
license_link: https://huggingface.co/iris-hq/iris-names/blob/main/LICENSES.md
|
| 5 |
+
library_name: onnx
|
| 6 |
+
tags:
|
| 7 |
+
- onnx
|
| 8 |
+
- named-entity-recognition
|
| 9 |
+
- natural-language-inference
|
| 10 |
+
- iris
|
| 11 |
+
base_model:
|
| 12 |
+
- fastino/gliner2.5-base-v1
|
| 13 |
+
- MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# Iris name models
|
| 17 |
+
|
| 18 |
+
The local name models Iris downloads when a person chooses Download in Settings (Names only). Iris pins one commit of this repository and checks every file's size and SHA-256 before use; no note text is ever sent here.
|
| 19 |
+
|
| 20 |
+
- `gliner25/`: GLiNER 2.5 Base (fastino/gliner2.5-base-v1 @ 07d99c0ba5d15cb3b24e0a236fa99bdd4ef87a5c), entity span path only, exported to ONNX (FP32 encoder with external data, FP32 boundary head). Apache-2.0.
|
| 21 |
+
- `deberta-nli/`: DeBERTa-v3 Base MNLI/FEVER/ANLI (MoritzLaurer, via Xenova @ 72a1ce83a0144efaf828b3c3844320a61197a53d), Q4F16 repackaged with external data. MIT; trained partly on ANLI (CC BY-NC 4.0).
|
| 22 |
+
- Tokenizers are rewritten for swift-transformers 1.4.0 (XLMRobertaTokenizer class, added tokens appended to the Unigram vocab); token IDs are unchanged.
|
| 23 |
+
|
| 24 |
+
See LICENSES.md for full notices. The export and repackaging recipe follows.
|
| 25 |
+
|
| 26 |
+
# `iris-names-1` Model Bundle Recipe
|
| 27 |
+
|
| 28 |
+
This directory contains the reproducible offline export, repackaging, and tokenizer-rewrite recipe for the `iris-names-1` ONNX bundle used by Iris's native `Names only` extraction (`namesFind` + `namesCheck` in `iris-voice-helper`).
|
| 29 |
+
|
| 30 |
+
## Bundle Layout
|
| 31 |
+
|
| 32 |
+
```text
|
| 33 |
+
iris-names-1/
|
| 34 |
+
gliner25/
|
| 35 |
+
encoder/
|
| 36 |
+
model.onnx
|
| 37 |
+
model.onnx_data
|
| 38 |
+
boundary_head.onnx
|
| 39 |
+
config.json
|
| 40 |
+
tokenizer.json
|
| 41 |
+
tokenizer_config.json
|
| 42 |
+
deberta-nli/
|
| 43 |
+
model.onnx
|
| 44 |
+
model.onnx_data
|
| 45 |
+
config.json
|
| 46 |
+
tokenizer.json
|
| 47 |
+
tokenizer_config.json
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
## Pinned Upstream Sources & Versions
|
| 51 |
+
|
| 52 |
+
- **Stage 1 (GLiNER 2.5 Base):**
|
| 53 |
+
- Hugging Face repository: `fastino/gliner2.5-base-v1`
|
| 54 |
+
- Pinned commit SHA: `07d99c0ba5d15cb3b24e0a236fa99bdd4ef87a5c`
|
| 55 |
+
- License: Apache-2.0
|
| 56 |
+
- **Stage 2 (DeBERTa-v3 Base MNLI/FEVER/ANLI Q4F16):**
|
| 57 |
+
- Hugging Face repository: `Xenova/DeBERTa-v3-base-mnli-fever-anli` (`onnx/model_q4f16.onnx` + tokenizer/config files)
|
| 58 |
+
- Pinned commit SHA: `72a1ce83a0144efaf828b3c3844320a61197a53d`
|
| 59 |
+
- Upstream FP32 source: `MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli` (commit `ef67fd0301dd3eebc5eed7fd3fae0ef2fc0bbd0a`)
|
| 60 |
+
- License: MIT (note: ANLI training dataset is CC BY-NC 4.0; see `LICENSES.md`)
|
| 61 |
+
- **Python Export & Reference Environment:**
|
| 62 |
+
- Python `3.13.11`
|
| 63 |
+
- `gliner2==2.1.0`
|
| 64 |
+
- `torch==2.15.0` (CPU)
|
| 65 |
+
- `transformers==4.57.6`
|
| 66 |
+
- `tokenizers==0.22.2`
|
| 67 |
+
- `onnx==1.23.2`, `onnxscript==0.7.2`
|
| 68 |
+
- `onnxruntime==1.23.2`
|
| 69 |
+
|
| 70 |
+
## Three Required Export Patches Against `gliner2==2.1.0`
|
| 71 |
+
|
| 72 |
+
Exporting `fastino/gliner2.5-base-v1`'s `BoundaryHead` (`candidate_pool="shared"`) to ONNX (opset 18, `dynamo=False`) and running it in ONNX Runtime 1.23.2 across arbitrary dynamic word lengths `L >= 1` requires three patches:
|
| 73 |
+
|
| 74 |
+
1. **TorchScript ONNX symbolic for `aten::sort` and `aten::argsort` with `stable=True`:**
|
| 75 |
+
PyTorch's 4-argument `aten::sort.stable(self, stable, dim, descending)` overload passes `descending` as the 4th positional argument (`out`) to `torch.onnx._internal.torchscript_exporter.symbolic_opset11.sort(g, self, dim, descending, out=None)`, raising `OnnxExporterError: Unsupported: ONNX export of operator Sort, Out parameter is not supported`. Registering custom symbolics for `aten::sort` and `aten::argsort` at opset 11 unpacks `(self, stable, dim, descending)` and delegates to `symbolic_helper._sort_helper(g, self, dim, descending=descending, out=None)` (which emits ONNX `TopK(..., sorted=1)`).
|
| 76 |
+
2. **Replace `torch.eye(n, dtype=torch.bool)` and in-place slice mutations in `gliner2/models/boundary/encoding.py`:**
|
| 77 |
+
`torch.eye(n, dtype=torch.bool)` exports an ONNX `EyeLike` node with `dtype=bool`, which fails at session initialization in ONNX Runtime 1.23.2 (`NOT_IMPLEMENTED : Could not find an implementation for EyeLike(9) node`). Replacing `diagonal = torch.eye(n, dtype=torch.bool, device=states.device)` with `diagonal = positions.view(n, 1) == positions.view(1, n)` emits an `Equal` node on `int64` coordinates. Replacing the in-place slice assignments in `shift_left_with_bos` and `shift_right_with_eos` with `torch.cat` and `torch.where` removes graph input mutation warnings.
|
| 78 |
+
3. **Right-pad boundary logits to `k=32` in `select_top_boundaries` (`gliner2/models/boundary/proposal.py`):**
|
| 79 |
+
In eager mode, `k = min(k, n)` where `n = L + 1` is traced as a Python constant (`32` when exported at `L = 40`). On short sentences with `L < 31` words (`n < 32`), an unpadded slice produces `< 32` top boundaries and fails in `DocumentCandidatePool.forward`'s `.expand(b, 32, 32)`. Right-padding `masked` with `k` columns of `MASK_LOGIT` (`-1e4`) and `valid_mask` with `k` columns of `False` before `torch.topk(..., k=k, dim=-1, largest=True, sorted=True)` guarantees a static `32 × 32 = 1024 >= 192` candidate pair grid for any `L >= 1` while masking padded slots to `(score=0, idx=0, valid=False)`, producing 100% identical candidate indices and logits to unmodified PyTorch.
|
| 80 |
+
|
| 81 |
+
### Unified Diff Against `gliner2==2.1.0`
|
| 82 |
+
|
| 83 |
+
```diff
|
| 84 |
+
--- a/gliner2/models/boundary/encoding.py
|
| 85 |
+
+++ b/gliner2/models/boundary/encoding.py
|
| 86 |
+
@@ -38,9 +38,7 @@
|
| 87 |
+
Returns:
|
| 88 |
+
[B, L + 1, H]
|
| 89 |
+
"""
|
| 90 |
+
b, l, h = text_states.shape
|
| 91 |
+
- out = torch.empty(b, l + 1, h, dtype=text_states.dtype, device=text_states.device)
|
| 92 |
+
- out[:, 0] = bos_state.to(text_states.dtype)
|
| 93 |
+
- out[:, 1:] = text_states
|
| 94 |
+
- return out
|
| 95 |
+
+ bos = bos_state.to(text_states.dtype).view(1, 1, h).expand(b, 1, h)
|
| 96 |
+
+ return torch.cat([bos, text_states], dim=1)
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def shift_right_with_eos(
|
| 100 |
+
@@ -59,13 +57,11 @@
|
| 101 |
+
Returns:
|
| 102 |
+
[B, L + 1, H]
|
| 103 |
+
"""
|
| 104 |
+
b, l, h = text_states.shape
|
| 105 |
+
- out = torch.empty(b, l + 1, h, dtype=text_states.dtype, device=text_states.device)
|
| 106 |
+
- out[:, :l] = text_states
|
| 107 |
+
- out[:, l] = eos_state.to(text_states.dtype)
|
| 108 |
+
- # Place EOS at each sample's own final boundary index n_b.
|
| 109 |
+
- eos = eos_state.to(text_states.dtype).view(1, h).expand(b, h)
|
| 110 |
+
- out[torch.arange(b, device=text_states.device), text_lengths.clamp(max=l)] = eos
|
| 111 |
+
- return out
|
| 112 |
+
+ eos = eos_state.to(text_states.dtype).view(1, 1, h).expand(b, 1, h)
|
| 113 |
+
+ padded = torch.cat([text_states, eos], dim=1)
|
| 114 |
+
+ idx = torch.arange(l + 1, device=text_states.device).unsqueeze(0)
|
| 115 |
+
+ is_eos = idx == text_lengths.clamp(max=l).unsqueeze(1)
|
| 116 |
+
+ return torch.where(is_eos.unsqueeze(-1), eos_state.to(text_states.dtype).view(1, 1, h), padded)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
class ResidualSwiGLU(nn.Module):
|
| 120 |
+
@@ -118,17 +114,20 @@
|
| 121 |
+
qkv = self.qkv_projection(self.norm(states)).view(
|
| 122 |
+
b, n, 3, self.num_heads, self.head_dim
|
| 123 |
+
)
|
| 124 |
+
- query, key, value = qkv.permute(2, 0, 3, 1, 4)
|
| 125 |
+
+ query, key, value = qkv.unbind(2)
|
| 126 |
+
+ query = query.transpose(1, 2)
|
| 127 |
+
+ key = key.transpose(1, 2)
|
| 128 |
+
+ value = value.transpose(1, 2)
|
| 129 |
+
allowed = mask.view(b, 1, 1, n).expand(b, 1, n, n)
|
| 130 |
+
+ positions = torch.arange(n, device=states.device)
|
| 131 |
+
if self.window > 0:
|
| 132 |
+
- positions = torch.arange(n, device=states.device)
|
| 133 |
+
local = (
|
| 134 |
+
positions.view(n, 1) - positions.view(1, n)
|
| 135 |
+
).abs() <= self.window
|
| 136 |
+
allowed = allowed & local.view(1, 1, n, n)
|
| 137 |
+
# Padding query rows still need one legal key to avoid NaNs.
|
| 138 |
+
- diagonal = torch.eye(n, dtype=torch.bool, device=states.device)
|
| 139 |
+
+ diagonal = positions.view(n, 1) == positions.view(1, n)
|
| 140 |
+
allowed = allowed | diagonal.view(1, 1, n, n)
|
| 141 |
+
attended = F.scaled_dot_product_attention(
|
| 142 |
+
query,
|
| 143 |
+
--- a/gliner2/models/boundary/proposal.py
|
| 144 |
+
+++ b/gliner2/models/boundary/proposal.py
|
| 145 |
+
@@ -93,13 +93,14 @@
|
| 146 |
+
Returns:
|
| 147 |
+
scores [B, Q, k], indices [B, Q, k], valid [B, Q, k].
|
| 148 |
+
"""
|
| 149 |
+
- n = logits.shape[-1]
|
| 150 |
+
- k = min(k, n)
|
| 151 |
+
+ b, q, n = logits.shape
|
| 152 |
+
floor = MASK_LOGIT
|
| 153 |
+
masked = logits.masked_fill(~valid_mask, floor)
|
| 154 |
+
- scores, idx = torch.sort(masked, dim=-1, descending=True, stable=True)
|
| 155 |
+
- scores = scores[..., :k]
|
| 156 |
+
- idx = idx[..., :k]
|
| 157 |
+
- valid = torch.gather(valid_mask, -1, idx)
|
| 158 |
+
+ pad_logits = masked.new_full((b, q, k), floor)
|
| 159 |
+
+ pad_valid = valid_mask.new_zeros((b, q, k))
|
| 160 |
+
+ masked_padded = torch.cat([masked, pad_logits], dim=-1)
|
| 161 |
+
+ valid_padded = torch.cat([valid_mask, pad_valid], dim=-1)
|
| 162 |
+
+ scores, idx = torch.topk(masked_padded, k=k, dim=-1, largest=True, sorted=True)
|
| 163 |
+
+ valid = torch.gather(valid_padded, -1, idx)
|
| 164 |
+
scores = torch.where(valid, scores, torch.zeros_like(scores))
|
| 165 |
+
idx = torch.where(valid, idx, torch.zeros_like(idx))
|
| 166 |
+
return scores, idx, valid
|
| 167 |
+
```
|
| 168 |
+
|
| 169 |
+
## Tokenizer Rewrite for `swift-transformers` 1.4.0 Compatibility
|
| 170 |
+
|
| 171 |
+
Iris's native helper uses `swift-transformers` `Tokenizers` `1.4.0` (`AutoTokenizer.from(modelFolder:)`). Stock `DebertaV2Tokenizer` configs are rejected by `swift-transformers` `1.4.0`, and class-only rewrites map added tokens (`[P]`, `[E]`, `[SEP_TEXT]`, `[MASK]`) to `<unk>` (`3`) because `UnigramTokenizer` builds its token-to-ID map solely from `model.vocab`.
|
| 172 |
+
|
| 173 |
+
For both `gliner25/` and `deberta-nli/`, `build_bundle.py` applies the proven `xlm-vocab` rewrite:
|
| 174 |
+
1. In `tokenizer_config.json`, set `"tokenizer_class": "XLMRobertaTokenizer"`.
|
| 175 |
+
2. In `tokenizer.json`, iterate over `added_tokens` sorted ascending by `id`; for each entry whose `id == len(model.vocab)`, append `[content, 0.0]` to `model.vocab`.
|
| 176 |
+
|
| 177 |
+
## Reproducing the Bundle and Fixtures
|
| 178 |
+
|
| 179 |
+
```bash
|
| 180 |
+
uv venv .venv
|
| 181 |
+
uv pip install --python .venv/bin/python \
|
| 182 |
+
"gliner2==2.1.0" "transformers==4.57.6" "tokenizers==0.22.2" \
|
| 183 |
+
"torch==2.15.0" "onnx==1.23.2" "onnxscript==0.7.2" "onnxruntime==1.23.2"
|
| 184 |
+
|
| 185 |
+
# 1. Build and verify deterministic bundle + manifest.json
|
| 186 |
+
.venv/bin/python build_bundle.py
|
| 187 |
+
|
| 188 |
+
# 2. Generate and verify deterministic golden fixtures in tools/voice/fixtures/names/
|
| 189 |
+
.venv/bin/python reference.py
|
| 190 |
+
```
|
deberta-nli/config.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"DebertaV2ForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"hidden_act": "gelu",
|
| 8 |
+
"hidden_dropout_prob": 0.1,
|
| 9 |
+
"hidden_size": 768,
|
| 10 |
+
"id2label": {
|
| 11 |
+
"0": "entailment",
|
| 12 |
+
"1": "neutral",
|
| 13 |
+
"2": "contradiction"
|
| 14 |
+
},
|
| 15 |
+
"initializer_range": 0.02,
|
| 16 |
+
"intermediate_size": 3072,
|
| 17 |
+
"label2id": {
|
| 18 |
+
"contradiction": 2,
|
| 19 |
+
"entailment": 0,
|
| 20 |
+
"neutral": 1
|
| 21 |
+
},
|
| 22 |
+
"layer_norm_eps": 1e-07,
|
| 23 |
+
"max_position_embeddings": 512,
|
| 24 |
+
"max_relative_positions": -1,
|
| 25 |
+
"model_type": "deberta-v2",
|
| 26 |
+
"norm_rel_ebd": "layer_norm",
|
| 27 |
+
"num_attention_heads": 12,
|
| 28 |
+
"num_hidden_layers": 12,
|
| 29 |
+
"pad_token_id": 0,
|
| 30 |
+
"pooler_dropout": 0,
|
| 31 |
+
"pooler_hidden_act": "gelu",
|
| 32 |
+
"pooler_hidden_size": 768,
|
| 33 |
+
"pos_att_type": [
|
| 34 |
+
"p2c",
|
| 35 |
+
"c2p"
|
| 36 |
+
],
|
| 37 |
+
"position_biased_input": false,
|
| 38 |
+
"position_buckets": 256,
|
| 39 |
+
"relative_attention": true,
|
| 40 |
+
"share_att_key": true,
|
| 41 |
+
"transformers_version": "4.32.0.dev0",
|
| 42 |
+
"type_vocab_size": 0,
|
| 43 |
+
"vocab_size": 128100
|
| 44 |
+
}
|
deberta-nli/model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e0adb1b53ad0bdcf10cf18a6d98207d0403e4e7a87046f6ccf7aa871252d661d
|
| 3 |
+
size 649802
|
deberta-nli/model.onnx_data
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:835c91321cdf40a99df2f80ca12608efb15806f9a2950f10bc85718b48ef8cc3
|
| 3 |
+
size 264840192
|
deberta-nli/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
deberta-nli/tokenizer_config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"bos_token": "[CLS]", "clean_up_tokenization_spaces": true, "cls_token": "[CLS]", "do_lower_case": false, "eos_token": "[SEP]", "mask_token": "[MASK]", "model_max_length": 512, "pad_token": "[PAD]", "sep_token": "[SEP]", "sp_model_kwargs": {}, "split_by_punct": false, "tokenizer_class": "XLMRobertaTokenizer", "unk_token": "[UNK]", "vocab_type": "spm"}
|
gliner25/boundary_head.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:354c425958b19200cf33fc1fba463f2c8aa42a170e759888af240be13978066d
|
| 3 |
+
size 4846334
|
gliner25/config.json
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architecture": "boundary",
|
| 3 |
+
"architecture_version": 1,
|
| 4 |
+
"architectures": [
|
| 5 |
+
"Gliner2ForSchemaExtraction"
|
| 6 |
+
],
|
| 7 |
+
"attn_implementation": "sdpa",
|
| 8 |
+
"boundary_head": {
|
| 9 |
+
"abstention_loss_weight": 0.2,
|
| 10 |
+
"abstention_threshold": 0.5,
|
| 11 |
+
"adaptive_threshold": false,
|
| 12 |
+
"bidirectional_proposals": true,
|
| 13 |
+
"boundary_attention_heads": 4,
|
| 14 |
+
"boundary_attention_layers": 2,
|
| 15 |
+
"boundary_attention_window": 128,
|
| 16 |
+
"boundary_dim": 128,
|
| 17 |
+
"boundary_ffn_multiplier": 2.0,
|
| 18 |
+
"boundary_focal_clip": 0.05,
|
| 19 |
+
"boundary_focal_gamma_negative": 2.0,
|
| 20 |
+
"boundary_focal_gamma_positive": 0.0,
|
| 21 |
+
"boundary_marginal_loss": "asymmetric_focal",
|
| 22 |
+
"boundary_negative_weight": 0.5,
|
| 23 |
+
"boundary_refinement_layers": 1,
|
| 24 |
+
"boundary_top_k_alpha": 0.08,
|
| 25 |
+
"boundary_top_k_bucket": 8,
|
| 26 |
+
"boundary_top_k_max": 128,
|
| 27 |
+
"candidate_attention_heads": 4,
|
| 28 |
+
"candidate_attention_layers": 0,
|
| 29 |
+
"candidate_budget": 192,
|
| 30 |
+
"candidate_pool": "shared",
|
| 31 |
+
"classification_loss_weight": 1.0,
|
| 32 |
+
"classification_temperature": 1.0,
|
| 33 |
+
"consistency_loss_weight": 0.1,
|
| 34 |
+
"consistency_warmup_steps": 2000,
|
| 35 |
+
"content_dim": 64,
|
| 36 |
+
"content_soft_max_pool": false,
|
| 37 |
+
"count_loss_weight": 0.2,
|
| 38 |
+
"directional_relation_states": true,
|
| 39 |
+
"dropout": 0.1,
|
| 40 |
+
"enable_abstention": true,
|
| 41 |
+
"enable_count_head": true,
|
| 42 |
+
"enable_records": true,
|
| 43 |
+
"enable_relations": true,
|
| 44 |
+
"enable_rotary_endpoints": true,
|
| 45 |
+
"enable_span_content": true,
|
| 46 |
+
"end_block_size": 256,
|
| 47 |
+
"end_top_k": 24,
|
| 48 |
+
"endpoint_difference_features": true,
|
| 49 |
+
"ends_per_start": 12,
|
| 50 |
+
"export_mode": "auto",
|
| 51 |
+
"hard_negative_keep_all_when_absent": true,
|
| 52 |
+
"hard_negatives_per_positive": 20,
|
| 53 |
+
"loss_reduction": "sum",
|
| 54 |
+
"max_gold_per_query": 64,
|
| 55 |
+
"max_negative_queries_per_batch": 64,
|
| 56 |
+
"min_pool_per_query": 8,
|
| 57 |
+
"minimum_hard_negatives": 16,
|
| 58 |
+
"multihead_pair_compat_heads": 8,
|
| 59 |
+
"negative_query_ratio": 1.0,
|
| 60 |
+
"overlap_policy": "flat",
|
| 61 |
+
"pair_dim": 128,
|
| 62 |
+
"pair_temperature": 1.0,
|
| 63 |
+
"pool_boundary_top_k": 32,
|
| 64 |
+
"pool_size": 192,
|
| 65 |
+
"proposal_loss_weight": 0.3,
|
| 66 |
+
"query_attention_layers": 0,
|
| 67 |
+
"query_conditioned_inside_weight": true,
|
| 68 |
+
"record_anchor_proposal_threshold": 0.2,
|
| 69 |
+
"record_anchor_threshold": 0.5,
|
| 70 |
+
"record_dim": 128,
|
| 71 |
+
"record_field_threshold": 0.5,
|
| 72 |
+
"record_instance_queries": 32,
|
| 73 |
+
"record_loss_weight": 1.0,
|
| 74 |
+
"record_temperature": 1.0,
|
| 75 |
+
"relation_argument_proposal_threshold": 0.2,
|
| 76 |
+
"relation_biaffine_content": true,
|
| 77 |
+
"relation_heads_per_type": 32,
|
| 78 |
+
"relation_loss_weight": 1.0,
|
| 79 |
+
"relation_pair_cap": 64,
|
| 80 |
+
"relation_tails_per_type": 32,
|
| 81 |
+
"relation_temperature": 1.0,
|
| 82 |
+
"rerank_listwise_weight": 0.3,
|
| 83 |
+
"reranker_endpoint_compat": true,
|
| 84 |
+
"rotary_base": 10000.0,
|
| 85 |
+
"soft_iou_anneal_steps": 20000,
|
| 86 |
+
"soft_iou_aux_weight": 0.2,
|
| 87 |
+
"start_top_k": 24,
|
| 88 |
+
"starts_per_end": 12,
|
| 89 |
+
"training_candidate_budget": 192,
|
| 90 |
+
"use_inside_evidence": true,
|
| 91 |
+
"vectorized_pair_elements": 16777216
|
| 92 |
+
},
|
| 93 |
+
"config_version": 3,
|
| 94 |
+
"max_len": 4096,
|
| 95 |
+
"model_name": "microsoft/deberta-v3-base",
|
| 96 |
+
"encoder_config": {
|
| 97 |
+
"attention_probs_dropout_prob": 0.1,
|
| 98 |
+
"bos_token_id": null,
|
| 99 |
+
"dtype": "float16",
|
| 100 |
+
"eos_token_id": null,
|
| 101 |
+
"hidden_act": "gelu",
|
| 102 |
+
"hidden_dropout_prob": 0.1,
|
| 103 |
+
"hidden_size": 768,
|
| 104 |
+
"initializer_range": 0.02,
|
| 105 |
+
"intermediate_size": 3072,
|
| 106 |
+
"layer_norm_eps": 1e-07,
|
| 107 |
+
"legacy": true,
|
| 108 |
+
"max_position_embeddings": 512,
|
| 109 |
+
"max_relative_positions": -1,
|
| 110 |
+
"model_type": "deberta-v2",
|
| 111 |
+
"norm_rel_ebd": "layer_norm",
|
| 112 |
+
"num_attention_heads": 12,
|
| 113 |
+
"num_hidden_layers": 12,
|
| 114 |
+
"pad_token_id": 0,
|
| 115 |
+
"pooler_dropout": 0.0,
|
| 116 |
+
"pooler_hidden_act": "gelu",
|
| 117 |
+
"pooler_hidden_size": 768,
|
| 118 |
+
"pos_att_type": [
|
| 119 |
+
"p2c",
|
| 120 |
+
"c2p"
|
| 121 |
+
],
|
| 122 |
+
"position_biased_input": false,
|
| 123 |
+
"position_buckets": 256,
|
| 124 |
+
"relative_attention": true,
|
| 125 |
+
"share_att_key": true,
|
| 126 |
+
"tie_word_embeddings": true,
|
| 127 |
+
"transformers_version": "5.8.0",
|
| 128 |
+
"type_vocab_size": 0,
|
| 129 |
+
"vocab_size": 128011
|
| 130 |
+
},
|
| 131 |
+
"model_type": "gliner2",
|
| 132 |
+
"token_pooling": "first",
|
| 133 |
+
"transformers_version": "5.8.0"
|
| 134 |
+
}
|
gliner25/encoder/model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4ed0793d74cc156be6a87f85e94372854fc452d34df23974f9979f23ae53a69b
|
| 3 |
+
size 873875
|
gliner25/encoder/model.onnx_data
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e5561bfead6c1422513060d358f3818fa482752bbf446b84ed1c932a47ed2d01
|
| 3 |
+
size 735052800
|
gliner25/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
gliner25/tokenizer_config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"add_prefix_space": true, "backend": "tokenizers", "bos_token": "[CLS]", "cls_token": "[CLS]", "do_lower_case": false, "eos_token": "[SEP]", "extra_special_tokens": ["[SEP_STRUCT]", "[SEP_TEXT]", "[P]", "[C]", "[E]", "[R]", "[L]", "[EXAMPLE]", "[OUTPUT]", "[DESCRIPTION]"], "is_local": true, "local_files_only": false, "mask_token": "[MASK]", "model_max_length": 1000000000000000019884624838656, "pad_token": "[PAD]", "sep_token": "[SEP]", "split_by_punct": false, "tokenizer_class": "XLMRobertaTokenizer", "unk_id": 3, "unk_token": "[UNK]", "vocab_type": "spm"}
|