A fine-tuned jhu-clsp/mmBERT-base model with a CRF layer for Personally Identifiable Information (PII) detection in multilingual dialogues across 11 languages.
Model Description
This model performs token-level Named Entity Recognition (NER) to identify and classify PII entities in dialogue text. It was trained on synthetic multilingual de-identification of conversational data.
Architecture: mmBERT-base (ModernBERT) + CRF head with FLERT context windowing
Training: Fine-tuned on all 11 languages jointly (multilingual training) using FLERT-style document context
Context window: 2 sentences left + 2 sentences right, separated by [SEP] markers
Decoding: Viterbi decoding via CRF layer
Supported Languages
Code
Language
AR
Arabic
DE
German
EN
English
FI
Finnish
FR
French
HI
Hindi
IT
Italian
PL
Polish
PT
Portuguese
SP
Spanish
TR
Turkish
Entity Types
The model recognizes 19 PII entity types using BIO tagging:
Entity
Description
PERSON
Person names
PERSON_EMAIL
Email addresses
PERSON_SOCIAL_RELATION
Social relations (e.g., "my wife")
ORG
Organizations
LOC_CITY
Cities
LOC_COUNTRY
Countries
LOC_STREET
Street names
LOC_ZIP
ZIP/postal codes
LOC_HOUSENUMBER
House numbers
LOC_OTHER
Other locations
DATETIME
Dates and times
DATETIME_AGE
Ages
CODE
ID numbers, reference codes
CODE_PHONE
Phone numbers
CODE_URL
URLs
PROFESSION
Professions
PRODUCT
Product names
QUANTITY
Quantities
MISC
Miscellaneous PII
Performance
Evaluated on held-out test sets per language (type-aware micro scores):
Language
Len P
Len R
Len F1
Len F2
Ex P
Ex R
Ex F1
Ex F2
AR
87.87
73.15
79.84
75.69
84.45
70.30
76.73
72.74
DE
94.12
90.66
92.36
91.33
93.33
89.90
91.58
90.56
EN
94.93
93.45
94.18
93.74
92.41
90.97
91.69
91.25
FI
91.36
88.46
89.89
89.03
89.93
87.07
88.48
87.63
FR
90.91
88.09
89.48
88.64
87.66
84.94
86.28
85.47
HI
87.55
82.33
84.86
83.33
83.37
78.40
80.81
79.35
IT
93.57
87.81
90.60
88.90
90.72
85.13
87.84
86.19
PL
90.11
90.31
90.21
90.27
87.41
87.61
87.51
87.57
PT
91.10
90.69
90.90
90.77
89.28
88.88
89.08
88.96
SP
93.06
91.47
92.26
91.79
91.30
89.74
90.51
90.05
TR
89.13
86.53
87.81
87.04
85.79
83.29
84.52
83.78
AVG
91.25
87.54
89.31
88.23
88.70
85.11
86.82
85.78
Usage
This model uses a custom CRF architecture with FLERT-style context windowing and cannot be loaded directly with AutoModelForTokenClassification. You need to use the custom ModernBertCRF class.
Note: The config.json in this repo exists solely for Hugging Face download tracking. For model loading, use crf_config.json and flert_config.json instead.
The model was trained using FLERT-style context windowing over sentence-level input. Each sentence is predicted with surrounding context sentences. For best results, split your input into sentences using spaCy before inference.
python
1nlp = spacy.blank("en")# use "de" for German, "xx" for multilingual2nlp.add_pipe("sentencizer")34defsplit_dialogue(text, nlp):5 sentences =[]6for line in text.strip().splitlines():7 m = re.match(r"^(SPEAKER_\d+)\s*:\s*(.*)", line.strip())8if m:9 speaker, rest = m.group(1), m.group(2)10 sentences.append([speaker,":"])11 line = rest
12ifnot line:13continue14 doc = nlp(line)15for sent in doc.sents:16 tokens =[tok.text for tok in sent ifnot tok.is_space]17if tokens:18 sentences.append(tokens)19return sentences
2021# Example22raw ="""SPEAKER_00: Hello, my name is Peter.
23SPEAKER_01: Hello, my name is Peter as well. Okay, and where do you come from? I come from Chicago."""2425sentences = split_dialogue(raw, nlp)
Inference with FLERT Context Windowing
The key difference from standard token classification: each sentence is predicted within a window of surrounding context sentences, joined by [SEP] tokens. Only labels for the target sentence are extracted.
python
1defpredict_dialogue(sentences, model, tokenizer, id2label,2 context_window=2, use_sep_marker=True, device="cpu"):3 sep = tokenizer.sep_token
4 all_labels =[]5for i, target_tokens inenumerate(sentences):6 left = sentences[max(0, i - context_window):i]7 right = sentences[i +1:i +1+ context_window]89 flat_tokens =[]10for s in left:11 flat_tokens.extend(s)12if use_sep_marker and left:13 flat_tokens.append(sep)1415 tgt_start =len(flat_tokens)16 flat_tokens.extend(target_tokens)17 tgt_end =len(flat_tokens)1819if use_sep_marker and right:20 flat_tokens.append(sep)21for s in right:22 flat_tokens.extend(s)2324 enc = tokenizer(flat_tokens, is_split_into_words=True,25 return_tensors="pt", truncation=False).to(device)26 word_ids = enc.word_ids(batch_index=0)2728with torch.no_grad():29 emissions = model(**enc)["logits"]30 mask = enc["attention_mask"].bool()31 preds = model.decode(emissions, mask)[0]3233 word_labels =["O"]*len(target_tokens)34 seen =set()35for idx, wid inenumerate(word_ids):36if wid isNoneor wid in seen:37continue38 seen.add(wid)39if tgt_start <= wid < tgt_end:40 word_labels[wid - tgt_start]= id2label[preds[idx]]4142 all_labels.append(word_labels)43return all_labels
444546# Run prediction47results = predict_dialogue(sentences, model, tokenizer, id2label,48 context_window=context_window,49 use_sep_marker=use_sep_marker)5051for sent_tokens, sent_labels inzip(sentences, results):52for token, label inzip(sent_tokens, sent_labels):53if label !="O":54print(f"{token:20s} -> {label}")
Single-sentence inference
For isolated sentences without dialogue context, pass them with context_window=0:
The model was trained on synthetic multilingual dialogue data covering various domains (medical anamnesis, customer support, police reports, therapy sessions, etc.). The data was generated and annotated as part of a thesis project on multilingual PII de-identification.
Limitations
Trained on synthetic dialogue data; performance on real-world data may vary
Optimized for dialogue/conversational text; may underperform on formal documents
Arabic and Hindi show lower performance compared to European languages
Requires pytorch-crf package for inference
Citation
If you use this model, please cite:
@misc{roller2026multilingual,
title={DialogPII: A multilingual dataset of synthetic dialog transcripts to detect personal information},
author={Roland Roller and Vera Czehmann and Derya Erman and Luke Flanagan and Ibrahim Baroud and Fr{\'e}d{\'e}ric Blain and Viviana Cotik and Eletta Giusto and Akhil Juneja and Mariana Neves and Maria S{\l}owi{\'n}ska and Christine Hovhannisyan and Aaron Louis Eidt and Lisa Raithel and Sebastian M{\"o}ller and Maija Poikela},
year={2026},
institution={DFKI SLT}
}