Views
No views yet
jhu-clsp/ettin-encoder-32m.AutoModelForTokenClassification.from_pretrained(...) call loads the FP32 Safetensors checkpoint;
select an ONNX file explicitly when using FP32, FP16, or INT8 ONNX Runtime inference.| Field | Value |
|---|---|
| Architecture | ModernBERT token classifier |
| Parameters | 32,043,681 |
| Base model | jhu-clsp/ettin-encoder-32m |
| Output classes | 33: O plus BIOES tags for eight span categories |
| Evaluated context window | 512 tokens with stride 128 |
| Root checkpoint precision | FP32 |
| Training | Full-parameter fine-tuning |
| Decoder | Constrained BIOES Viterbi, zero transition biases |
account_number, private_address, private_date,
private_email, private_person, private_phone, private_url, and secret.| File | Precision | Size | Intended runtime |
|---|---|---|---|
model.safetensors | FP32 | 122.2 MiB | Canonical Transformers checkpoint |
onnx/model.onnx | FP32 | 122.5 MiB | ONNX reference and compatibility path |
onnx/model_fp16.onnx | FP16 weights/compute, FP32 output | 61.4 MiB | GPU; validated with ONNX Runtime CUDA |
onnx/model_quantized.onnx | Per-row QInt8 embedding plus selective dynamic QUInt8 | 33.6 MiB | Compact CPU path, one request per inference batch |
1import torch
2from transformers import AutoModelForTokenClassification, AutoTokenizer
3
4model_id = "sheltron-ai/privacy-filter-ettin-32m"
5tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=True)
6model = AutoModelForTokenClassification.from_pretrained(model_id)
7model.eval()
8
9text = "Send the report to alice@example.com after review."
10encoded = tokenizer(
11 text,
12 return_tensors="pt",
13 return_offsets_mapping=True,
14 return_overflowing_tokens=True,
15 truncation=True,
16 max_length=512,
17 stride=128,
18 padding="max_length",
19)
20offsets = encoded.pop("offset_mapping")
21encoded.pop("overflow_to_sample_mapping", None)
22
23with torch.inference_mode():
24 logits = model(**encoded).logitsviterbi_calibration.json, then convert decoded token offsets into character spans and deduplicate
exact spans from overlapping windows.pip install onnxruntime transformers huggingface-hub numpy1from huggingface_hub import hf_hub_download
2import numpy as np
3import onnxruntime as ort
4from transformers import AutoTokenizer
5
6model_id = "sheltron-ai/privacy-filter-ettin-32m"
7filename = "onnx/model_quantized.onnx" # or model.onnx / model_fp16.onnx
8model_path = hf_hub_download(repo_id=model_id, filename=filename)
9
10providers = ["CPUExecutionProvider"]
11# For model_fp16.onnx use: providers = ["CUDAExecutionProvider"]
12session = ort.InferenceSession(model_path, providers=providers)
13tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=True)
14
15tokens = tokenizer(
16 "Send the report to alice@gmail.com after review.",
17 return_tensors="np",
18 truncation=True,
19 max_length=512,
20 padding="max_length",
21)
22input_names = {item.name for item in session.get_inputs()}
23inputs = {
24 key: np.asarray(value, dtype=np.int64)
25 for key, value in tokens.items()
26 if key in input_names
27}
28logits = session.run(None, inputs)[0]viterbi_calibration.json for the same post-processing contract as the Transformers path. ONNX
Runtime returns raw BIOES logits; constrained Viterbi decoding is required to reproduce the reported
span metrics for every precision variant, not only INT8.