urchade / GLiNER

Generalist and Lightweight Model for Named Entity Recognition (Extract any entity types from texts) @ NAACL 2024
https://arxiv.org/abs/2311.08526
Apache License 2.0
1.36k stars 117 forks source link

Conversion to ONXX #177

Open jitesh0034 opened 2 months ago

jitesh0034 commented 2 months ago

Using this snippet to save pre-trained model locally -

from gliner import GLiNER
model  = GLiNER.from_pretrained("urchade/gliner_medium")
model.save_pretrained("gliner_medium")

post this, running script for onxx conversion as per documentation - python GLiNER/convert_to_onnx.py --model_path gliner_medium/ --save_path gliner_onnx/ --quantize True

getting error on - OSError: gliner_medium does not appear to have a file named config.json. Checkout 'https://huggingface.co/gliner_medium/tree/None' for available files.

Tried with changing file name from 'gliner_config.json' to 'config.json' getting new error of - ValueError: Unrecognized model in gliner_medium. Should have a `model_type` key in its config.json

hari-ag00 commented 2 months ago

try the same onnx conversion in notebook version once, https://github.com/urchade/GLiNER/blob/main/examples/convert_to_onnx.ipynb

hari-ag00 commented 2 months ago

and try to use earlier gliner version, latest gliner version has some bugs in onnx conversion

jitesh0034 commented 2 months ago

thanks @hari-ag00
Also, can you suggest the version for this? Currently, i am using '0.2.2'

hari-ag00 commented 2 months ago

@jitesh0034 try using 0.2.3