Views
No views yet
gector-roberta-base-5k| File | Purpose |
|---|---|
model.onnx | ONNX Runtime model (detection + tag classification heads) |
config.json | Model configuration (label mappings, thresholds) |
tokenizer.json | Fast tokenizer (no transformers dependency at runtime) |
verb-form-vocab.txt | Verb conjugation lookup for $TRANSFORM_VERB_* tags |
inference.py | Standalone inference script (see Usage below) |
pip install onnxruntime tokenizers numpyNote:torchandtransformersare not required at runtime. They are only needed to export the model (seescripts/export_onnx.pyin the source repo).
1from gector.onnx_predict import GECToRONNXPredictor
2
3predictor = GECToRONNXPredictor(
4 model_dir="letheviet/gector-roberta-base-5k-onnx", # or local path
5 verb_file="verb-form-vocab.txt",
6 keep_confidence=0.0,
7 min_error_prob=0.0,
8 batch_size=128,
9 n_iteration=5,
10)
11
12corrected = predictor.predict(["I has a apple .", "She go to school ."])
13print(corrected)
14# ['I have an apple .', 'She goes to school .']inference.py from this repo and run:1# Single sentence
2python inference.py \
3 --model_dir letheviet/gector-roberta-base-5k-onnx \
4 --input "I has a apple ."
5
6# Batch from file
7python inference.py \
8 --model_dir letheviet/gector-roberta-base-5k-onnx \
9 --input_file sentences.txt \
10 --batch_size 64torch/transformers dependencies, bundling with PyInstaller is straightforward:1pip install onnxruntime tokenizers numpy
2# PyInstaller spec only needs the 4 files above (~1.5 MB + deps)| Backend | Latency / sentence | Throughput |
|---|---|---|
| PyTorch (1 thread) | ~282 ms | ~3.5 sentences/sec |
| ONNX Runtime | ~101 ms | ~9.9 sentences/sec |
gotutiyan/gector-roberta-base-5k checkpoint with 20 iterations.