Instructions to use chaliasif/saudi-tender-tagger-onnx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use chaliasif/saudi-tender-tagger-onnx with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-classification', 'chaliasif/saudi-tender-tagger-onnx');
saudi-tender-tagger-onnx
ONNX export (fp32 and dynamic int8) of the activity classifier in chaliasif/saudi-tender-tagger. It reads the Arabic title of a Saudi government tender plus the issuing agency and returns one of 54 Etimad activity categories. It runs in Node and in the browser through transformers.js, no Python needed.
Fine-tuned from CAMeL-Lab/bert-base-arabic-camelbert-mix (BertForSequenceClassification, 54 labels, max length 128). Training data: chaliasif/etimad-tender-titles. Code: https://github.com/aliasif97/saudi-tender-tagger
Input format
One string per tender: title | agency. Normalise first: Unicode NFKC, delete U+200E and U+200F, collapse whitespace to single spaces, trim both parts. In Python this is make_input(title, agency) in scripts/common.py of the GitHub repo. Texts longer than 128 tokens are truncated.
توريد أجهزة حاسب آلي محمول | وزارة الصحة
Usage (transformers.js)
import { pipeline } from '@huggingface/transformers';
const clf = await pipeline('text-classification', 'chaliasif/saudi-tender-tagger-onnx', { dtype: 'q8' });
const out = await clf('توريد أجهزة حاسب آلي محمول | وزارة الصحة', { top_k: 3 });
console.log(out); // [{ label, score }, x3]
Works the same in the browser (import from a CDN or bundler; the int8 file is downloaded, 110 MB). Use dtype: 'fp32' for the full-precision file. For local files set env.localModelPath to the parent folder and env.allowRemoteModels = false.
Files
| File | Size |
|---|---|
| onnx/model.onnx (fp32) | 436.6 MB |
| onnx/model_quantized.onnx (int8, per-channel) | 110.0 MB |
| tokenizer.json, vocab.txt, config files | about 1.1 MB |
Parity and accuracy
Test split of the dataset, 1,053 rows, onnxruntime 1.27 (Python):
| Model | Top-1 agreement with PyTorch | Top-1 acc | Top-3 acc |
|---|---|---|---|
| PyTorch original | 100% | 61.06% | n/a |
| ONNX fp32 | 100.00% | 61.06% | 80.44% |
| ONNX int8 | 98.29% | 60.68% | 80.25% |
Accuracy is measured against the exact Etimad activity label across 54 classes, so it is a hard task; top-3 is the more useful number for suggestions.
In Node, 200 random test rows, int8 vs the Python int8 result: 98.5% with @huggingface/transformers 4.3.1 (onnxruntime-node 1.30), 95.5% with 3.8.1 (onnxruntime-node 1.21, older int8 kernels). Median latency about 21 ms per title on an Apple M-series CPU. Prefer 4.x for int8, or use fp32 on 3.x. The JS tokenizer does not always truncate at 128 tokens, so keep inputs short (tender titles normally are).
Attribution
Base model: CAMeLBERT (CAMeL-Lab/bert-base-arabic-camelbert-mix), Apache-2.0. Inoue, Khalifa, Habash, "The Interplay of Variant, Size, and Task Type in Arabic Pre-trained Language Models", WANLP 2021. This fine-tune and export are released under MIT; keep the Apache-2.0 notice for the base model when redistributing.
ملخص بالعربية
هذا النموذج نسخة ONNX (بدقة كاملة وبصيغة int8 مضغوطة) من مصنّف الأنشطة في مشروع saudi-tender-tagger. يأخذ عنوان المنافسة الحكومية السعودية واسم الجهة بصيغة "العنوان | الجهة" ويُرجع أقرب أنشطة اعتماد من بين 54 نشاطًا. يعمل مباشرة في Node والمتصفح عبر transformers.js دون Python. دقة التصنيف الأول نحو 61% ودقة أفضل ثلاثة نتائج نحو 80% على مجموعة الاختبار، والنسخة المضغوطة (110 ميغابايت) تطابق النموذج الأصلي في 98% من الحالات.
- Downloads last month
- 17
Model tree for chaliasif/saudi-tender-tagger-onnx
Base model
CAMeL-Lab/bert-base-arabic-camelbert-mix