Skip to content

/work · In production use

Schwärzwerk

German DSGVO redaction that survives German text: regex over official formats wins on overlap, a GLiNER2 model catches the rest. Measured F1 0.916, in production at firms.

Python · GLiNER2 · PyTorch · mDeBERTa · Regex-Hybrid · Kaggle T4

Problem

Companies in Germany copy personal data all day: into support tickets, into test systems, into vendor handoffs. GDPR does not grade the effort; it demands the data be gone before the copy leaves the building. The tools sold for this job fail on German text.

The failure has a shape: international detectors know US formats and English names, then stall on Sozialversicherungsnummer, Steuer-Identifikationsnummer, KVNR and Kfz-Kennzeichen. PIIBench 2026, the broadest public benchmark, lines up eight systems: every one lands below F1 0.14, Microsoft Presidio as the best reaches 0.1385 and finds nothing on most types. A German evaluation does not exist in that benchmark at all. The commercial suites charge enterprise money regardless.

Architecture: two layers, clear responsibility

The core decision is which layer decides. Official German identifiers have published formats, and that is exactly why they belong in a deterministic regex layer: 14 pattern groups covering SVNR, Steuer-Identifikationsnummer, W-IdNr, Personalausweis and Reisepass numbers (distinguishable by letter pool since November 2021), KVNR, license plates and the rest. Where regex and model overlap, regex wins. Where a specification exists, deterministic beats probabilistic.

The machine-learning layer takes what has no format: names, free-form addresses, passwords in context. It is a fine-tuned GLiNER2 model, 307 million parameters on an mDeBERTa backbone, trained for the 17 PII types. Post-processing merges the fragments a tokenizer leaves behind: the house number that drifts off its street, the title that separates from its name.

The split also settles the LLM question. A general language model decides nothing here; it helped map formats and draft paraphrases, and it confused the Steuernummer with every other digit run on the page. The first version, model only, scored F1 0.452 on tax IDs. Every pattern in the final regex layer was checked by hand against the official specification.

Data: synthetic, 50,000+ examples

Real client documents are the one material this project refuses to train on; the whole point is redacting that material later. So the training corpus is synthetic: 50,000+ examples from pattern families, addresses in German, Austrian and Swiss spellings, Steuernummer in old and unified form, credit cards, driver licences, KVNR, plates, IPs, URLs, passwords, plus realistic negatives.

The generators encode the official specifications and follow their changes: the number pools that split Personalausweis from Reisepass are the post-November-2021 rules. Public corpora fill the spots where free text is missing. A held-out benchmark of 188 examples covers all 17 types with edge cases: name-like strings in non-PII roles, partial IBANs, mixed-context sentences.

Training: five epochs on Kaggle's free T4

Training runs on Kaggle's free T4 tier, a 16 GB GPU that still fits a full fine-tune of 307 million parameters. A run takes about half an hour across five or more epochs, with fp16, a cosine schedule, warmup and early stopping. The GPU is the cheapest part of this project.

The knobs mattered more than the hardware. The second version shipped learning rates ten to a hundred times below the GLiNER2 recommendations and a training set without a single text free of PII, so the model saw personal data everywhere it looked. Naming those bugs bought more F1 than any extra epoch.

Results (measured) & deployment

The current build measures F1 0.916 on the 188-example benchmark. The weak spots are on the record: person at 0.87 and address at 0.86, both dragged down by precision (0.775 and 0.750), password at 0.74. The target for the next data revision is F1 0.95, and the fix list is already written: learning rates, negative examples, English label descriptions.

The system runs in production at firms, as a CLI over documents and ticket text: regex-only mode for the structured fields, the model for the rest, every redaction as a category placeholder. It has not been released as open source yet; commercial use goes through info@dimitripisarev.com. A public model card and a hosted API are the next steps.