katip-mask
Detect and mask Turkish personal data (KVKK) in text, locally. It uses the same rules as the
Katip demo and the Katip Kalkan connector, with optional small name
models (ONNX). A JavaScript version with identical output is on npm as
katip-mask.
pip install katip-mask # rules only, no dependencies
pip install "katip-mask[model]" # adds onnxruntime and numpy for the name models
from katip_mask import Masker
masker = Masker("ai", model="mini")
result = masker.mask(text)
result.text # 'Davacı [AD SOYAD-1] (T.C. Kimlik No: [T.C. KİMLİK NO-1]) ...'
result.spans # what was masked, with offsets, type and score
result.mapping # {'[AD SOYAD-1]': 'Ahmet YILMAZ', ...}
result.restore(answer) # put the original values back, e.g. into an LLM's reply
Limits
How Katip handles data, and what masking does and does not do under KVKK: PRIVACY.md.
Each detected value is masked everywhere it appears in the text, or mask() raises LeakError.
Values the detector misses stay in the text, so check the output before relying on it. Detection rates
by document type and model are on the KVKK-Bench leaderboard.
Text never leaves the machine. The only network call is the model download, which happens only when you
pass model=.
Profiles
| profile | use | masks | leaves readable |
|---|---|---|---|
court (default) |
court filings | names, ID/passport/tax numbers, UETS addresses, bar numbers, IBAN, cards, phones, e-mails, plates, birth dates, IPs, parties' own addresses, building and door numbers of other addresses, health and other special-category data | the property in dispute, streets of other addresses, case numbers, dates, courts, precedent citations |
ai |
sending text to an LLM | court, plus every address, case and UYAP numbers, criminal-record terms |
dates, places, institutions, precedent citations |
anon |
publishing, research | ai, plus dates, places, courts, companies and institutions |
precedent citations |
The KVKK practice guide for lawyers (Avukatların Mesleki Faaliyetlerinde Kişisel Verilerin Korunmasına İlişkin Uygulama Rehberi, 2026) recommends masking or anonymising personal data where possible and sharing only what is needed, including with AI tools. The court profile also follows feedback from practising lawyers: a party's own address is masked whole, the address of the property in dispute stays readable, and a masked lawyer's UETS address and bar number are masked.
Options
Masker(
profile="court", # "court" | "ai" | "anon"
model=None, # None (rules only) | "mini" | "nano" | "base" | path to a model folder
threshold=0.5, # minimum confidence
entities=None, # replace the profile's entity types (see katip_mask.ENTITY_TYPES)
address_detail=None, # "street" | "full"; default comes from the profile
allow=(), # never mask these terms
deny=(), # always mask these terms
style="label", # "label": [AD SOYAD-1], reversible; "block": ██████
)
masker.mask(text, ocr_ranges=[(0, len(text))]) # mark OCR text so misread ID numbers are still caught
masker.detect(text) # spans only
mask(), detect() and restore() are also available as functions. Offsets are Python string indices.
Models
| model | size | |
|---|---|---|
nano |
2.6 MB | fastest, weaker on informal text |
mini |
31 MB | recommended |
base |
111 MB | most accurate, also tags addresses and health terms |
Models are downloaded from Hugging Face (f1k/katip-mask-mini
and siblings) at a fixed commit and checked against SHA-256 hashes in the package. They are cached in
~/.cache/katip-mask (or $KATIP_MASK_CACHE), which the Node package shares.
katip-mask download mini # fetch ahead of time
export KATIP_MASK_OFFLINE=1 # never use the network
export KATIP_MASK_ENDPOINT=https://your-mirror.example
Command line
katip-mask mask dilekce.txt --profile ai --model mini > maskeli.txt
katip-mask mask dilekce.txt --json > result.json
katip-mask restore cevap.txt --mapping result.json
katip-mask detect dilekce.txt
The JSON matches the JavaScript CLI's. Exit code 3 means masking was refused (LeakError).
Licence
Code: AGPL-3.0, or a commercial licence. Models: CC BY-SA 4.0, based on BERTurk (dbmdz, MIT). Citation: CITATION.cff.
Metadata
Release files for katip-mask 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| katip_mask-0.1.0.tar.gz | 184.5 kB | With provenance | Details for katip_mask-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| katip_mask-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for katip_mask-0.1.0-py3-none-any.whl |
Total release size: 374.2 kB
Release files / katip_mask-0.1.0.tar.gz
| Download URL | katip_mask-0.1.0.tar.gz |
|---|---|
| Size | 184.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
005a4032951c55ab77917e1c89f3f0ccde185bc62eb2d583fc857a42ea9ba507
|
|
BLAKE2b-256 checksum How to use checksums |
e21ac1e95b8c68bb571db8d08ea6d06a6cce006f82129b18cb4aebc444b7731d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / katip_mask-0.1.0-py3-none-any.whl
| Download URL | katip_mask-0.1.0-py3-none-any.whl |
|---|---|
| Size | 189.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dc453075e290259b7ac8095be26d9d9eb3491a8526f558072ee7389157a397c7
|
|
BLAKE2b-256 checksum How to use checksums |
0289cf7867eae586983cbe16062680a8a5f394a90af2872c714c852f9eb0a914
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for katip-mask 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for katip_mask-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.