Finds personal information (PII) in Indian text and returns the exact position of each value with one of 27 labels, including Aadhaar, PAN, UPI IDs, IFSC codes, voter IDs and vehicle numbers. It reads 12 Indian languages and Indian English (Hindi, Bengali, Marathi, Tamil, Telugu, Kannada, Malayalam, Gujarati, Punjabi, Odia, Assamese, Urdu), in native script, romanized (Indian languages in English letters) and code-mixed text. It is InDIM-small (32M) fine-tuned for PII tagging: about 9 ms for a short message and 50 ms for a 600-token document on a CPU (8 threads).
| Label | Covers |
|---|---|
| PERSON | Names, including first names or surnames on their own and initials; titles (Shri, Dr, ji) are not part of the name |
| PHONE | Phone numbers |
| Email addresses | |
| ADDRESS | Postal addresses including the PIN code, and a PIN code on its own (a city or state on its own is not labelled) |
| DATE_OF_BIRTH | Dates of birth |
| DATE | Every other date, in any format and script, with a time written next to it |
| AMOUNT | Money amounts with their currency sign or word (₹25,000, Rs. 500/-, २५ हज़ार रुपये) |
| BANK_ACCOUNT | Bank account numbers |
| IFSC | IFSC branch codes |
| UPI_ID | UPI IDs |
| PAYMENT_CARD | Card numbers, including masked ones (XXXX XXXX XXXX 1234) |
| AADHAAR | Aadhaar numbers, including masked ones |
| PAN | PAN numbers |
| VOTER_ID | Voter ID (EPIC) numbers |
| RATION_CARD | Ration card numbers |
| PASSPORT | Passport numbers |
| DRIVERS_LICENSE | Driving licence numbers |
| VEHICLE_REG | Vehicle registration numbers |
| NATIONAL_ID | Other national IDs: ABHA number and address, APAAR ID |
| TAX_ID | GSTIN and TAN (PAN has its own label) |
| CUSTOMER_ID | Customer, CIF, loan, policy and consumer numbers (not order, transaction or ticket numbers) |
| EMPLOYEE_ID | Employee codes, PF UAN, ESIC numbers |
| PATIENT_ID | MRN, UHID and hospital registration numbers |
| SECRET | OTPs, MPINs, passwords, CVVs |
| USERNAME | Usernames and handles |
| URL | Web addresses |
| IP_ADDRESS | IPv4 and IPv6 addresses |
Codes that are not personal data (order, invoice, ticket, transaction, SKU, batch, tracking and booking numbers, public helplines) are not labelled.
pip install -U huggingface_hub
hf download CobuildX-AI/cbx-indim-pii-extractor-32M --local-dir cbx-indim-pii-extractor-32M
cd cbx-indim-pii-extractor-32M
pip install -r requirements.txt
from pii import PIIExtractor # pii.py is in this repository
pii = PIIExtractor() # uses a GPU if one is available
pii.extract("नमस्ते, मेरा नाम अनीता कुलकर्णी है। मेरा मोबाइल नंबर 98204 51763 है और ईमेल anita.k@example.in है।")
# [{'label': 'PERSON', 'text': 'अनीता कुलकर्णी', 'start': 17, 'end': 31},
# {'label': 'PHONE', 'text': '98204 51763', 'start': 53, 'end': 64},
# {'label': 'EMAIL', 'text': 'anita.k@example.in', 'start': 76, 'end': 94}]
pii.redact("...") # replaces each value with [LABEL]
pii.extract(text, labels=["PERSON", "AADHAAR"]) # keep only some labels
pii_config.json holds a minimum confidence for 16 of the labels (min_confidence),
tuned on the IndicPIIDetX dev split to cut false alarms; pii.py applies them. Set
pii.min_conf = {} to get every span the model tags (more recall, more false alarms), or change single values.XXXX XXXX 4521 is returned whole as AADHAAR.python example.py runs four sample texts; onnx/model.onnx runs the same model with ONNX Runtime (1.23 or later,
fused attention) and gives the same spans as PyTorch (checked on 300 documents); see onnx_example.py.Every model below was fine-tuned on the same synthetic training data with the same recipe (plain fine-tuning, learning rate picked on validation), and all were given confidence thresholds tuned the same way on the IndicPIIDetX dev split. Mean of 3 training runs unless marked; mmBERT-base is 1 run.
Independent test sets (not generated by us; typed F1 = a predicted span counts if it overlaps a true value of an accepted type):
| Model | Parameters | IndicPIIDetX test, 27 labels | IndicPIIDetX, 14 shared types | PII-free documents flagged ↓ | Ylemis India-PII | IndiaPII-Bench | IndiaPII decoys hit ↓ |
|---|---|---|---|---|---|---|---|
| InDIM-small (this model's base) | 32M | 0.910 | 0.951 | 39.0% | 0.986 | 0.960 | 20.0% |
| mmBERT-small | 140M | 0.897 | 0.931 | 35.0% | 0.985 | 0.949 | 16.2% |
| mmBERT-base (1 run) | 307M | 0.916 | 0.958 | 33.4% | 0.984 | 0.951 | 11.8% |
| IndicBERT v2 | 278M | 0.904 | 0.952 | 48.0% | 0.987 | 0.951 | 13.0% |
Our synthetic test (7,370 documents, exact-span F1): InDIM-small 0.992, mmBERT-small 0.993, mmBERT-base 0.994, IndicBERT v2 0.970. Rows longer than 512 tokens: InDIM-small 0.996 (shorter rows 0.991).
pii_config.json.Intended use: finding and redacting personal information in Indian-language text, for example before storing, sharing or analysing documents, chats and call transcripts, with checks suited to the risk. Not intended as the only safeguard where missing a value causes harm. The model makes mistakes. It is provided "as is", without warranties of any kind; Cobuild Tech Private Limited is not liable for its use. You are responsible for checking that it suits your data and for complying with the laws that apply to your use.
InDIM-small (32M) fine-tuned as a BIO token tagger on 59,080 synthetic documents (chats, forms, emails, transcripts, statements; native script, romanized and code-mixed) in the 13 languages (plain fine-tuning, learning rate 2e-4).
If you use this model, please cite InDIM-small (32M).
Apache-2.0 (see LICENSE and NOTICE).
Questions: hello@cobuildx.ai.
onnx/model.onnx 126 MBmodel.safetensors 126 MBCobuildX-AI/InDIM-small