BCCard/MoAI-Privacy-Filter-INT8
566
1---2language:3- ko4- en5license: apache-2.06library_name: onnxruntime7pipeline_tag: token-classification8inference: false9base_model: openai/privacy-filter10datasets:11- BCCard/privacy-filter-openpii-masking12metrics:13- precision14- recall15- f116tags:17- onnx18- onnxruntime19- int820- weight-only21- token-classification22- ner23- pii24- privacy25- korean26- english27- bioes28---29 30# MoAI-Privacy-Filter-INT831 32`MoAI-Privacy-Filter-INT8` is an INT8 weight-only ONNX Runtime artifact for Korean and English entity detection. It identifies 29 entity types with 117 BIOES token classes.33 34This repository contains the quantized ONNX graph, external tensor data, tokenizer, label configuration, taxonomy, and Viterbi calibration. It does not contain PyTorch weights and cannot be loaded with `AutoModelForTokenClassification.from_pretrained()`.35 36## 1. Model summary37 38* **Base model**: [`openai/privacy-filter`](https://huggingface.co/openai/privacy-filter).39* **Parent checkpoint**: `BCCard/MoAI-Privacy-Filter` v3 `final-bf16`.40* **Task**: Korean and English token classification with character-offset entity reconstruction.41* **Taxonomy**: 29 entity labels and 117 BIOES classes under `4N+1`.42* **Input policy**: Up to 1024 tokens per sequence.43* **Quantization**: INT8 weight-only with FP32 activations and logits.44* **Runtime**: ONNX Runtime CPU execution.45 46The validated serving chain is:47 48```text49text50-> tokenizer51-> INT8 weight-only ONNX graph52-> FP32 logits53-> constrained BIOES Viterbi decoding54-> character-offset spans55-> whitespace boundary refinement56```57 58## 2. Labels59 60The model detects the following entity types:61 62| Label | Description |63|---|---|64| `PERSON` | Person name |65| `RRN` | Korean resident registration number |66| `FRN` | Korean foreign resident registration number |67| `SSN` | Social Security number |68| `GENERIC_ID` | Identity or tax identifier without a more specific taxonomy class |69| `CARD_NUMBER` | Payment card number |70| `ACCOUNT_NUMBER` | Financial account number |71| `SECRET` | Password, API key, token, or other authentication secret |72| `USER_ID` | User or account login identifier |73| `EMAIL` | Email address |74| `PHONE` | Telephone number |75| `PASSPORT` | Passport number |76| `DRIVER_LICENSE` | Driver's license number |77| `ADDRESS` | Postal or street address |78| `ZIPCODE` | Postal code |79| `DATE` | Date or time expression |80| `CARD_EXPIRY` | Payment card expiration date |81| `CVC` | Payment card verification code |82| `IPIN` | Korean I-PIN identifier |83| `TRANSACTION_APPROVAL_ID` | Transaction approval identifier |84| `BUSINESS_ID` | Business registration identifier |85| `VIRTUAL_CARD_NUMBER` | Virtual card number |86| `CI` | Connecting Information identifier |87| `IPADDRESS` | IP address |88| `MACADDRESS` | MAC address |89| `IMEI` | Mobile equipment identifier |90| `PORT` | Network port number |91| `ORGANIZATION` | Organization name |92| `URL` | URL |93 94Each entity has `B-`, `I-`, `E-`, and `S-` boundary classes. The remaining class is `O`.95 96## 3. Usage97 98Install the required packages:99 100```bash101pip install "onnxruntime>=1.28,<1.29" "huggingface-hub>=1.5" "transformers>=5.6" numpy102```103 104The following example runs the graph and returns FP32 logits:105 106```python107import json108from pathlib import Path109 110import numpy as np111import onnxruntime as ort112from huggingface_hub import snapshot_download113from transformers import AutoTokenizer114 115model_id = "BCCard/MoAI-Privacy-Filter-INT8"116model_dir = Path(snapshot_download(repo_id=model_id))117 118tokenizer = AutoTokenizer.from_pretrained(model_dir)119session = ort.InferenceSession(120 str(model_dir / "model_quantized.onnx"),121 providers=["CPUExecutionProvider"],122)123 124text = "연락처는 010-1234-5678이고 접속 주소는 192.0.2.15입니다."125encoded = tokenizer(126 text,127 add_special_tokens=False,128 truncation=True,129 max_length=1024,130 return_tensors="np",131)132feeds = {133 model_input.name: np.asarray(encoded[model_input.name], dtype=np.int64)134 for model_input in session.get_inputs()135}136logits = session.run(["logits"], feeds)[0]137 138config = json.loads((model_dir / "config.json").read_text(encoding="utf-8"))139id2label = {140 int(class_id): label141 for class_id, label in config["id2label"].items()142}143 144print(logits.shape)145print(id2label[int(logits[0, 0].argmax())])146```147 148The graph emits logits rather than final entities. Apply the constrained BIOES Viterbi decoder using `config.json` and `viterbi_calibration.json`, then map token predictions to character offsets. Independent token argmax is not equivalent to the decoding chain used for validation.149 150## 4. Evaluation151 152The INT8 artifact and its FP32 ONNX reference were evaluated on the same 14,524-row Korean and English validation split. Metrics use strict character-span matching after constrained BIOES Viterbi decoding and whitespace boundary refinement.153 154| Slice | Model | Precision | Recall | F1 | F1 delta from FP32 |155|---|---|---:|---:|---:|---:|156| Overall | FP32 ONNX | 0.9604 | 0.9597 | 0.9601 | - |157| Overall | INT8 | 0.9603 | 0.9596 | 0.9599 | -0.0001 |158| Korean | FP32 ONNX | 0.9586 | 0.9576 | 0.9581 | - |159| Korean | INT8 | 0.9584 | 0.9575 | 0.9580 | -0.0001 |160| English | FP32 ONNX | 0.9654 | 0.9654 | 0.9654 | - |161| English | INT8 | 0.9652 | 0.9654 | 0.9653 | -0.0001 |162 163The INT8 predictions achieved 0.9984 strict micro F1 against the FP32 ONNX predictions, with 14,402 of 14,524 rows matching exactly. All configured quantization quality gates passed.164 165These end-to-end character-span scores are not directly comparable with training-time token metrics because they include character reconstruction, constrained decoding, and boundary refinement.166 167## 5. Artifact size168 169| Artifact | Graph files | Relative size |170|---|---:|---:|171| BF16 parent checkpoint | 2.799 GB | Reference |172| INT8 weight-only ONNX | 1.618 GB | 42.2% smaller than the BF16 parent |173 174The comparison uses the publicly released BF16 parent checkpoint as its reference. Actual memory use and latency depend on hardware, ONNX Runtime version, sequence length, and batch size.175 176## 6. Intended use and limitations177 178This model is intended for entity detection in privacy filtering, data review, and preprocessing workflows. A consuming application must define its own downstream redaction or retention policy for every detected label.179 180* Evaluate the model on representative in-domain data before deployment.181* Inputs longer than 1024 tokens require chunking and span reconciliation.182* Context-dependent and ambiguous identifiers can still produce false positives or false negatives.183* `PORT` and `ZIPCODE`, `ORGANIZATION` and `PERSON`, and structurally similar numeric identifiers require particular monitoring.184* Do not treat model output as a substitute for organizational privacy controls or human review in high-risk workflows.185 186## 7. Training data and attribution187 188The parent model was trained with [`BCCard/privacy-filter-openpii-masking`](https://huggingface.co/datasets/BCCard/privacy-filter-openpii-masking), which is derived in part from [`ai4privacy/pii-masking-openpii-1.5m`](https://huggingface.co/datasets/ai4privacy/pii-masking-openpii-1.5m) and supplemented with Korean and English synthetic scenarios.189 190The base model is [`openai/privacy-filter`](https://huggingface.co/openai/privacy-filter). Review the licenses and usage terms of the model, dataset, and dependencies before redistribution or deployment.191 192## 8. License, Attribution, and Citation193 194```bibtex195@misc{bccard2026moaiprivacyfilter,196 title = {MoAI Privacy Filter INT8: A Korean Finance-Domain PII Detection Model},197 author = {BC Card AX Team},198 year = {2026},199 howpublished = {https://huggingface.co/BCCard/MoAI-Privacy-Filter-INT8},200 note = {INT8 weight-only ONNX artifact of a full fine-tune of openai/privacy-filter}201}202```203 204Related resources:205 206* **Base model** - [`openai/privacy-filter`](https://huggingface.co/openai/privacy-filter).207* **Parent BF16 model** - [`BCCard/MoAI-Privacy-Filter`](https://huggingface.co/BCCard/MoAI-Privacy-Filter).208* **Training dataset** - [`BCCard/privacy-filter-openpii-masking`](https://huggingface.co/datasets/BCCard/privacy-filter-openpii-masking).209* **Source data attribution** - [`ai4privacy/pii-masking-openpii-1.5m`](https://huggingface.co/datasets/ai4privacy/pii-masking-openpii-1.5m) under CC-BY-4.0.210 