A zero-shot NER and document anonymization package.
A lightweight Python library for Zero-Shot Named Entity Recognition (NER) and Document Anonymization, powered by GLiNER 2.
Anonymizer allows you to extract custom entities from PDFs and Word documents, dynamically redact them, and most importantly, it includes a built-in memory override so you can easily correct the AI when it makes mistakes.
(Note: Not actually published to PyPI yet. Install from source).
Zero-Shot Extraction: Define what you want to extract using natural language descriptions (e.g., "address": "street addresses").
Document Anonymization: Physically redact the extracted entities from PDFs (using secure PyMuPDF redaction) or DOCX files.
Feedback Memory Loop: If the AI mislabels something, you can add a correction to the memory database. On all future extractions, the package will automatically override the AI and correctly label that specific text.
You can securely redact all the entities you found. You can choose different strategies for how the text is hidden:
If the AI makes a mistake (e.g., it tags "John Doe" as an address), you can add a correction. By default, this is saved to ~/.anonymizer_ner/memory.json, but you can isolate it per project:
This correction is saved locally to ~/.anonymizer_ner/memory.json.
The next time you call anonymizer_ner.extract(), two things happen automatically:
If the text "John Doe" is found anywhere in the document, it is guaranteed to be tagged as a person with 100% confidence, overriding any AI predictions.
By default, the package uses fastino/gliner2-base-v1. If you have fine-tuned your own GLiNER 2 model on specific domain data, you can easily load it either globally or per-extraction.
The anonymizer_ner package is designed to be highly memory efficient. It breaks large documents into small chunks so a 10,000-page document uses the exact same amount of RAM as a 5-page document.
However, if you are running this on a standard laptop and need to process hundreds of documents, do not use multiprocessing. Loading multiple AI models at the same time will crash your RAM. Instead, use a simple for loop to process them sequentially in complete safety:
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
Details for the file anonymizer_ner-1.0.0.tar.gz.
Details for the file anonymizer_ner-1.0.0-py3-none-any.whl.
