Releasing Tarnkappe: why I trained my own model for finding personal data
Tarnkappe is out. It’s a small, open model that finds personal data in web pages: people, organisations, emails, phone numbers, addresses. I built it for BetterPrivacy.me, because I wasn’t happy with what was already out there. The models were either not good enough or needed far too many resources, and it had to work properly in German too.
Open source
Get the code and the model on GitHub →
Apache 2.0 code, open weights, the training script and every benchmark.
The model itself is also on Hugging Face.
What I didn’t like about the others
A BetterPrivacy scan reads a lot of pages about one person and has to point at the parts that are personal data. There are good open models for that. GLiNER multi PII has about 278 million parameters, GLiNER2-PII about 300 million, NVIDIA’s GLiNER-PII 570 million, OpenAI’s Privacy Filter 1.5 billion. On a normal CPU the GLiNER models took around 200 milliseconds for one short text. Multiply that by every snippet on every page of every scan and you need GPUs, or a lot of patience.
Two of them are also mostly English. A lot of what a scan finds about someone in Germany or Austria is German: an Impressum, a Handelsregister entry, a local newspaper.
So I set myself a few rules: it runs on a CPU, it keeps text in memory and never stores it, it handles English and German, and it’s fast enough that nobody notices it.
Small on purpose
Tarnkappe (the German word for a cloak that makes you invisible) has 2.5 million parameters. That’s about a hundred times smaller than the GLiNER models. The model file is 5 MB, plus 25 MB of word vectors, and a short text takes about 1.5 milliseconds on one CPU core.
It works in layers. Anything with a fixed shape is caught without a neural network: emails and IP addresses by pattern, IBANs by their checksum, card numbers by the Luhn check, phone numbers with Google’s libphonenumber. The small network then reads the text for the parts that need context: names, organisations, streets and places. A few rules clean up after it, like “anything followed by GmbH or Ltd is a company”. And because a scan is many pages about the same person, names found with confidence on one page help on the others.
No real personal data went into training. It learned from public English and German corpora, generated sentences, and Wikipedia paragraphs labelled by GLiNER2-PII, the big model, keeping only the labels it was sure about.
Labelling, a lot of it
Public benchmarks only get you so far. They are newspaper text and tweets, not the strange mix of menus, footers, imprints and profile pages a scan finds. So I built a small labelling page and went through real snippets from BetterPrivacy scans, word by word: tap a name to mark it as a person, tap a company to mark it as a company.
The scans came from people who agreed to be scanned for this. Their texts stay private and are only used for testing, never for training. When I wrote this, there were about 250 hand-labelled snippets.
The rule that made the numbers worth anything: the model’s answers are saved before I label a new batch. So my labels can’t drift towards what the model said, and each batch is a clean test exactly once. After that I’ve seen its mistakes, so it becomes development data.
Nine days, seven releases
The first tagged version, v0.2, came out on 18 November, and v0.7.1 nine days later. People were good from the start. Organisations were the hard part, so that’s what most releases were about.
- v0.3 was retrained for web pages. It found almost every company, but only about a third of what it called a company was one. Medical terms, street names and user names all got flagged.
- v0.4 added a second, tiny check (107 KB) that looks at every company detection again. Correct detections went from 62% to 87%, but it still found too few.
- v0.5 added rules like “worked at X” and “bei X”. On the pages I tuned them on, companies found jumped to 86%. On fresh pages it was 67%. The 86% came from tuning on a small sample, and a small sample tells you what you want to hear.
- v0.6 retrained the model with thousands of examples of organisations in running text, and wrote down what counts as one: anything a person can work for or belong to.
- v0.7 added a list of about 250 well-known organisations that rarely carry a legal form: parties, broadcasters, newspapers, public bodies.
- v0.7.1 is the same detector, tested on the largest clean batch at the time: 45 snippets with 141 organisations and 60 persons. It finds 87.9% of organisations, and 89.9% of its organisation detections are correct. Persons: 100% found, 92.1% correct. That passes the release bar I set at the start for the first time.
Phone numbers got their own test along the way: 1,000 synthetic European phone sentences from 40 countries, never looked at while tuning. Tarnkappe finds 99.2% of them, with no false phone hits.
Against the big models
I ran the two GLiNER models on the same 400 texts per test set, on the same machine, against Tarnkappe v0.7.
On edited text, in English and German, Tarnkappe finds about as many people as GLiNER2-PII, roughly twice as much of what it flags is actually a person, and it’s about a hundred times faster. The big models mark words like “I”, “owner” or “Menschen” as people.
It isn’t better everywhere. On social media the GLiNER models find more people (92 to 96% against 85%), and GLiNER2-PII is strong on addresses, postcodes and organisations. For scanning web pages on a CPU, though, the trade is worth it for me.
What it still gets wrong
These are the usual misses in v0.7.1:
- Small startup and event names without any context. Some get taken for people.
- Job-title fragments like “Platform Solutions” marked as companies.
- Political news and blogs: on a smaller test of those pages, it found 71% of organisations, not 88%.
- Tweets and chat are harder than web pages.
It finds most of the personal data in a text. That makes it a good tool for minimising data, not a guarantee that something is anonymous.
Try it, and tell me where it fails
pip install "git+https://github.com/ncserny/betterprivacy-tarnkappe"
from tarnkappe import Detector
Detector().redact("Call Thomas Weber on +49 30 1234567")
# 'Call [FIRST_NAME] [LAST_NAME] on [PHONE]'
The code is Apache 2.0, the weights CC BY-SA 4.0, because part of the training data carries that licence. Both allow commercial use. If you only want the model, you can download it on Hugging Face without cloning the repository.
Every version Read the release notes → The numbers for every version, the test rules and what is still missed.I’m happy to get your feedback, especially texts where it misses something. Open an issue on GitHub, or write to me on LinkedIn or X.