Views
No views yet
openai/privacy-filter is a bidirectional 1.5B-parameter / 50M-active sparse-MoE token classifier that tags personally identifiable information (PII) with BIOES spans over 8 categories (person, email, phone, URL, address, date, account number, secret).pip install mlx-embeddings1from itertools import groupby
2import mlx.core as mx
3from mlx_embeddings.utils import load
4
5model, tokenizer = load("mlx-community/openai-privacy-filter-mxfp8")
6id2label = model.config.id2label
7
8text = "My name is Alice Smith and my email is alice@example.com. Phone: 555-1234."
9inputs = tokenizer(text, return_tensors="mlx")
10
11outputs = model(inputs["input_ids"], attention_mask=inputs["attention_mask"])
12preds = mx.argmax(outputs.logits, axis=-1)[0].tolist()
13
14entity = lambda p: id2label[str(p)].split("-", 1)[-1] if id2label[str(p)] != "O" else None
15
16for ent, group in groupby(zip(inputs["input_ids"][0].tolist(), preds), key=lambda x: entity(x[1])):
17 if ent:
18 span = tokenizer.decode([tid for tid, _ in group]).strip()
19 print(f"{ent:18s} -> {span!r}")