cbx-indim-pii-extractor-32M

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).

Labels

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 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.

How to use

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
  • Confidence thresholds: 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.
  • Text is read in one pass up to 8,192 tokens; longer texts are split automatically. The model was pretrained on 512-token inputs, and our tests show no loss on longer ones (below).
  • Masked values keep their mask: 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.

Results

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%
  • IndicPIIDetX (DOI 10.57967/hf/11457): test split, 8,028 documents written independently of our training data.
  • Ylemis India-PII (CC0) and IndiaPII-Bench (CC BY 4.0, includes ID-shaped decoys that are not PII).
  • This repository holds the training run with the best validation score: IndicPIIDetX 0.910 (27 labels) / 0.951 (14 types), PII-free documents flagged 38.6%, Ylemis 0.984, IndiaPII-Bench 0.957, decoys hit 23.5%.
  • InDIM-small finds more PII than mmBERT-small and IndicBERT v2 on IndicPIIDetX and IndiaPII-Bench, close to mmBERT-base at a tenth of its size, but raises more false alarms than the mmBERT models (see Limitations).

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).

Limitations

  • Trained on synthetic text only. Real documents contain layouts, typos and value formats the generator did not produce; scores on real data are lower than on our own test set (compare the tables above).
  • False alarms: about 39% of PII-free IndicPIIDetX documents get at least one span, and about 20% of IndiaPII decoys (ID-shaped numbers that are not personal data) are tagged. Review redactions where over-redaction matters, or raise the thresholds in pii_config.json.
  • Sensitive attributes such as health, religion or caste are not detected. Names that are also common words can be missed, and labels can be confused between ID types with similar formats.
  • No tool finds all PII. Do not rely on it as the only safeguard for legal or regulatory compliance.

Intended use and disclaimer

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.

Training

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).

Citation

If you use this model, please cite InDIM-small (32M).

Licence

Apache-2.0 (see LICENSE and NOTICE).

Questions: hello@cobuildx.ai.

Downloads last month
-
Safetensors
Model size
31.5M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for CobuildX-AI/cbx-indim-pii-extractor-32M

Quantized
(4)
this model

Collection including CobuildX-AI/cbx-indim-pii-extractor-32M