# Redact Docs: A Tunable, Local PII Scrubber

> Source: <https://www.rickmanelius.com/p/redact-docs-a-tunable-local-pii-scrubber>
> Published: 2026-11-27 09:00:59+00:00

**Recommendation:** Constrain small-model PII detection to closed-set classification of code-extracted capitalized words instead of open-ended search, and rerun the pinned tool version on the same machine to reproduce what it redacted.
More in the playbook "Verifying model output": <https://wpnews.pro/playbooks/output-verification>

Several of my clients, across financial services, investment, insurance, and health, have the same need. Before a document touches an AI model, you have to extract the personal information: names, birth dates, Social Security numbers, member IDs, addresses, account numbers. And it has to happen on their own machines, so the raw documents never go to anyone’s cloud.

It’s the same logic as credit card numbers. The less of it you send, the less can leak. Scrub the PII before it ever reaches the prompt, and you can be far more confident it won’t come out the other side.

I wanted a tool I could read line by line, tune for each client, and measure: run it on a test document, count what slips through, change one rule, count again. So I built one. It’s called redact-docs, it’s free and open source on [GitHub](https://github.com/rickmanelius/nexus), and one of those clients is about to run it in production.

## What it does

You give it a PDF, a Word file, a spreadsheet or a text file. It gives back the same document as Markdown with every personal value swapped for a placeholder, plus a table of what it swapped:

``` php
Patient Name: Eleanor Marguerite Whitfield   ->   Patient Name: [PERSON_1]
SSN: 987-65-4320                             ->   SSN: [SSN_1]
Mobile: 312-555-0187                         ->   Mobile: [PHONE_2]
```

(Every value in this post is from a fictitious test form.) Labels stay, and values go, and a value gets the same placeholder everywhere it appears, so the cleaned document still reads correctly.

## Why NexusRun

Writing the code was the easy part. The hard part of handing a client an AI tool is everything around it: which model file, which version, which runtime, which Python packages, and whether what runs on their laptop is what I tested on mine.

[NexusRun](https://nexusrun.dev) handles that. It packages an AI tool as a single artifact, called a unit: the code, plus a manifest that names each model by its exact source and checksum. nexus pull fetches the unit (1.9 MB here), nexus install downloads and checks the models (2.7 GB, once), and nexus run runs it. In short, it packages the entire solution into a repeatable building block.

My client gets the same artifact I tested, and when I change something, I publish a new version while the old one stays exactly as it was. For a privacy tool, that matters most: if someone asks what it did to a document last Tuesday, I can rerun that version on that file, on the same machine, and get the same output.

## How it finds personal information

Three layers run in a fixed order, and each one only sees what the earlier ones left:

1. Rules catch formats that give themselves away (emails, phone numbers, dates, IP addresses, SSNs, card numbers, Medicare IDs) and numbers that only count next to a label, like routing and member IDs, even when their checksum fails.
2. A classifier, [GLiNER-PII](https://huggingface.co/knowledgator/gliner-pii-base-v1.0) , tags names, addresses, and organizations.
3. A local language model, Qwen3-4B through llama.cpp, looks at whatever the first two missed.

I expected the language model to be the strongest layer. At first it was the weakest. When I asked it to list any personal information still visible, it flagged field labels like “Member ID” as personal data, called drug names ID numbers, and echoed the example from my own prompt until it ran out of room. A 4-billion-parameter model is bad at open-ended searching.

So I changed the question. Now the code pulls out the capitalized words still visible, and the model answers one thing for each: person, place, organization, or none. It can’t invent or rewrite text, and every string it flags is one the code already found. With that change, it caught three organizations the classifier had missed or half-caught (an insurance carrier, a bank, and a pharmacy), and it left every drug and diagnosis alone.

When anything fails, the tool stops and prints one line naming the step. It never puts document text in an error, not even the file name, since file names are often client names.

## How well it works

I tested it on a five-page fictitious clinic intake form with 133 planted values, built to be awkward: names inside sentences, a Social Security number spelled out in words, a phone number the PDF converter splits across two lines, and people whose names are ordinary words (Hope, Joy, June, Faith).

None of the 94 values it is meant to remove survive, even counting partial leaks like a surname left beside a placeholder. The off-the-shelf model I started with left 66 of the form’s 109 distinct planted values untouched. It gave identical output every run, worked with the network switched off, and took about 15 seconds on an Apple M4 Pro.

That’s one hand-made form, not a benchmark. A larger test set is next. Until then, check its output on your own documents.

## Tuning it for each client

This is why I built it instead of buying it. Each client gets a small profile:

```
{  
  “name”: “client-a”,
  “base”: “strict”,
  “disable”: [”OCCUPATION”],
  “classes”: [{”id”: “CLAIM_NUMBER”, “tag”: “CLAIM”, “tier”: “A”, “name”: “Claim number”}],
  “patterns”: [{”class”: “CLAIM_NUMBER”, “regex”: “CLM-\\d{4}-\\d{6}”}],
  “deny”: [{”class”: “PERSON”, “term”: “Jordan Example”}],
  “allow”: [”Example Mutual Health”]
}
```

A profile can add a client’s own ID formats, list names that must always go (staff) or terms that must stay (their own product names), and switch off context categories they don’t need. It can’t switch off direct identifiers like names and SSNs. The profile lives on the client’s machine, never in the public repo, because a list of staff names is personal data too.

My default is to over-redact. If something might identify a person, it goes. A client can loosen a rule later. You can’t take back a leak.

## Try it

You need a Mac with Apple Silicon and [Homebrew](https://brew.sh). Install nexus v0.1.0 with the steps in the [repo’s quickstart](https://github.com/rickmanelius/nexus#quickstart), then:

```
brew install llama.cpp python@3.14
nexus pull ghcr.io/rickmanelius/redact-docs:1.0.0
nexus install --yes redact-docs:1.0.0
nexus run --no-daemon --no-sandbox redact-docs:1.0.0 -p “[selftest]”
```

The last command cleans the fictitious form bundled with the tool, checks the result against its answer key, and ends with selftest: ... passed. To clean your own file:

```
nexus run --no-daemon --no-sandbox redact-docs:1.0.0 -p “@$PWD/my-document.pdf” > cleaned.md
```

The full source is at [github.com/rickmanelius/nexus](https://github.com/rickmanelius/nexus), so you can read exactly what runs before you run it.

## What it doesn’t do yet

It has no OCR, so it needs documents with real text, in English. It judges each value on its own, so a rare mix of harmless details (a small town, an exact age, a job title) can still point to one person. On a Mac, “nothing leaves the machine” rests on the tool’s own code, which you can read; a sealed build that needs no network at all is next. And I haven’t tested it on Linux yet.

## What’s next

First, the production run with one client. Then the sealed build, and a bigger test set so the leak rate I publish comes from more than one form. If you try it, tell me what it missed. [Issues are open](https://github.com/rickmanelius/nexus/issues).
