lmo3 commited on
Commit
0a4cb8f
·
verified ·
1 Parent(s): 81e5d6b

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,12 @@ 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
+ onnx/classifier.onnx.data filter=lfs diff=lfs merge=lfs -text
37
+ onnx/classifier_fp16.onnx.data filter=lfs diff=lfs merge=lfs -text
38
+ onnx/count_embed.onnx.data filter=lfs diff=lfs merge=lfs -text
39
+ onnx/count_embed_fp16.onnx.data filter=lfs diff=lfs merge=lfs -text
40
+ onnx/encoder.onnx.data filter=lfs diff=lfs merge=lfs -text
41
+ onnx/encoder_fp16.onnx.data filter=lfs diff=lfs merge=lfs -text
42
+ onnx/span_rep.onnx.data filter=lfs diff=lfs merge=lfs -text
43
+ onnx/span_rep_fp16.onnx.data filter=lfs diff=lfs merge=lfs -text
44
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: gliner2-onnx
3
+ base_model: fastino/gliner2-multi-v1
4
+ tags:
5
+ - onnx
6
+ - gliner
7
+ - gliner2
8
+ - ner
9
+ - named-entity-recognition
10
+ - zero-shot
11
+ - classification
12
+ license: mit
13
+ ---
14
+
15
+ > **Experimental ONNX build** - Unofficial ONNX export of [fastino/gliner2-multi-v1](https://huggingface.co/fastino/gliner2-multi-v1).
16
+
17
+ # gliner2-onnx
18
+
19
+ GLiNER2 ONNX runtime for Python. Runs GLiNER2 models without PyTorch.
20
+
21
+ This library is experimental. The API may change between versions.
22
+
23
+ ## Features
24
+
25
+ - Zero-shot NER and text classification
26
+ - Runs with ONNX Runtime (no PyTorch dependency)
27
+ - FP32 and FP16 precision support
28
+ - GPU acceleration via CUDA
29
+
30
+ All other GLiNER2 features such as JSON export are not supported.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install gliner2-onnx
36
+ ```
37
+
38
+ ## NER
39
+
40
+ ```python
41
+ from gliner2_onnx import GLiNER2ONNXRuntime
42
+
43
+ runtime = GLiNER2ONNXRuntime.from_pretrained("lmoe/gliner2-large-v1-onnx")
44
+
45
+ entities = runtime.extract_entities(
46
+ "John works at Google in Seattle",
47
+ ["person", "organization", "location"]
48
+ )
49
+ # [
50
+ # Entity(text='John', label='person', start=0, end=4, score=0.98),
51
+ # Entity(text='Google', label='organization', start=14, end=20, score=0.97),
52
+ # Entity(text='Seattle', label='location', start=24, end=31, score=0.96)
53
+ # ]
54
+ ```
55
+
56
+ ## Classification
57
+
58
+ ```python
59
+ from gliner2_onnx import GLiNER2ONNXRuntime
60
+
61
+ runtime = GLiNER2ONNXRuntime.from_pretrained("lmoe/gliner2-large-v1-onnx")
62
+
63
+ # Single-label classification
64
+ result = runtime.classify(
65
+ "Buy milk from the store",
66
+ ["shopping", "work", "entertainment"]
67
+ )
68
+ # {'shopping': 0.95}
69
+
70
+ # Multi-label classification
71
+ result = runtime.classify(
72
+ "Buy milk and finish the report",
73
+ ["shopping", "work", "entertainment"],
74
+ threshold=0.3,
75
+ multi_label=True
76
+ )
77
+ # {'shopping': 0.85, 'work': 0.72}
78
+ ```
79
+
80
+ ## CUDA
81
+
82
+ To use CUDA for GPU acceleration:
83
+
84
+ ```python
85
+ runtime = GLiNER2ONNXRuntime.from_pretrained(
86
+ "lmoe/gliner2-large-v1-onnx",
87
+ providers=["CUDAExecutionProvider", "CPUExecutionProvider"]
88
+ )
89
+ ```
90
+
91
+ ## Precision
92
+
93
+ Both FP32 and FP16 models are supported. Only the requested precision is downloaded.
94
+
95
+ ```python
96
+ runtime = GLiNER2ONNXRuntime.from_pretrained(
97
+ "lmoe/gliner2-large-v1-onnx",
98
+ precision="fp16"
99
+ )
100
+ ```
101
+
102
+ ## Models
103
+
104
+ Pre-exported ONNX models:
105
+
106
+ | Model | HuggingFace |
107
+ |-------|-------------|
108
+ | gliner2-large-v1 | [lmoe/gliner2-large-v1-onnx](https://huggingface.co/lmoe/gliner2-large-v1-onnx) |
109
+ | gliner2-multi-v1 | [lmoe/gliner2-multi-v1-onnx](https://huggingface.co/lmoe/gliner2-multi-v1-onnx) |
110
+
111
+ Note: `gliner2-base-v1` is not supported (uses a different architecture).
112
+
113
+ ## Exporting Models
114
+
115
+ To export your own models, clone the repository and use make:
116
+
117
+ ```bash
118
+ git clone https://github.com/lmoe/gliner2-onnx
119
+ cd gliner2-onnx
120
+
121
+ # FP32 only
122
+ make onnx-export MODEL=fastino/gliner2-large-v1
123
+
124
+ # FP32 + FP16
125
+ make onnx-export MODEL=fastino/gliner2-large-v1 QUANTIZE=fp16
126
+ ```
127
+
128
+ Output is saved to `model_out/<model-name>/`.
129
+
130
+ ## JavaScript/TypeScript
131
+
132
+ For Node.js, see [@lmoe/gliner-onnx.js](https://github.com/lmoe/gliner-onnx.js).
133
+
134
+ ## Credits
135
+
136
+ - [fastino-ai/GLiNER2](https://github.com/fastino-ai/GLiNER2) - Original GLiNER2 implementation
137
+ - [fastino/gliner2-large-v1](https://huggingface.co/fastino/gliner2-large-v1) - Pre-trained models
138
+
139
+ ## License
140
+
141
+ MIT
config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "hidden_size": 768,
3
+ "vocab_size": 250101
4
+ }
gliner2_config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "max_width": 8,
3
+ "special_tokens": {
4
+ "[SEP_STRUCT]": 250102,
5
+ "[SEP_TEXT]": 250103,
6
+ "[P]": 250104,
7
+ "[C]": 250105,
8
+ "[E]": 250106,
9
+ "[R]": 250107,
10
+ "[L]": 250108,
11
+ "[EXAMPLE]": 250109,
12
+ "[OUTPUT]": 250110,
13
+ "[DESCRIPTION]": 250111
14
+ },
15
+ "onnx_files": {
16
+ "fp32": {
17
+ "encoder": "onnx/encoder.onnx",
18
+ "classifier": "onnx/classifier.onnx",
19
+ "span_rep": "onnx/span_rep.onnx",
20
+ "count_embed": "onnx/count_embed.onnx"
21
+ },
22
+ "fp16": {
23
+ "encoder": "onnx/encoder_fp16.onnx",
24
+ "classifier": "onnx/classifier_fp16.onnx",
25
+ "span_rep": "onnx/span_rep_fp16.onnx",
26
+ "count_embed": "onnx/count_embed_fp16.onnx"
27
+ }
28
+ }
29
+ }
onnx/classifier.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0daf6bb253bf449757f507503f1204a9cd9422ec7ab15b602dcf61a70e5faaaa
3
+ size 4731597
onnx/classifier.onnx.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a718fa8f512a3ba6f56fb7bfaace4e456f461c3b24210e79d614d5fd4c5d8b04
3
+ size 4784128
onnx/classifier_fp16.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:afb84218f428aeceee5591b02d6b5a29acf209ad6a5a1c9b8904b66430bca8c2
3
+ size 1303
onnx/classifier_fp16.onnx.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4521c0976f0dc0625bbe05288a8b9e50af0d18828f02520ee6fe04d63d04d4ba
3
+ size 7096320
onnx/count_embed.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9b221ecf849b923733ebfde4afac2ea5a37d4a58c5252d61d037ab802c602328
3
+ size 42506885
onnx/count_embed.onnx.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9bea1328893f5cfe249537e2729e9d03ed991b6c2d53f6a73cae9ba7a9919c19
3
+ size 42532864
onnx/count_embed_fp16.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e3c025e8ead7074f514304fca1f921898df8a4e8edf88d381503b03324b867de
3
+ size 5410
onnx/count_embed_fp16.onnx.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cd4bc33cd6686ea5cbd2ce2e77e1dbfaad1eaeda36546fc39a7c6c73f4655324
3
+ size 106260480
onnx/encoder.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f225fd0164d71e3050d9ac8ba4b82bf4e6cd17b32e44f237bf36d27d4be9b1fd
3
+ size 1111055946
onnx/encoder.onnx.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b53cd28f9d625e17f9c19c8613b9a36651b98dd8ad17b7d3e7bb0d873807c8e
3
+ size 1110179840
onnx/encoder_fp16.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ae92c5816a17ec8d88e0b19e485a081acb283e31715080cdeae3e79f4e7b3d04
3
+ size 1265182
onnx/encoder_fp16.onnx.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d74f661dfcb9fb84407135aa79e218afc60c39adb708f2a92fc0c9b72cb49a72
3
+ size 1665220608
onnx/span_rep.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:65de283b39fcf1e73beb2ecd23ba9cf5807f2cf00ecb988944bd8d3e8d2cd144
3
+ size 66111424
onnx/span_rep.onnx.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a3944ab5ad45a9cacb3cdda9d42c80e1c7947348c9137345c54c270530a9cbad
3
+ size 66125824
onnx/span_rep_fp16.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:544e4f98ea39687c1f8663f23435764c7628a347ce3e37a427e563cc0655cd77
3
+ size 8387
onnx/span_rep_fp16.onnx.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8330a4d34ab4ad828b63843f01f9603caef562d64643b33a4626add34d3c14c
3
+ size 99159552
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a1c7ccb287623cccb7c03150953b6d2a09dd95122933393c9151c3a60095c97e
3
+ size 16337353
tokenizer_config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "[CLS]",
4
+ "clean_up_tokenization_spaces": false,
5
+ "cls_token": "[CLS]",
6
+ "do_lower_case": false,
7
+ "eos_token": "[SEP]",
8
+ "extra_special_tokens": [
9
+ "[SEP_STRUCT]",
10
+ "[SEP_TEXT]",
11
+ "[P]",
12
+ "[C]",
13
+ "[E]",
14
+ "[R]",
15
+ "[L]",
16
+ "[EXAMPLE]",
17
+ "[OUTPUT]",
18
+ "[DESCRIPTION]"
19
+ ],
20
+ "is_local": false,
21
+ "mask_token": "[MASK]",
22
+ "model_max_length": 1000000000000000019884624838656,
23
+ "model_specific_special_tokens": {},
24
+ "pad_token": "[PAD]",
25
+ "sep_token": "[SEP]",
26
+ "sp_model_kwargs": {},
27
+ "split_by_punct": false,
28
+ "tokenizer_class": "TokenizersBackend",
29
+ "unk_token": "[UNK]",
30
+ "vocab_type": "spm"
31
+ }