CoolFace
Modelpublic

nativ-community/rampart-mlx-4bit

sourceHugging Facecc-by-4.0updated 2d agoView on Hugging Face
0likes10downloads
Model Card

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.

Size15 MB
WeightsTransformer linears and classifier are 4-bit affine (group 32), repacked bit-for-bit from the ONNX MatMulNBits weights (symmetric q4, zero point 8 → MLX bias = -8·scale). Embeddings are 8-bit affine, repacked from the ONNX per-tensor uint8 DequantizeLinear tables. Nothing is re-quantized, so this checkpoint holds exactly the released weights.
Other precision`nativ-community/rampart-mlx-fp16` (fp16)
LicenseCC BY 4.0, from the original model. Attribution: National Design Studio.

Usage

Needs mlx-vlm with BERT token-classification support (mlx_vlm.token_classification).

python
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>
sh
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:

sh
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):

Token labels identical to ORTRows with identical redaction
MLX fp1699.998%99.95%
MLX 4-bit99.997%99.90%

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):

LanguageORT q4 (upstream)MLX fp16MLX 4-bitPrivate terms
en99.87% [99.75, 99.93]99.87%99.87%6,221
es99.75% [99.59, 99.85]99.75%99.75%5,708
fr99.34% [99.10, 99.52]99.34%99.34%5,641
de99.59% [99.38, 99.73]99.59%99.59%5,582
it99.50% [99.29, 99.65]99.50%99.50%6,004
pt99.63% [99.44, 99.75]99.63%99.63%5,896
nl99.28% [99.03, 99.47]99.28%99.28%5,977
all99.57% [99.50, 99.63]99.57%99.57%41,029

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.