Views
No views yet
Experimental ONNX build - Unofficial ONNX export of fastino/gliner2-multi-v1.
pip install gliner2-onnx1from gliner2_onnx import GLiNER2ONNXRuntime
2
3runtime = GLiNER2ONNXRuntime.from_pretrained("lmo3/gliner2-large-v1-onnx")
4
5entities = runtime.extract_entities(
6 "John works at Google in Seattle",
7 ["person", "organization", "location"]
8)
9# [
10# Entity(text='John', label='person', start=0, end=4, score=0.98),
11# Entity(text='Google', label='organization', start=14, end=20, score=0.97),
12# Entity(text='Seattle', label='location', start=24, end=31, score=0.96)
13# ]1from gliner2_onnx import GLiNER2ONNXRuntime
2
3runtime = GLiNER2ONNXRuntime.from_pretrained("lmo3/gliner2-large-v1-onnx")
4
5# Single-label classification
6result = runtime.classify(
7 "Buy milk from the store",
8 ["shopping", "work", "entertainment"]
9)
10# {'shopping': 0.95}
11
12# Multi-label classification
13result = runtime.classify(
14 "Buy milk and finish the report",
15 ["shopping", "work", "entertainment"],
16 threshold=0.3,
17 multi_label=True
18)
19# {'shopping': 0.85, 'work': 0.72}1runtime = GLiNER2ONNXRuntime.from_pretrained(
2 "lmo3/gliner2-large-v1-onnx",
3 providers=["CUDAExecutionProvider", "CPUExecutionProvider"]
4)1runtime = GLiNER2ONNXRuntime.from_pretrained(
2 "lmo3/gliner2-large-v1-onnx",
3 precision="fp16"
4)| Model | HuggingFace |
|---|---|
| gliner2-large-v1 | lmo3/gliner2-large-v1-onnx |
| gliner2-multi-v1 | lmo3/gliner2-multi-v1-onnx |
gliner2-base-v1 is not supported (uses a different architecture).1git clone https://github.com/lmoe/gliner2-onnx
2cd gliner2-onnx
3
4# FP32 only
5make onnx-export MODEL=fastino/gliner2-large-v1
6
7# FP32 + FP16
8make onnx-export MODEL=fastino/gliner2-large-v1 QUANTIZE=fp16model_out/<model-name>/.