加载中…
加载中…
A fine-tuned version of bardsai/eu-pii-anonimization-multilang (revision 62ca5712368705bac11b8fea19e42e65cce088dd) that marks personal data in text, mainly names of people. It was adjusted for one situation the base model handles poorly: text that mixes prose with source code, logs and documentation, where the base model marks tool names, identifiers and dates as personal data.
This is a modified version of the base model. The base model is licensed under Apache-2.0, and so is this one.
The network, the tokenizer and the list of labels are the base model's. Only weights were adjusted: the embeddings and the lower 6 of 12 encoder layers were kept frozen, the upper 6 layers and the classification layer were fine-tuned for two passes over about 10,800 short examples (learning rate 2e-5, batch size 16, maximum 320 tokens).
Training examples, none of which contain real personal data:
urchade/gliner_multi_pii-v1) did not mark was relabelled as nothing.Unchanged from the base model: 34 types in BIO form, among them PERSON_NAME, POSTAL_ADDRESS, LOCATION, DATE_OF_BIRTH, EMAIL_ADDRESS, PHONE_NUMBER and HEALTH_DATA. The fine-tuning targeted PERSON_NAME, LOCATION and DATE_OF_BIRTH. The other types were not trained on and not evaluated here.
from transformers import pipeline
pipe = pipeline(
"token-classification",
model="<user>/<repository>",
revision="<commit hash>", # pin it: results belong to one set of weights
aggregation_strategy="simple",
)
for entity in pipe("Rücksprache mit Dr. Huber wegen der Entlassung am Montag."):
print(entity["entity_group"], entity["start"], entity["end"], round(float(entity["score"]), 2))
The model reads at most 512 tokens at a time. For longer text, cut it into overlapping windows and merge the results; the measurements below used 512-character windows with a 128-character overlap and kept spans with a score of at least 0.6.
All numbers come from one pipeline: 512-character windows, score threshold 0.6, LOCATION counted as an address, plus regular-expression rules for e-mail addresses, phone numbers, IBANs and numeric birth dates, and a filter that drops implausible spans. "Base" is the unchanged base model, "GLiNER" is urchade/gliner_multi_pii-v1 with eleven zero-shot labels. Processor only, Apple Silicon, four performance cores.
| Test | GLiNER | Base | This model |
|---|---|---|---|
| Seconds per kB of text | 0.22–0.25 | 0.09 | 0.08 |
| Memory after load / highest over 151 scans | 2.1 / 4.0 GB | 1.2 / 1.8 GB | 1.2 / 1.8 GB |
| German clinical letters (GraSCCo PII v2, 63 synthetic letters): patient names found, of 166 | 158 | 161 | 159 |
| GraSCCo: doctor names found, of 154 | 128 | 141 | 143 |
| GraSCCo: name spans on something that is not a person | 116 | 42 | 38 |
| German news and Wikipedia (GermEval 2014 test part, 5,100 sentences): persons found, of 1,639 | 1,493 | 1,547 | 1,543 |
| GermEval: name spans on something that is not a person | 353 | 172 | 137 |
| Invented names, sentence on its own, of 140 (80 German, 60 English) | 139 | 137 | 140 |
| Invented names placed in the middle of code, of 140 | 139 | 134 | 139 |
| One-word names next to punctuation, of 20 | 20 | 19 | 19 |
| Code and docs of an unseen software project (490 kB): spans marked by the model | 62 | 145 | 58 |
| Unseen open-source Python code (238 kB): spans marked by the model | 35 | 60 | 19 |
A span counts as found when any detected span overlaps it. On the unseen open-source code, 13 of this model's 19 spans have the shape "First Last"; that text contains real author names.
model.safetensors — sha256 08552c982992a3284f2e72e019a67d5596de18406d826606d45aff4891f52556config.json, tokenizer.json, tokenizer_config.jsonbardsai/eu-pii-anonimization-multilang (Apache-2.0); the weights of the upper six encoder layers and the classification layer were changed by fine-tuning as described above.