Token Classification
Transformers
ONNX
xlm-roberta
pii
privacy
redaction
accessibility-tree
ocr
computer-use
agentic
screen-capture
screenpipe
Instructions to use screenpipe/pii-redactor with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use screenpipe/pii-redactor with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="screenpipe/pii-redactor")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("screenpipe/pii-redactor") model = AutoModelForTokenClassification.from_pretrained("screenpipe/pii-redactor", device_map="auto") - Notebooks
- Google Colab
- Kaggle
docs: rewrite card — screenpipe's own model (not OpenAI Privacy Filter), ScreenLeak numbers, demo link
Browse files6 unmodified lines789101112135 unmodified lines19202122232425268 unmodified lines353637383940414243444546474849505152535455565758592 unmodified lines62636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041054 unmodified lines1101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881896 unmodified lines- it- es- nllibrary_name: opfpipeline_tag: token-classificationtags:- pii5 unmodified lines- agentic- screen-capture- screenpipebase_model:- openai/privacy-filtermetrics:- f1- recall8 unmodified lines> A [screenpipe](https://screenpi.pe) project.A fine-tuned PII redactor for the **three surfaces an AI agent actuallysees a user's machine through**:1. **Accessibility-tree dumps** — the structured AX hierarchy macOS /Windows expose to assistive tech. Short, structured, often containinglabels like `AXButton[Send to marcus@helios-ai.io]`.2. **OCR'd screen text** — what tools like screenpipe extract fromscreen recordings. Mix of window-title-shaped artifacts, app chrome,and occasional long-form (emails, docs).3. **Computer-use traces** — what an agentic model (Claude Computer Use,GPT operator, etc.) reads when it controls a desktop.These surfaces are short, sparse-context, and full of identifiers thatslip past redactors trained on chat-style prose. This model is fine-tunedspecifically for them — while still handling long-form text atcompetitive accuracy.Built on top of the [OpenAI Privacy Filter](https://github.com/openai/privacy-filter)(1.5B parameters, 50M active).> **License: CC BY-NC 4.0** (non-commercial). For commercial use —> production redaction, SaaS / API embedding, AI-agent privacy2 unmodified lines## Headline numbers| | base OPF | **this model** ||---|---:|---:|| Accessibility / window-title PII zero-leak | 38.6% (33.6–43.8) | **79.1% (74.8–83.5)** || Long-form PII zero-leak (English) | 14.0% (11.7–16.2) | **77.5% (74.5–80.3)** || Long-form PII macro-F1 (English) | 0.591 | **0.934** || Targeted secret-redaction (34 realistic shapes) | not measured | **31/34** || p50 inference latency (CUDA) | ~23 ms | ~23 ms |95% bootstrap CIs in brackets. Zero-leak: % of cases where the modelcaught all gold spans (the metric that matters for privacy).## Why this exists (vs the base Privacy Filter)The OpenAI Privacy Filter (and most other public PII redactors) istrained on prose-shaped data. A typical accessibility-tree node, OCR'dwindow title, or computer-use log line looks nothing like that:```AXButton[Send to marcus@helios-ai.io]Welcome | Acme Corp | xAI Console[ScreenCapture 09:14] Slack — #compai-tessera (12 unread)```These are 30-character strings with one or two PII tokens and almostno surrounding context. A model trained on chat corpora will conflatebrand names with people, miss `Arc | Marcus Chen` because it expectssentence context, and tag `Raycast` and `Claude` as people.If you're building an **agentic system that reads screen state** — adesktop-control agent, a memory layer for browsing, anything thatstreams accessibility / OCR / screen-capture data into an LLM — thisis the redactor designed for that pipe.## What it doesSpan-level redaction. Given a string, returns `[(start, end, label, text)]`where each span is a region the model thinks is PII, classified into oneof 12 canonical categories:```private_person, private_email, private_phone, private_address,4 unmodified lines`secret` covers passwords, API keys, JWTs, DB connection strings,PRIVATE-KEY block markers, etc.## Inference```python# pip install opf (currently from source: github.com/openai/privacy-filter)from opf import OPFfilt = OPF(model="./model", device="cuda") # or "cpu"out = filt.redact("Welcome | Marcus Chen — Confluence")for span in out.detected_spans:print(f" [{span.start}:{span.end}] {span.label} = {span.text!r}")# -> [10:21] private_person = 'Marcus Chen'```See [`examples/inference.py`](examples/inference.py) for a longer examplecovering window titles, long-form text, and secrets.## MultilingualThis model handles 6 languages. Performance on a public long-form PIIbenchmark (n=200 per language):| Language | zero-leak ||---|---:|| English | 76.8% (70.1–83.1) || Spanish | 73.2% (66.5–79.3) || Italian | 70.8% (64.3–77.4) || German | 70.6% (63.5–77.1) || French | 68.1% (61.5–75.3) || Dutch | 56.1% (48.9–63.3) |Romance + Germanic languages drop −3 to −9 pp from English.**Dutch is the weakest** — flagged as a known gap.## Limitations1. **Sudo / login password prompts leak.** Pattern like `[sudo]password for alice: hunter2` results in the username being redactedbut the password surviving. One known hard miss in the targetedsecret probe; mitigate with an OS-level keystroke-suppression policyalongside this model.2. **Dutch is the weakest language** at −20.7 pp from English. Indic,Asian, African, Cyrillic scripts not evaluated at meaningful samplesizes — don't deploy without a locale-specific eval pass.3. **Synthetic training data only.** No real user data was used duringfine-tuning. Validate on YOUR data before deploying.4. **Oversmash.** 7.8% on accessibility / window titles, 16.5% onlong-form text. The model over-redacts. Acceptable for privacy-firstdeployments; flag if you need clean OCR text downstream.5. **Strict label-space evaluation.** The numbers above use a12-class taxonomy and a strict per-example zero-leak metric.Absolute values depend on the evaluator's label taxonomy and metricchoice; macro-F1 is a more lenient point of comparison.## Reproducing inference```bashgit clone https://huggingface.co/screenpipe/pii-redactorcd pii-redactorgit lfs pullpip install git+https://github.com/openai/privacy-filter.gitpython examples/inference.py```Reproducing the eval scores requires our held-out benchmark, which isnot redistributed. Contact **louis@screenpi.pe** for benchmark accessor commercial licensing.## License[CC BY-NC 4.0](LICENSE) — non-commercial use only. The base model isApache-2.0; obligations are preserved (see [`NOTICE`](NOTICE)).For commercial licensing (production deployment, redistribution rights,SaaS / API embedding, custom fine-tunes for your domain): **louis@screenpi.pe**.## Citation6 unmodified lines789101112135 unmodified lines1920212223248 unmodified lines3334353637383940414243444546474849505152535455562 unmodified lines596061626364656667686970717273747576777879808182838485868788894 unmodified lines9495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821836 unmodified lines- it- es- nllibrary_name: transformerspipeline_tag: token-classificationtags:- pii5 unmodified lines- agentic- screen-capture- screenpipemetrics:- f1- recall8 unmodified lines> A [screenpipe](https://screenpi.pe) project.screenpipe's own PII redactor, purpose-built for the **three surfaces anAI agent actually sees a user's machine through**:1. **Accessibility-tree dumps** — the structured AX hierarchy macOS /Windows expose to assistive tech. Short, structured, full of labelslike `AXButton[Send to marcus@helios-ai.io]`.2. **OCR'd screen text** — what tools like screenpipe extract from screenrecordings: window-title-shaped artifacts, app chrome, and theoccasional long-form email or doc.3. **Computer-use traces** — what an agentic model (Claude Computer Use,GPT operators, etc.) reads when it drives a desktop.These surfaces are short, sparse-context, and full of identifiers thatslip past redactors trained on chat-style prose. This is a compact,multilingual token classifier trained in-house specifically for them.**It is not OpenAI's Privacy Filter, and it is not a fine-tune of one** —it's screenpipe's own model. 278 MB INT8 ONNX, ~9 ms p50 on CPU, runsfully offline.> **License: CC BY-NC 4.0** (non-commercial). For commercial use —> production redaction, SaaS / API embedding, AI-agent privacy2 unmodified lines## Headline numbersOn [**ScreenLeak**](https://github.com/screenpipe/screenleak), our openbenchmark for PII redaction on screen telemetry — n=422 hand-labelleddesktop-telemetry strings, 13 categories, strict per-string zero-leak(every PII span in the string must be caught):| Model | Zero-leak | ||---|---:|---|| Gemini 3.1 Pro | 91.0% | cloud API || GPT-5.5 | 90.7% | cloud API || Claude Opus 4.7 | 87.8% | cloud API || **this model** ⭐ | **86.7%** | **local · 278 MB · ~9 ms CPU · $0/call** || Google Cloud DLP | 37.7% | cloud API || Microsoft Presidio | 35.4% | local OSS |Within a few points of the frontier APIs, ~50 points above the flagshipcommercial PII products — at zero per-call cost, fully offline. Fullmethodology, confidence intervals, and per-framework (HIPAA / GDPR /PCI DSS / …) breakdowns:[github.com/screenpipe/screenleak](https://github.com/screenpipe/screenleak).**Try it in your browser:** [screenpipe.github.io/screenleak/demo](https://screenpipe.github.io/screenleak/demo/).## What it doesSpan-level redaction. Given a string, returns the regions it thinks arePII, each classified into one of **12 canonical categories**:```private_person, private_email, private_phone, private_address,4 unmodified lines`secret` covers passwords, API keys, JWTs, DB connection strings,PRIVATE-KEY block markers, etc.> **Tip:** screenpipe redacts **each captured fragment independently**> (one AX node / OCR line / window title at a time) — that's the> distribution the model is tuned for. Feeding a giant multi-entity blob> in a single call degrades recall; split on natural boundaries first.## Inference**Browser (transformers.js):**```jsimport { pipeline } from "@huggingface/transformers";const pii = await pipeline("token-classification", "screenpipe/pii-redactor", { dtype: "q8" });const out = await pii("export OPENAI_API_KEY=sk-proj-Ab12Cd34Ef56Gh78");// out: per-token tags; group consecutive B-/I- tags into spans```**Python (transformers):**```python# pip install transformers torchfrom transformers import AutoTokenizer, AutoModelForTokenClassificationimport torchtok = AutoTokenizer.from_pretrained("screenpipe/pii-redactor")model = AutoModelForTokenClassification.from_pretrained("screenpipe/pii-redactor").eval()id2label = model.config.id2labeldef redact(text):enc = tok(text, return_offsets_mapping=True, return_tensors="pt", truncation=True)offsets = enc.pop("offset_mapping")[0].tolist()with torch.no_grad():pred = model(**enc).logits.argmax(-1)[0].tolist()# decode BIO from offsets + argmax (aggregation_strategy is unreliable# for this tokenizer — walk the offsets yourself)spans, cur = [], Nonefor (s, e), p in zip(offsets, pred):if s == e: # special tokencur = None; continuelab = id2label[p]if lab == "O":cur = None; continuebase = lab.split("-", 1)[-1]if cur and cur["label"] == base and not lab.startswith("B-"):cur["end"] = eelse:cur = {"start": s, "end": e, "label": base}; spans.append(cur)return [(d["start"], d["end"], d["label"], text[d["start"]:d["end"]]) for d in spans]print(redact("export OPENAI_API_KEY=sk-proj-Ab12Cd34Ef56Gh78"))# -> [(..., ..., 'secret', 'sk-proj-Ab12Cd34Ef56Gh78')]```Production INT8 ONNX weights are in [`onnx/`](onnx/) — load with`onnxruntime` on any platform (CoreML / DirectML / CUDA / CPU baseline);the same file ships everywhere.## MultilingualHandles 6 languages (en, fr, de, it, es, nl). English is strongest;Dutch is the weakest and is flagged as a known gap. Validate on yourlocale before deploying.## Limitations1. **Sudo / login password prompts can leak.** `[sudo] password foralice: hunter2` may redact the username but survive the password.Pair with an OS-level keystroke-suppression policy.2. **Multi-entity blobs degrade recall** — redact per captured fragment(see tip above), not one giant concatenated string.3. **Synthetic training data only.** No real user data was used. Validateon YOUR data before deploying.4. **Over-redaction (oversmash).** The model errs toward redacting — goodfor privacy-first deployments; flag it if you need clean textdownstream.5. **Strict zero-leak metric.** Absolute numbers depend on theevaluator's taxonomy and metric; macro-F1 is a more lenient lens.## License[CC BY-NC 4.0](LICENSE) — non-commercial use only. See [`NOTICE`](NOTICE)for third-party component attributions.For commercial licensing (production deployment, redistribution, SaaS /API embedding, custom fine-tunes for your domain): **louis@screenpi.pe**.## Citation
README.md+105-111