GLiNER2 ONNX runtime for NER and classification without PyTorch
Project description
gliner2-onnx
GLiNER2 ONNX runtime for Python. Runs GLiNER2 models without PyTorch.
This library is experimental. The API may change between versions.
Features
- Zero-shot NER and text classification
- Runs with ONNX Runtime (no PyTorch dependency)
- FP32 and FP16 precision support
- GPU acceleration via CUDA
All other GLiNER2 features such as JSON export are not supported.
Installation
pip install gliner2-onnx
NER
from gliner2_onnx import GLiNER2ONNXRuntime
runtime = GLiNER2ONNXRuntime.from_pretrained("lmo3/gliner2-large-v1-onnx")
entities = runtime.extract_entities(
"John works at Google in Seattle",
["person", "organization", "location"]
)
# [
# Entity(text='John', label='person', start=0, end=4, score=0.98),
# Entity(text='Google', label='organization', start=14, end=20, score=0.97),
# Entity(text='Seattle', label='location', start=24, end=31, score=0.96)
# ]
Classification
from gliner2_onnx import GLiNER2ONNXRuntime
runtime = GLiNER2ONNXRuntime.from_pretrained("lmo3/gliner2-large-v1-onnx")
# Single-label classification
result = runtime.classify(
"Buy milk from the store",
["shopping", "work", "entertainment"]
)
# {'shopping': 0.95}
# Multi-label classification
result = runtime.classify(
"Buy milk and finish the report",
["shopping", "work", "entertainment"],
threshold=0.3,
multi_label=True
)
# {'shopping': 0.85, 'work': 0.72}
CUDA
To use CUDA for GPU acceleration:
runtime = GLiNER2ONNXRuntime.from_pretrained(
"lmo3/gliner2-large-v1-onnx",
providers=["CUDAExecutionProvider", "CPUExecutionProvider"]
)
Precision
Both FP32 and FP16 models are supported. Only the requested precision is downloaded.
runtime = GLiNER2ONNXRuntime.from_pretrained(
"lmo3/gliner2-large-v1-onnx",
precision="fp16"
)
Models
Pre-exported ONNX models:
| Model | HuggingFace |
|---|---|
| gliner2-large-v1 | lmo3/gliner2-large-v1-onnx |
| gliner2-multi-v1 | lmo3/gliner2-multi-v1-onnx |
Note: gliner2-base-v1 is not supported (uses a different architecture).
Exporting Models
To export your own models, clone the repository and use make:
git clone https://github.com/lmoe/gliner2-onnx
cd gliner2-onnx
# FP32 only
make onnx-export MODEL=fastino/gliner2-large-v1
# FP32 + FP16
make onnx-export MODEL=fastino/gliner2-large-v1 QUANTIZE=fp16
Output is saved to model_out/<model-name>/.
JavaScript/TypeScript
For Node.js, see @lmoe/gliner-onnx.js.
Credits
- fastino-ai/GLiNER2 - Original GLiNER2 implementation
- fastino/gliner2-large-v1 - Pre-trained models
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gliner2_onnx-0.1.1.tar.gz.
File metadata
- Download URL: gliner2_onnx-0.1.1.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0858337a867e47753046c1041d9c5e2e24a67940a9f566c37f174f861648b63f
|
|
| MD5 |
777d628fc5f945ef520a0d2cf030f3ca
|
|
| BLAKE2b-256 |
938b594e61d423ec912bc620ca8bd76a6da55c7d3089a9e3c4ee45ea5207fcf4
|
Provenance
The following attestation bundles were made for gliner2_onnx-0.1.1.tar.gz:
Publisher:
publish.yml on lmoe/gliner2-onnx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gliner2_onnx-0.1.1.tar.gz -
Subject digest:
0858337a867e47753046c1041d9c5e2e24a67940a9f566c37f174f861648b63f - Sigstore transparency entry: 962716284
- Sigstore integration time:
-
Permalink:
lmoe/gliner2-onnx@35655a6b18fa24e81584645415a1733e9d47e321 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/lmoe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@35655a6b18fa24e81584645415a1733e9d47e321 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gliner2_onnx-0.1.1-py3-none-any.whl.
File metadata
- Download URL: gliner2_onnx-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f1b8300a880a19c2fec6688b4af51491258f5deefaa84b5a0cebf7c9d5f3044
|
|
| MD5 |
2456805575f35f31f640033187ce8beb
|
|
| BLAKE2b-256 |
9367ae24b96a31433154eef40d962b90dde1640263aec748ac3040baaf824cc0
|
Provenance
The following attestation bundles were made for gliner2_onnx-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on lmoe/gliner2-onnx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gliner2_onnx-0.1.1-py3-none-any.whl -
Subject digest:
4f1b8300a880a19c2fec6688b4af51491258f5deefaa84b5a0cebf7c9d5f3044 - Sigstore transparency entry: 962716291
- Sigstore integration time:
-
Permalink:
lmoe/gliner2-onnx@35655a6b18fa24e81584645415a1733e9d47e321 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/lmoe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@35655a6b18fa24e81584645415a1733e9d47e321 -
Trigger Event:
push
-
Statement type: