A Swedish fine-tune of openai/privacy-filter. It finds personal data in Swedish text so the data can be masked before the text is sent to an LLM, written to a log or passed on by a tool.
Status: a starting point. We release the weights, the training data and the full recipe (the recipe/ folder of this repository) so others can build
better Swedish and Nordic guards. Read Known gaps before you rely on it.
11 labels: the base model's 8 plus national_id, id_number and ip_address.
| Label | Examples |
|---|---|
private_person |
full names, first or last name alone, initials, genitives ("Annas") |
national_id |
personnummer, samordningsnummer |
id_number |
passport, ID card, patient/journal numbers |
private_address |
home addresses, postcode + town of a person |
private_phone |
personal and direct numbers |
private_email |
personal and named work addresses |
account_number |
bank account, bankgiro/plusgiro of a person, card, IBAN, customer numbers |
private_date |
birth dates and dates tied to one person (injury, move-in, employment start) |
private_url |
personal profiles and pages |
secret |
passwords, API keys, tokens, PINs, one-time codes |
ip_address |
IPv4 and IPv6 addresses |
Deliberately not masked:
An LLM usually needs these, and they don't identify a private person. The full policy is in recipe/POLICY.md.
The model uses the same runtime as the base model (opf):
from opf._api import OPF
guard = OPF(model="kognitiv-ai/swedish-pii-guard", device="cuda")
res = guard.redact("Hej, jag heter Karin Berg och mitt personnummer är 19121212-1212.")
for s in res.detected_spans:
print(s.label, s.text)
We recommend snapping span edges to word boundaries (recipe/eval/postproc.py).
opf train, 2 epochs, lr 5e-5, batch 16, about 340k rows.All sets are Swedish, word-snapped, and none were used for training.
| Model | GPT test F1 | Person recall, news (Webbnyheter) | Person recall, SUCX3 | Orgs / places wrongly masked, SUCX3 |
|---|---|---|---|---|
| openai/privacy-filter (base) | 0.70 | 0.56 | 0.41 | |
| OpenMed/privacy-filter-multilingual-v2 † | 0.69 | 0.84 | 0.75 | 30% / 31% |
| emiemimi/privacy-filter-multilingual-500 † | 0.73 | 0.79 | 0.68 | 33% / 46% |
| this model | 0.92 | 0.90 | 0.80 | 23% / 13% |
† Decoded with plain argmax and with labels mapped to ours. Their policies differ (for example, OpenMed masks all dates), so treat these rows as indicative.
By type, on a GPT dev set:
Thanks to AI Factory Sweden, through AI Göteborg, for pointing us to the EuroHPC AI Factories access programme.
We acknowledge EuroHPC JU for awarding the project ID EHPC-AIF-2026FL01-1143 access to the Arrhenius GPU partition hosted by NAISS at Linköping University, Sweden. All training and evaluation of this model ran on that allocation. Some template-writing calls used hosted APIs (DeepSeek-V4.1-Flash, GLM-5.2).
Apache 2.0, the same as the base model.
openai/privacy-filter