๐ ONNX Model for NuNerZero
This repository stores the ONNX version of NuNerZero, a zero - shot named entity recognition (NER) model. It is optimized for fast inference using ONNX Runtime. The conversion aims to offer efficient and production - ready performance while retaining the original capabilities of the NuNerZero model.
This model is a part of Zink. Zink is a zero - shot anonymizer and currently uses the ONNX NuNERZero model for anonymization.
๐ Quick Start
Hereโs a quick example on how to load and use the ONNX model with GLiNER:
from gliner import GLiNER
import time
model_name="deepanwa/NuNerZero_onnx"
model = GLiNER.from_pretrained(model_name,load_onnx_model=True, load_tokenizer=True)
text = "Dr. Michael, a cardiologist from Canada, was born on 07/04/1970. John Doe dialled his mother at 992-234-3456 and then went out for a walk."
labels = ("person", "profession", "location", "date", "phone number", "relationship", "medical condition", "age")
start = time.time()
result = model.predict_entities(text, labels)
end = time.time()
print("Predicted entities:", result)
print("Time taken:", end - start)
โจ Features
- Zero - shot named entity recognition.
- Optimized for fast inference using ONNX Runtime.
- Part of the Zink zero - shot anonymizer.
๐ฆ Installation
Requirements
- Python 3.7 or higher
- GLiNER โ the package that provides the interface to load and run the model. The ONNX version was created on "gliner==0.2.3".
๐ Documentation
Repository Contents
Property |
Details |
model.onnx |
The primary ONNX model file used for inference. |
gliner_config.json |
Configuration settings for the model. |
added_tokens.json |
Additional tokens required by the tokenizer. |
special_tokens_map.json |
Mapping for special tokens. |
tokenizer.json and tokenizer_config.json |
Tokenizer vocabulary and configuration files. |
spm.model |
SentencePiece model file used by the tokenizer. |
๐ง Technical Details
- The model is a zero - shot NER model.
- It is converted to the ONNX format to improve inference speed.
- It is used as a component in the Zink zero - shot anonymizer.
๐ License
This project is licensed under the MIT license.
๐ Citation
10.57967/hf/4902
๐ฌ Contributing
Contributions, suggestions, or bug reports are welcome. Please open an issue or submit a pull request if you have improvements.
โ ๏ธ Important Note
The model file is approximately 1.85 GB, so please ensure you have sufficient bandwidth and disk space when downloading.
๐ก Usage Tip
Leveraging the ONNX format can significantly accelerate inference compared to the original PyTorch implementation.