HabrSeptember 9, 2026🇷🇺Translated from Russian

PII-Guard: Open-Source Detector for Personal Data in Russian Text

PII-Guard, an open-source detector for personal data in Russian text, has been released by NLP researcher Andrey Ivanov from the R&D laboratory of red_mad_robot. The system addresses the growing need to protect sensitive information when users and companies send working texts to language models.

Personal data such as names, phone numbers, document numbers and addresses frequently accompany prompts. Companies therefore build masking pipelines that anonymize text before model inference. However, simple masking destroys semantic links, forcing models to answer questions about “**** called ****” without knowing how many people are involved or who called whom.

The new requirement is reversible pseudonymization: real values must be replaced by structured placeholders that models can process naturally, after which the original data is restored in the final answer.

From regex to hybrid detection

The first prototype relied on regular expressions. While telephone numbers, INN, SNILS and card numbers have predictable length and structure, real-world text contains spaces, dashes, typos and extra characters that break rigid patterns. Moreover, a 16-digit sequence could be either a bank card or an order ID, and a 10-digit string could match both INN and passport formats.

Control-sum verification was added next. Bank cards use the Luhn algorithm, INN and SNILS employ weighted sums, and OMS policies again apply Luhn. Additional structural checks cover BIK prefixes and postal-index ranges. These filters reduced false positives, yet arithmetic validation alone cannot distinguish a genuine document from a coincidental numeric string that happens to satisfy the checksum.

Context windows were introduced to look for nearby cue words such as “паспорт”, “ИНН” or “полис”. Positive keywords must lie within type-specific distance limits; negative keywords such as “биржевой” can veto an index match regardless of distance. When multiple candidates compete, the system selects the highest-confidence match after ordering document types from most distinctive (birth certificates, military IDs) to most ambiguous (simple six- or ten-digit sequences).

Adding semantic understanding

Names, addresses and telephone numbers lack rigid formats, so rules cannot locate them reliably. The team therefore annotated their own datasets and fine-tuned a ruBert-base NER model. The model handles semantic entities such as person names and addresses while also capturing documents missed by rules because of typos or irregular spacing.

The final architecture runs two independent streams. The rule-based stream normalizes text, extracts candidates, validates checksums and applies keyword context. The model stream processes the entire text and returns its own spans. An arbitration module merges results: when spans overlap but labels differ, rules win; when only the model finds an entity, its prediction is accepted; non-overlapping spans from both streams are retained.

Pseudonymization and grammatical restoration

Detected entities are replaced by XML-style tags containing type, numeric ID and, for persons, grammatical gender inferred by a Russian morphology library. The tag format was chosen to avoid accidental collisions with ordinary text or other system markup. After the model returns its answer, real values are substituted back, with morphological analysis ensuring correct case for names and addresses.

Evaluation was performed on four public datasets, one of which is the team’s own. On the intersection of entity types supported by all compared systems, PII-Guard achieved the highest micro-F1 scores under both strict span matching and type-overlap criteria. The project, datasets and code are publicly available.

Related articles

AntiMalwarePrivacy & Surveillance

Google to Add Explicit Content Warnings in Android System Photo Picker

Google is preparing a new safety feature for the system photo picker in Android that will scan images and videos for explicit or nude content. The tool is designed to warn users before they share intimate photographs, whether accidentally or due to a momentary lapse in judgment. This functionality will operate at the system level, meaning it applies across multiple apps that use the built-in photo selector. The feature aims to reduce the risk of unintended distribution of private images that could lead to embarrassment or privacy violations. By integrating the check directly into Android, Google seeks to provide a consistent layer of protection without requiring third-party applications to implement similar logic themselves.

AntiMalwarePrivacy & Surveillance

LG Smart TVs Record Audio in Standby Mode and Scan Home Networks for Advertising Data

Researchers from the Gamers Nexus YouTube channel analyzed multiple LG OLED television models, including the LG G5 series, and discovered that the devices continue to capture audio through built-in microphones even when the screen is off and the television is in standby. The TVs scan local networks to identify smartphones and smartwatches, collect internal IP addresses, available Wi-Fi network names, and location data. When internet connectivity is removed, audio recordings are stored locally and transmitted once the connection is restored. The devices also employ Automatic Content Recognition (ACR) technology to generate digital fingerprints of viewed content, with the resulting data reportedly sent to LG Ad Solutions for targeted advertising. Additional vulnerabilities were identified in webOS that could potentially allow remote code execution. LG has not yet commented on the findings, and experts recommend disconnecting the televisions from the internet and using external streaming devices until official clarification is provided.

HabrPrivacy & Surveillance

Engineer Details Six Weeks Spent Training and Testing Signature Redaction Models for Closed-Loop Document Anonymization

A detailed case study describes attempts to automatically redact handwritten signatures from scanned and text-based PDFs containing personal data such as names, phones, addresses and signatures. The work was performed inside an air-gapped environment on a single GPU machine with no internet access. Multiple approaches including color-based ink gates, pre-trained YOLO detectors, custom-trained YOLO11s models, Tesseract OCR heuristics and various vision-language OCR engines were evaluated on 492 real pages plus synthetic augmentations. Key findings include rotation handling bugs, line-assembly failures in Tesseract, the necessity of using apply_redactions instead of draw_rect for true removal, and the limited value of vision models once rule-based pipelines are mature. The final pipeline reduced expensive vision-model calls from 50 pages to 18 pages while achieving zero leaks across thousands of redactions. The author also measured twelve OCR engines and demonstrated that combining PaddleOCR detection with Tesseract recognition yields the best accuracy-to-speed trade-off.

HabrPrivacy & Surveillance

pg_anon Open-Source Tool Receives Major Updates for PostgreSQL Data Masking and Partial Database Operations

Tantor Labs has released version 1.11.0 of pg_anon, an open-source utility designed to mask personal data in PostgreSQL databases while preserving structure and relationships. The update introduces packaging as a standard Python package, support for partial dumps and restores using whitelist and blacklist dictionaries, and improved handling of complex schema elements such as partitioned tables, generated columns, and custom types. Performance improvements include switching the dump engine to asyncio, single-query metadata collection, and on-the-fly gzip compression to reduce memory usage on large databases. New CLI options allow clean or drop operations on target databases, privilege ignoring, and passthrough of pg_dump and pg_restore flags. A REST API was added to enable integration into CI/CD pipelines and automated self-service systems for nightly masked database refreshes. The tool helps organizations comply with data protection requirements by creating pseudonymized copies suitable for development, testing, and contractor environments.