Tarn German PII base

Deutsch: Erkennt personenbezogene Daten in deutschen Texten: Namen, Anschriften, Kontaktdaten, Geburtsdaten, IBAN, Kreditkarten und alle deutschen Kennnummern von der Steuer-ID ΓΌber die Krankenversichertennummer bis zum FΓΌhrerschein. Die Labels sind die EntitΓ€tsnamen von Microsoft Presidio, das Modell lΓ€sst sich dort direkt einsetzen.

Detects 19 types of personal data in German text, including every German identifier that Presidio knows, with Presidio's entity names so it drops into existing anonymization pipelines. Trained only on synthetic data.

Try the demo: tarn-german-pii-base running fully in your browser with transformers.js, no text leaves your device.

Code, evaluation script and demo source: github.com/Syntriq-GmbH/tarn.

Quickstart

from transformers import pipeline

detector = pipeline("token-classification", model="syntriq/tarn-german-pii-base", aggregation_strategy="simple", stride=128)
detector("Frau Lena Schubert, Lindenallee 14, 04109 Leipzig, IBAN DE50 5260 1815 9083 0166 13, Steuer-ID 72659534808")

Strip leading and trailing whitespace from the returned spans and merge touching spans with the same label. Keep stride: without it the pipeline cuts every text after 512 tokens and misses all personal data behind that point.

Results

German PII benchmark (syntriq/german-pii-benchmark, 687 documents of 26 document types that do not occur in training, names and streets from a separate pool). Masked recall counts a personal value as protected when any predicted span overlaps it, regardless of the label. Strict F1 requires exact spans and labels.

Benchmark comparison

Model Size Labels covered Masked recall Masked precision Strict F1
syntriq/tarn-german-pii-base 125M 19 of 19 0.999 0.993 0.989
bardsai/eu-pii-anonimization-multilang 10 of 19 0.978 0.772 0.677
urchade/gliner_multi_pii-v1 19 of 19 0.892 0.875 0.687
openai/privacy-filter 5 of 19 0.887 0.671 0.462
tabularisai/eu-pii-safeguard 12 of 19 0.788 0.892 0.539
Presidio 2.2.366, German recognizers only rules 0.348 0.970 0.474

Our model is measured exactly as in the quickstart (transformers pipeline, stride=128, whitespace trimmed, touching spans merged), the other token classification models through the same pipeline with their labels mapped to ours, GLiNER through overlapping windows (baselines.py). Labels covered counts how many of our 19 labels a model has an equivalent for (mappings in baselines.py). Labels without an equivalent in our scheme still count for masked recall and precision, but strict F1 penalizes models that lack some of our labels, so masked recall is the fairest comparison. The benchmark is synthetic: document types, writer (a different LLM) and the pool of names and streets are unseen in training, but the identifier values come from the same generators as our training data, so real documents will score lower. Validate on a sample of your own data.

Per label (strict F1 on the benchmark):

Label F1 Support
PERSON 0.992 2957
ADDRESS 0.992 1063
EMAIL_ADDRESS 0.997 961
PHONE_NUMBER 0.999 837
CUSTOMER_ID 0.938 469
DATE_OF_BIRTH 0.997 448
IBAN_CODE 1.000 262
IP_ADDRESS 0.988 166
DE_TAX_ID 0.983 141
DE_ID_CARD 0.964 110
CREDIT_CARD 1.000 103
DE_KFZ 0.995 97
DE_HEALTH_INSURANCE 1.000 80
DE_TAX_NUMBER 0.948 76
DE_FUEHRERSCHEIN 1.000 66
DE_PASSPORT 0.968 61
DE_LANR 0.981 51
DE_SOCIAL_SECURITY 0.980 49
DE_BSNR 0.962 38

Labels

Label Covers Example
PERSON First names, last names, full names Lena Schubert
EMAIL_ADDRESS E-mail addresses lena.schubert@example.com
PHONE_NUMBER Landline, mobile and fax numbers 0341 2289441
ADDRESS Street with house number, optionally postcode and city Lindenallee 14, 04109 Leipzig
DATE_OF_BIRTH Birth dates, not other dates 12.03.1987
IBAN_CODE IBANs DE50 5260 1815 9083 0166 13
CREDIT_CARD Card numbers 4902 9657 3570 3469
IP_ADDRESS IPv4 and IPv6 203.0.113.42
CUSTOMER_ID Customer, contract and member numbers 991.819.270
DE_TAX_ID Steuerliche Identifikationsnummer 72659534808
DE_TAX_NUMBER Steuernummer 5112023779437
DE_SOCIAL_SECURITY Rentenversicherungsnummer 99 140874 X 984
DE_HEALTH_INSURANCE Krankenversichertennummer K118609133
DE_ID_CARD Personalausweisnummer M02FX24C6
DE_PASSPORT Reisepassnummer CFM91LR65
DE_FUEHRERSCHEIN FΓΌhrerscheinnummer B072RRE2I55
DE_KFZ Licence plates WOB YG 9337
DE_LANR Lebenslange Arztnummer 375101702
DE_BSNR BetriebsstΓ€ttennummer 019802357

Company names, cities on their own, invoice numbers, file numbers and VAT IDs are not personal data in this scheme and stay unlabeled.

Microsoft Presidio

Save as german-pii.yaml:

nlp_engine_name: transformers
models:
  - lang_code: de
    model_name:
      spacy: de_core_news_md
      transformers: syntriq/tarn-german-pii-base
ner_model_configuration:
  labels_to_ignore: [O]
  aggregation_strategy: simple
  stride: 16
  alignment_mode: expand
  model_to_presidio_entity_mapping:
    PERSON: PERSON
    EMAIL_ADDRESS: EMAIL_ADDRESS
    PHONE_NUMBER: PHONE_NUMBER
    ADDRESS: LOCATION
    DATE_OF_BIRTH: DATE_OF_BIRTH
    IBAN_CODE: IBAN_CODE
    CREDIT_CARD: CREDIT_CARD
    IP_ADDRESS: IP_ADDRESS
    CUSTOMER_ID: CUSTOMER_ID
    DE_TAX_ID: DE_TAX_ID
    DE_TAX_NUMBER: DE_TAX_NUMBER
    DE_SOCIAL_SECURITY: DE_SOCIAL_SECURITY
    DE_HEALTH_INSURANCE: DE_HEALTH_INSURANCE
    DE_ID_CARD: DE_ID_CARD
    DE_PASSPORT: DE_PASSPORT
    DE_FUEHRERSCHEIN: DE_FUEHRERSCHEIN
    DE_KFZ: DE_KFZ
    DE_LANR: DE_LANR
    DE_BSNR: DE_BSNR
  low_confidence_score_multiplier: 1.0
  low_score_entity_names: []
from presidio_analyzer import AnalyzerEngine
from presidio_analyzer.nlp_engine import NlpEngineProvider

engine = NlpEngineProvider(conf_file="german-pii.yaml").create_engine()
analyzer = AnalyzerEngine(nlp_engine=engine, supported_languages=["de"])
analyzer.analyze("Frau Lena Schubert, Steuer-ID 72659534808", language="de")

Presidio's own German recognizers can run on top. In Presidio 2.2.366 two of them have known gaps: the driving licence pattern does not match the official format, and ID card and passport numbers get the same score after validation, so Presidio cannot tell them apart.

ONNX and transformers.js

onnx/model.onnx (fp32, identical to PyTorch on the validation set) and onnx/model_quantized.onnx (int8, 127 MB, F1 0.9997 against 0.9997 for PyTorch on 300 validation documents).

from optimum.onnxruntime import ORTModelForTokenClassification
from transformers import AutoTokenizer, pipeline

model = ORTModelForTokenClassification.from_pretrained("syntriq/tarn-german-pii-base", subfolder="onnx", file_name="model_quantized.onnx")
detector = pipeline("token-classification", model=model, tokenizer=AutoTokenizer.from_pretrained("syntriq/tarn-german-pii-base"), aggregation_strategy="simple", stride=128)

Intended use and limitations

  • Built for redacting German business documents, e-mails, tickets, chat logs and forms before they are stored, shared or sent to an LLM.
  • Trained on synthetic documents. Real documents with unusual layouts, heavy OCR noise or dialect can lower recall. Check a sample of your own data before relying on it.
  • Detection is not anonymization in the legal sense. Combine it with human review where the GDPR requires certainty.
  • Austrian and Swiss formats are covered for names, addresses, phone numbers and IBANs, not for their national identifiers.

Training data

49,350 synthetic German documents of 68 types (letters, invoices, contracts, medical forms, HR files, tickets, chats, CSV exports and more) in 12 styles, 8 of the types without any personal data. DeepSeek 4.1 Flash wrote templates with placeholders, the values come from Faker and from generators that follow the official formats and check digits (Steuer-ID ISO 7064, KVNR, Rentenversicherungsnummer, ICAO document numbers, FeV driving licence numbers, ELSTER tax numbers, LANR, BSNR). Names follow the mix of origins in Germany. No real personal data was used at any point.

Training

Fine-tuned from GeistBERT/GeistBERT_base on one NVIDIA B200, 3 epochs, learning rate 5e-05, batch size 32, windows of 512 tokens with stride 128, bf16. Checkpoint selected on the validation split only, test and benchmark evaluated once.

License and citation

Apache-2.0. Base model: MIT.

@misc{syntriq2026germanpii,
  title  = {Tarn German PII},
  author = {Syntriq Labs},
  year   = {2026},
  url    = {https://huggingface.co/syntriq/tarn-german-pii-base}
}
Downloads last month
108
Safetensors
Model size
0.1B params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for syntriq/tarn-german-pii-base

Quantized
(1)
this model

Space using syntriq/tarn-german-pii-base 1