# Releasing Tarnkappe: why I trained my own model for finding personal data

> The open models for finding names, companies and phone numbers in text were either too heavy to run or not good enough, especially in German. So I trained my own, and it's out now.
- **Author**: Nader Cserny
- **Published**: 2026-11-27
- **URL**: https://nader.io/posts/why-i-trained-tarnkappe

---

[Tarnkappe is out](https://github.com/ncserny/betterprivacy-tarnkappe/releases/latest). 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](https://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.

<img src="/posts/why-i-trained-tarnkappe.webp" alt="A typed German letter on a sheet of paper, with the name, IBAN, street, postcode, email, phone number and company blacked out and each marked with a red label." width="1200" height="630" class="post-hero" />

<a class="post-cta" href="https://github.com/ncserny/betterprivacy-tarnkappe">
  <span class="post-cta__eyebrow">Open source</span>
  <span class="post-cta__title">Get the code and the model on GitHub -></span>
  <span class="post-cta__line">Apache 2.0 code, open weights, the training script and every benchmark.</span>
</a>

The model itself is also on [Hugging Face](https://huggingface.co/ndrcsr/tarnkappe).

## 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.

<figure class="post-wide">
  <img src="/posts/tarnkappe-labelling.webp" alt="The labelling page in dark mode. An invented German imprint for a yoga studio: the studio name is marked orange as a company, the owner's name purple as a person, and the street, postcode, city, phone number and email are underlined in dotted green as other types the model found. Below are buttons to add texts and copy the labelled texts." width="787" height="731" loading="lazy" decoding="async" />
  <figcaption>The labelling page, with an invented imprint. Purple is a person, orange a company, green the rest.</figcaption>
</figure>

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.

<figure class="post-wide">
  <img src="/posts/tarnkappe-progress.webp" alt="Line chart of organisations on real web pages for six releases. Organisations found, in red: 92.3% in v0.3, then 62%, 67%, 68%, 71% and 87.9% in v0.7.1. Organisation detections correct, in black: 34.3% in v0.3, then 87%, 79%, 90%, 97% and 89.9% in v0.7.1. Dashed lines mark the release bar at 80% found and 85% correct. Each release was tested on a new set of pages, from 13 to 141 organisations." width="2400" height="1352" loading="lazy" decoding="async" />
  <figcaption>Every point is a different, fresh set of pages, so the line is a rough trend, not a lab measurement.</figcaption>
</figure>

- **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.

<figure class="post-wide">
  <img src="/posts/tarnkappe-compare.webp" alt="Bar chart comparing Tarnkappe, GLiNER2-PII and GLiNER multi PII v1 on four test sets. Persons found are close on English web text and German news (all between 94% and 99%), and lower for Tarnkappe on social media (84.9% against 95.8% and 92.4%). Person detections correct are much higher for Tarnkappe on edited text: 75.5% against 39.7% and 31.4% on English web text, 76.2% against 45.4% and 48.3% on GermEval, 82.3% against 48.0% and 51.4% on German news, and 45.4% against about 40% on social media. Speed: 1.5 to 2.8 ms per text for Tarnkappe, about 184 to 228 ms for the GLiNER models." width="2400" height="1488" loading="lazy" decoding="async" />
</figure>

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

```bash
pip install "git+https://github.com/ncserny/betterprivacy-tarnkappe"
```

```python
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](https://huggingface.co/ndrcsr/tarnkappe) without cloning the repository.

<a class="post-cta" href="https://github.com/ncserny/betterprivacy-tarnkappe/releases">
  <span class="post-cta__eyebrow">Every version</span>
  <span class="post-cta__title">Read the release notes -></span>
  <span class="post-cta__line">The numbers for every version, the test rules and what is still missed.</span>
</a>

I'm happy to get your feedback, especially texts where it misses something. Open an issue on [GitHub](https://github.com/ncserny/betterprivacy-tarnkappe/issues), or write to me on [LinkedIn](https://www.linkedin.com/in/nadercserny/) or [X](https://x.com/nadcsr).

---
- [All articles](https://nader.io/posts)