nicolasembleton commited on
Commit
20c74ee
·
verified ·
1 Parent(s): 452ee52

v5 export: candidate_states + records.onnx assignment head

Browse files
Files changed (4) hide show
  1. README.md +23 -43
  2. export_config.json +2 -43
  3. onnx/model.onnx +2 -2
  4. onnx/records.onnx +3 -0
README.md CHANGED
@@ -17,63 +17,43 @@ tags:
17
  # gliner2.5-multi-v1-onnx
18
 
19
  ONNX export of [fastino/gliner2.5-multi-v1](https://huggingface.co/fastino/gliner2.5-multi-v1) (GLiNER 2.5
20
- `BoundaryExtractor`) for onnxruntime-web / WebGPU. **Revision 4:** same fused
21
- encoder as revision 3, plus `[R]` role-state gather and a separate relation
22
- scorer graph.
23
 
24
- One encoder pass. JointIE beam search stays in JavaScript.
 
25
 
26
  Host packing and decode: [Pastel-Org/gliner2.5-onnx-webgpu](https://github.com/Pastel-Org/gliner2.5-onnx-webgpu)
27
  (live: [gliner25-onnx-webgpu.pages.dev](https://gliner25-onnx-webgpu.pages.dev)).
28
 
29
  ## Files
30
 
31
- | File | Role |
32
- |------|------|
33
- | `onnx/model.onnx` | Encoder + entity pair path + classifier + cached states |
34
- | `onnx/heads.onnx` | `SparseRelationScorer` only (no encoder). Directional 2H + biaffine. |
 
35
 
36
- ## model.onnx inputs
37
 
38
- | Name | Shape | Dtype |
39
- |------|-------|-------|
40
- | input_ids | [B, T] | int64 |
41
- | attention_mask | [B, T] | int64 |
42
- | text_word_indices | [B, L] | int64 |
43
- | text_word_mask | [B, L] | float32 |
44
- | query_marker_indices | [B, Q] | int64 |
45
- | query_marker_mask | [B, Q] | float32 |
46
- | cls_marker_indices | [B, K] | int64 |
47
- | cls_marker_mask | [B, K] | float32 |
48
- | rel_marker_indices | [B, R] | int64 |
49
- | rel_marker_mask | [B, R] | float32 |
50
 
51
- Unused heads: pass length-1 indices with mask 0.
52
 
53
- ## model.onnx outputs
54
-
55
- | Name | Shape |
56
- |------|-------|
57
- | start_logits / end_logits | [B, Q, L+1] |
58
- | pair_indices / pair_logits / pair_valid | C=192 |
59
- | cls_logits | [B, K] |
60
- | text_states | [B, L, H] |
61
- | query_states | [B, Q, H] |
62
- | rel_role_states | [B, R, H] |
63
-
64
- Host concatenates each `[R] head` + `[R] tail` pair into a 2H relation state.
65
-
66
- ## heads.onnx
67
-
68
- Inputs: `text_states`, `rel_states [B, Rel, 2H]`, `head_start/end`, `tail_start/end`,
69
- `rel_index`, `pair_mask` (all pair tensors `[B, P]`). Output: `rel_logits [B, P]`.
70
- `sigmoid(rel_logits)` then JS beam (width 16). Schema constraints stay on the host.
71
 
72
  ## Still not in ONNX
73
 
74
- Neural RecordHead instance formation. Repeated JSON objects on the demo are
75
- host assignment (i-th mention of each field). Constrained `implies`/`excludes`
76
- for classification is JS when used.
 
77
 
78
  ## Credits
79
 
 
17
  # gliner2.5-multi-v1-onnx
18
 
19
  ONNX export of [fastino/gliner2.5-multi-v1](https://huggingface.co/fastino/gliner2.5-multi-v1) (GLiNER 2.5
20
+ `BoundaryExtractor`) for onnxruntime-web / WebGPU. **Revision 5:** revision 4
21
+ plus `candidate_states` on the main graph and a tiny `records.onnx` assignment
22
+ head.
23
 
24
+ One encoder pass. JointIE beam, classification `implies`/`excludes`, and record
25
+ assignment stay in JavaScript.
26
 
27
  Host packing and decode: [Pastel-Org/gliner2.5-onnx-webgpu](https://github.com/Pastel-Org/gliner2.5-onnx-webgpu)
28
  (live: [gliner25-onnx-webgpu.pages.dev](https://gliner25-onnx-webgpu.pages.dev)).
29
 
30
  ## Files
31
 
32
+ | File | Role | Size |
33
+ |------|------|------|
34
+ | `onnx/model.onnx` | Encoder + entity pair path + classifier + `text_states` + `candidate_states` | 1121.5 MB |
35
+ | `onnx/heads.onnx` | `SparseRelationScorer` only (no encoder) | 23.7 MB |
36
+ | `onnx/records.onnx` | RecordHead assignment (inst/field/cand projections + null column) | 1.19 MB |
37
 
38
+ ## model.onnx outputs (new in v5)
39
 
40
+ `candidate_states` `[B, Q, C, H]` C=192. Needed by `records.onnx`. Unused heads:
41
+ pass length-1 indices with mask 0.
 
 
 
 
 
 
 
 
 
 
42
 
43
+ ## records.onnx
44
 
45
+ Inputs: `inst_states [B,N,H]`, `inst_mask [B,N]`, `field_query_states [B,F,H]`,
46
+ `field_cand_states [B,F,C,H]`, `field_cand_mask [B,F,C]`.
47
+ Outputs: `assign_logits [B,N,F,1+C]` (col 0 is ABSENT), `object_logits`,
48
+ `latent_logits`. Natural mode seeds instances from the first `::str` field's
49
+ candidates above threshold.
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  ## Still not in ONNX
52
 
53
+ `score_explicit_spans` (pair-reranker broadcast does not export). The demo
54
+ attaches attributes by looking up the same `(start,end)` on attribute `[E]`
55
+ queries. Full Kleene classification AST is not ported; README `implies` /
56
+ `excludes` is a JS beam.
57
 
58
  ## Credits
59
 
export_config.json CHANGED
@@ -1,46 +1,5 @@
1
  {
2
- "architecture": "boundary",
3
- "export_version": 4,
4
  "base_model": "fastino/gliner2.5-multi-v1",
5
- "opset": 17,
6
- "inputs": [
7
- "input_ids",
8
- "attention_mask",
9
- "text_word_indices",
10
- "text_word_mask",
11
- "query_marker_indices",
12
- "query_marker_mask",
13
- "cls_marker_indices",
14
- "cls_marker_mask",
15
- "rel_marker_indices",
16
- "rel_marker_mask"
17
- ],
18
- "outputs": [
19
- "start_logits",
20
- "end_logits",
21
- "pair_indices",
22
- "pair_logits",
23
- "pair_valid",
24
- "cls_logits",
25
- "text_states",
26
- "query_states",
27
- "rel_role_states"
28
- ],
29
- "heads_inputs": [
30
- "text_states",
31
- "rel_states",
32
- "head_start",
33
- "head_end",
34
- "tail_start",
35
- "tail_end",
36
- "rel_index",
37
- "pair_mask"
38
- ],
39
- "heads_outputs": [
40
- "rel_logits"
41
- ],
42
- "hidden_size": 768,
43
- "directional_relation_states": true,
44
- "relation_temperature": 1.0,
45
- "notes": "v4: v3 plus rel_marker gather and query_states. heads.onnx is SparseRelationScorer (directional 2H, biaffine on). Host concats [R] head||tail role states. Beam stays in JS. Dummy R=1/P=1 with mask 0 when unused."
46
  }
 
1
  {
2
+ "export_version": 5,
 
3
  "base_model": "fastino/gliner2.5-multi-v1",
4
+ "notes": "v4 plus candidate_states for RecordHead"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  }
onnx/model.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:42d0f11cb4313d66542c6966ae7e88c6df90cdc77ddbec877a0e33b3c59b4114
3
- size 1120694273
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d42b04535a40d5f1da5e1fde57fdf5fc96d897a083895acc58734c7612bc5fb
3
+ size 1121494477
onnx/records.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bef6dbb75ffbe584fdfc9af19a763c9b6539ea32f5821268f1663dc61beac2a5
3
+ size 1191956