nativ-community/rampart-mlx-4bit
Rampart — MLX 4-bit
MLX conversion of `nationaldesignstudio/rampart`, National Design Studio's multilingual PII token classifier (announcement). It is a 6-layer MiniLM (BertForTokenClassification, hidden 384, 19,730-piece vocab) with 35 BIO labels over 17 entity types, in seven Latin-script languages.
Usage
Needs mlx-vlm with BERT token-classification support (mlx_vlm.token_classification).
from mlx_vlm.token_classification import load_token_classifier
classifier = load_token_classifier("nativ-community/rampart-mlx-4bit")
result = classifier(
"I'm Sarah Connor, 1984 Cyberdyne Ave, Los Angeles CA 90012, sarah@sky.net",
keep_labels=("CITY", "STATE", "ZIP_CODE"),
)
print(result.redacted_text)
# I'm <GIVEN_NAME> <SURNAME>, <BUILDING_NUMBER> <STREET_NAME>, Los Angeles CA 90012, <EMAIL>python -m mlx_vlm.token_classification --model nativ-community/rampart-mlx-4bit \
--keep CITY,STATE,ZIP_CODE "Call Maria Garcia on 617-555-0142."keep_labels mirrors Rampart's default policy: city, state and ZIP are detected but kept.
Not included: upstream Rampart is a hybrid system. SSNs, payment cards and IP addresses are caught by a regex and checksum layer (in the @nationaldesignstudio/rampart npm package) that masks them before the model runs, and the model was trained with those values masked. This checkpoint is the model only, so add your own pattern matching for those classes.
Conversion
Upstream ships only onnx/model_q4.onnx. convert_from_onnx.py in this repo reads the ONNX initializers, maps them to the HF BERT parameter names, and writes MLX safetensors in mlx-vlm's layout. It reproduces both checkpoints from the upstream repo:
hf download nationaldesignstudio/rampart --local-dir rampart
python convert_from_onnx.py rampart # writes rampart-mlx-fp16/ and rampart-mlx-4bit/Evaluation
Measured on an Apple M5 Max. The eval set is 10,500 rows from the validation split of `ai4privacy/pii-masking-openpii-1.5m`, 1,500 per language, which is data the model was not trained on. The reference is the shipped ONNX q4 model under ONNX Runtime (CPU), run on the same inputs.
Conversion fidelity (1,280,624 tokens):
Every disagreement is a near-tie: ORT's own top-1 vs top-2 logit margin at those tokens is at most 0.016.
Model-only private-term recall (a gold PII value counts as caught if any of its characters is redacted; Wilson 95% CI):
Through the mlx_vlm.token_classification span decoder end to end, with the city/state/ZIP keep policy: private recall 99.57%, public-term retention 99.90%.
The private terms counted are names, phones, emails, ID/tax/passport/licence numbers, street and building number. SSNs and credit cards are left out because they belong to the regex layer. Public terms are dates, ages, titles, gender, times, city and ZIP. These numbers are not comparable to the 98.42% on the upstream card. That figure is a full-system score on a pinned 30k-row slice with a different term mapping. What this table shows is that the MLX checkpoints reproduce upstream model behaviour.
Rampart is a redaction aid, not an anonymization or compliance guarantee. See the upstream model card for intended use, limitations, and fairness results.
