Can Open-Source PII Filters Protect Documents Sent to LLMs?

Read on Terminal Reader

Earlier this year, Politico reported that the acting director of CISA, the US agency in charge of civilian cyber defence, had uploaded government contracting documents marked “for official use only” to ChatGPT, under an exception granted to him. The uploads set off the agency’s own automated security warnings (TechCrunch). If the head of the cyber agency can slip, anyone can.

The numbers point the same way. In October, the Russian data-loss-prevention vendor SearchInform published a survey of 120 security specialists in Moscow organisations (source, in Russian). 40% said their organisations had incidents through AI services in 2026, up from 6% a year earlier. The top motive, named by 78% of respondents, was wanting to get the work done faster and more easily. In a case reported in July, Moscow’s Babushkinsky District Court found lawful the dismissal of a sales director who had exported sales and payment reports from a corporate Power BI system and uploaded them to DeepSeek (case 02-1545/2026, Pravo.ru, in Russian). The court treated it as disclosure of a trade secret.

That case was about commercial data. But the contracts, CVs and letters people paste into chatbots also carry the personal data of clients and staff.

Banning the tools does not remove the reason people use them. The pragmatic answer is reversible pseudonymisation. Before the request, every name, passport number and address in the document becomes a placeholder such as [PERSON_1] or [PASSPORT_RU_1]. The model works on the placeholders. When the answer comes back, the placeholders are swapped for the real values locally, so the values the tool found never leave the machine.

Reversible pseudonymisation: what goes out and what stays with youReversible pseudonymisation: what goes out and what stays with you

Several open-source tools do the detection part. I wanted to know how far they can be trusted on documents that look like real work, so I built an open benchmark. The answer was uncomfortable.

The setup

Five open tools plus a regular-expression baseline with checksums: pii-guard, GLiNER Guard Omni, Microsoft Presidio, OpenAI privacy-filter and Prompt Anonymizer. Two languages: Russian and UK English. UK English matters because it has its own identifiers (NHS number, National Insurance number) and its own data-protection law.

No confidence thresholds were tuned on my data; they are the same for every set. Presidio has no Russian recognisers, so I added recognisers for the passport, SNILS, INN, bank account and Mir card. The settings of every tool are recorded in results/metrics.json.

Two kinds of data:

External datasets built by other people: hivetrace/pii-bench and redmadrobot’s pii_benchmark for Russian, Nemotron-PII with UK texts for English. In part of Nemotron-PII I replaced the labelled IDs, health plan and account numbers with synthetic NHS, National Insurance numbers and IBANs to test UK identifiers. Almost all identifiers in the external UK data come from that part, and the text around them is still American, which lowers identifier recall for every tool.
Synthetic documents that look like work: contracts, certificates, letters, HR files and hospital discharge summaries. Numbers are written with digits, with dots, with typos and in words. About 40% of documents contain a number in such a hard format.

I also build a competing engine, and a benchmark run by its author deserves suspicion. So the rules for the final set were fixed and published before it was run (the strict-leak and name-placeholder thresholds were added between earlier sets; HOLDOUT.en.md records when):

No home datasets. No tool gets a verdict on a dataset made by its own authors.

Thresholds announced in advance. At least 99% recall on strictly structured numbers and at least 95% on names, addresses and organisations. At most 2% of documents with a leak, and at most 2% with any value only partly hidden. After the model’s answer, at least 99% of placeholders restored correctly, and separately at least 99% of name placeholders.

Interval-based verdicts. A threshold is passed only if the whole 95% confidence interval is on the right side of it. If the interval covers the threshold, the result is undetermined. Intervals are Wilson for shares of documents and a bootstrap over answers for restoration.

A pre-registered held-out set. The final set was generated in advance, and its files, SHA-256 hashes, decision rules, run plan and stopping rule were published before the first run. Every tool ran on it exactly once; the engine and evaluator code in that run matches the published 0.5.0.

A strict definition of a leak. A document leaks if any original value survives cleaning: a number in any separator form (spaces, hyphens, dots, slashes), an address or organisation name in full, or, for a person, the surname in any grammatical case, or a first name or patronymic that remains more often than the same word appears outside personal data (June as a month in a date, for example).

On the external datasets, no existing tool met all thresholds. For UK English, the identifier and leak thresholds were missed. For Russian, the identifier result was undetermined: 97.7% [96.1; 99.0] for the best tool against a 99% threshold. For the best tools, leaks there were rare, though: pii-guard leaked in 0.7% of the short hivetrace messages, GLiNER Guard Omni in 4.0% of the UK texts (1.4% [0.8; 2.4] on the unmodified Nemotron-PII texts).

On the synthetic work documents it got much worse. This is the share of documents where at least one original value survived cleaning on the final held-out set, 1,000 documents per language, with 95% confidence intervals. All data types are counted here, organisation names included. Lower is better.

Tool

Russian

UK English

pii-guard

60.8% [57.7; 63.8]

not supported

GLiNER Guard Omni

99.6% [99.0; 99.8]

58.3% [55.2; 61.3]

Presidio

87.1% [84.9; 89.0]

61.1% [58.0; 64.1]

OpenAI privacy-filter

97.0% [95.7; 97.9]

81.1% [78.6; 83.4]

Prompt Anonymizer

not supported

100.0% [99.6; 100.0]

Regex with checksums

100.0% [99.6; 100.0]

100.0% [99.6; 100.0]

pii-roundtrip (my engine, below)

0.3% [0.1; 0.9]

0.2% [0.1; 0.7]

The regex baseline looks for numbers, emails and phone numbers only, so names and addresses leak in every document. Prompt Anonymizer is built for Japanese data and has no NHS or National Insurance recogniser, so its 100% says it does not fit the task, not that it is a bad tool. My engine was developed on documents from the same generator and the other tools were not, so the gap in this table is not the gap you would see on real documents.

Share of documents with a leak on the final held-out setShare of documents with a leak on the final held-out set

pii-guard and OpenAI privacy-filter do not look for organisation names at all, so the fair comparison counts only the types each tool claims to handle. On that basis the best results are pii-guard on Russian documents at 31.5% [28.7; 34.4] and OpenAI privacy-filter on UK documents at 33.0% [30.2; 36.0]. Even the best tool leaves personal data in about one document in three. This supported-types count is descriptive; it was not one of the pre-registered measures.

The cause differs by tool. For pii-guard, almost every leak in the types it supports comes from numbers in words, with dots or with typos: in Russian documents where every number is written the usual way, it leaked in 1 of 603, against 314 of 397 where some number was in a hard format. Those formats are in 40% of my documents because my generator puts them there, so the lesson for pii-guard is narrow: if your documents spell numbers out or write them with dots, it will miss them. OpenAI privacy-filter still leaks in 30.5% [26.9; 34.3] of UK documents with ordinary formats, and GLiNER Guard Omni, also leaving organisations out, in 32.2% [28.6; 36.0] (39.2% with organisations), so for the UK tools the result does not come down to hard formats.

What leaks, from the published examples: a card number on Russia’s Mir payment system spelled out in words, missed by Presidio, GLiNER Guard and OpenAI privacy-filter. A passport number written with dots (97.09.710811) and bank accounts with dots, missed by pii-guard. IBANs split with dots and National Insurance numbers with dots in UK documents. Names with initials in the body of a contract, missed by GLiNER Guard.

The engine

Since nothing passed, I built pii-roundtrip on top of the two strongest tools on the external datasets: pii-guard for Russian and GLiNER Guard Omni for both languages. Neither passes on its own, but they made the fewest mistakes there. On top of them sit my own rules:

identifiers checked by checksum (SNILS and INN, the Russian pension and tax numbers, bank cards, NHS, IBAN) or by format (Russian passport, National Insurance);
long numbers with any separator, and numbers spelled out in words;
organisations, sole traders, names with titles and initials, and dates of birth recognised by context;
consistency across the document and the conversation. Once a person is found, later mentions are hidden too, across grammatical cases, letter case and spelling variants.

Placeholders carry the type, such as [NHS_1], so the model can still reason about the text. The mapping lives in a local encrypted vault (AES-256-GCM, key derived from a password with scrypt).

Restoration is tolerant of what models do to placeholders: changed case, extra spaces, a lost bracket, or a title written inside the bracket, like [Mr PERSON_1]. Russian names are put into the grammatical case the answer needs. This is exactly where it failed, as you will see below.

On the same held-out set, the engine left an original value in 0.3% of Russian and 0.2% of UK documents and met every detection threshold in both languages. The strict count, where any partly hidden value counts, is 0.8% and 0.2%. It does not get there by hiding everything: 98.4% of the spans it hides in Russian documents and 99.8% in UK documents touch personal data.

It still leaks. In three Russian documents, organisation names with no legal form went through, such as “Akron”; no personal data of people leaked in Russian documents. In two UK documents, one misspelt word of a name stayed visible in a signature, such as “Frakn” from “Frakn Bond”.

Two different people almost never share a placeholder: at most two cases per 1,000 documents on the Russian development sets. The opposite error is much more common: version 0.5.1 splits one person into two placeholders 266 to 274 times per 1,000 documents (284 to 301 in 0.5.0). That leaks nothing, but the model may read one person as two.

Where the engine missed a threshold

For the full round trip I took 190 documents per language from the final set, two tasks per document, which gives 380 answers per model and language. Two local models, qwen3.5:9b and gemma4:12b, at temperature 0: clean the document, let the model answer, restore the answer. The run was interrupted once by a power cut and resumed with the same command from the stored answers; the Russian answers were complete by then, and the run journal is in the repository.

For UK English it passed. Name placeholders came back correctly in 99.97% of cases for the weaker model.

For Russian, name placeholders came back correctly in only 94.6% [93.6; 95.6] of cases for the weaker model. The 99% threshold was missed. The overall Russian restoration result for the weaker model (qwen3.5:9b) was undetermined at 98.9% [98.6; 99.1], and roughly one Russian answer in four (99 of 380 for one model, 100 of 380 for the other) contained at least one error.

I reviewed by hand all 288 failed name-placeholder occurrences in the Russian answers of both models (143 and 145). In 199 cases the name had been stored correctly but was inflected wrongly on the way back. In 82 it had been stored in the wrong form. In 7 the restored text was right and the evaluator was wrong (plus one such case in the UK answers).

Manual review of the 288 failed Russian name placeholdersManual review of the 288 failed Russian name placeholders

The main cause was how my engine inflected surnames. It handed them to pii-guard’s inflector, which took the first dictionary parse, and the pymorphy3 dictionary parses the surname “Kharitonov” first as the genitive plural of the first name “Khariton”. So it came back as “Kharitony”.

That set was the last held-out set for the paper, and the stopping rule had been published in advance, so the verdict stands: not passed. All final-set figures are for version 0.5.0. The fix shipped in 0.5.1 and 0.5.2, where the engine now builds word forms itself. With 0.5.2, on the stored answers of the same set (372 of 380 per model; 8 answers were skipped because the prompt changed in 0.5.1), Russian name placeholders are restored correctly in 99.3% of cases for both models, with intervals [98.8; 99.6] for qwen3.5:9b and [98.9; 99.7] for gemma4:12b. With 0.5.1 it was 98.7% and 99.2%, the figures in the README. Both are for reference only. I had already seen the set, and the interval still touches the threshold. The current release, 1.0.0, includes the 0.5.1 to 0.5.3 fixes. In 0.5.1, detection results on Russian sets 4 to 6 matched 0.5.0.

I left the failed verdict in the preprint and in the README. This is what a held-out set with a stopping rule declared in advance is for: without it you do not see the error. Better to find it in a results table than in a letter that opens “Dear Mr Smiths”.

What this does not prove

All evaluation data are synthetic and come from this project’s generator. Held-out sets protect against tuning to specific documents, not against tuning to the generator’s style. The engine was developed on six earlier sets from the same generator and on separate development data. The other tools were never tuned on them.

The engine was not tested on real documents.

I ran the benchmark myself, so I published the code, data, every tool’s predictions and the raw model answers for anyone to re-check.

pii-guard and GLiNER Guard, which the engine is built on, come from the authors of both Russian external datasets. I used those datasets to study errors while developing the first version, so for my engine they are not an independent test.

On short hivetrace messages, the engine over-masks more than pii-guard: 89.2% of the spans it hides contain personal data, against 96.5% for pii-guard.

The round trip was tested on two local models. Large cloud models may treat placeholders differently.

Try it

There is a desktop app for people who do not use a terminal: drop in a Word file, a PDF or text, send the cleaned version to any model, paste the answer back and get it with the real values. The models ship inside the installer, so it works offline from the first launch. The macOS app (Apple silicon, macOS 14 or later) is signed and notarised by Apple. The Windows build is in beta and its installer is not signed yet. Installers: https://github.com/beskvladimir-create/pii-roundtrip/releases

From the command line:

git clone https://github.com/beskvladimir-create/pii-roundtrip.git && cd pii-roundtrip
uv sync –extra all
uv run pii-roundtrip download-models
uv run pii-roundtrip anonymize -l en-GB -i letter.txt -o letter.clean.txt –vault letter.vault
# send letter.clean.txt to any model, save its answer as answer.txt
uv run pii-roundtrip restore -i answer.txt -o answer.restored.txt –vault letter.vault

The commands for the final held-out run are in HOLDOUT.en.md, under set 7, run plan. You need Ollama with the two models and about 20 GB of disk. The code is licensed under Apache 2.0.

Code: https://github.com/beskvladimir-create/pii-roundtrip
Preprint: https://arxiv.org/abs/2610.34012
Site: https://pii-roundtrip.besk.tech/
DOI: https://doi.org/10.5281/zenodo.23478192

If you have a document where the engine misses data or mangles a name, please open an issue with a synthetic example of the same kind. Real data is not needed.

CTO & CPO | Enterprise AI & Big Data at National Scale | Published AI Researcher (arXiv) | Author, “Enterprise AI: The KATA Way” (Amazon #1 in AI)