← Back to full index
# BetterRedactionTool - PII Redaction for Word Documents

A tool that finds personal data in .docx files and replaces it with consistent, realistic fake values, evaluated against a hand-verified ground truth on a 446,000-character IPO prospectus. Available as a CLI and a web app.

- Role: Sole Developer
- Date: Sep 2026
- Categories: project
- Tech: Python, spaCy, Presidio, Transformers, FastAPI, Faker, Docker
- GitHub: https://github.com/AmulyaJain2004/BetterRedactionTool
- Live: https://huggingface.co/spaces/Alokik089/redaction_tool

## Overview

Sharing a document often means removing personal data first, but blacking text out destroys readability. This tool redacts personally identifiable information (PII) from Word documents and replaces each value with a realistic fake one. Replacements are consistent: the same real name becomes the same fake name everywhere in the document. Every change is written to an audit log, and the original formatting is kept.

It ships two ways: a one-line CLI command, and a web app with a progress bar and a settings page for changing what gets redacted without editing any files.

## System Design

```mermaid
flowchart TD
    CLI["CLI"] --> Engine
    Web["Web app<br/>upload · progress · download"] --> API["FastAPI<br/>background jobs"]
    API --> Engine["Redaction engine"]
    Settings["Settings UI<br/>categories · table rules · exclude list"] --> Config[("YAML config")]
    Config -->|"hot reload, no model restart"| Engine
    Engine --> Presidio["Presidio recognisers<br/>email · phone · SSN · card · IP"]
    Engine --> NER["spaCy en_core_web_trf<br/>people · organisations"]
    Engine --> Rules["Rules<br/>addresses · dates of birth · personnel tables"]
    Engine --> Fake["Consistent fake values<br/>Faker"]
    Fake --> Out(["Redacted .docx + audit log"])
```

- **Shaped data** such as emails, phone numbers, SSNs, cards and IPs is caught by Presidio's validated recognisers.
- **People and organisations** are found by spaCy's transformer NER model, with a deny-list and the document's own glossary used to keep defined terms and regulators from being flagged as companies.
- **Personnel and KYC tables** are detected from their column headers, which is far more reliable than NER for a bare value alone in a table cell.
- **Settings changes** take effect on the next file without restarting the server or reloading the NLP model.

## Evaluation

The tool was evaluated on a real IPO prospectus (1,006 paragraphs, 76 tables, about 446,000 characters) against a ground truth covering the whole document. Three NER backends were compared head-to-head before choosing one:

| Category | Metric | en_core_web_lg | GLiNER-PII | **en_core_web_trf** |
|---|---|---|---|---|
| Person | Precision | 0.56 | 0.58 | **0.72** |
| Person | Recall | 0.83 | 0.90 | **0.95** |
| Organisation | Precision | 0.40 | 0.17 | **0.69** |
| Organisation | Recall | 0.79 | 0.36 | **0.89** |

Emails, phone numbers, physical addresses and director ID numbers are detected at or near 1.00 precision and recall. The remaining gaps in people and organisations, and the trade-offs behind each technique, are documented in the repository.

## My Contribution

I designed and built the whole project on my own: the detection pipeline, the evaluation suite and ground truth, the FastAPI web app and settings UI, and the Docker deployment.

---

Back to the full index: /agent