- privacy-filter-finetuned
- What This Repo Includes
- What The Excel Script Does
- Requirements
- Fresh Install On Windows
- Fresh Install On macOS Or Linux
- Test The Sample Workbook
- Use Your Own Excel File
- Continued Use After Installation
- Important Notes For Real Data
- Direct Python Inference
- Label Space
- Training Details
- Known Limitations
- License
- What This Repo Includes
privacy-filter-finetuned
A finetuned version of openai/privacy-filter for local privacy filtering in procurement, finance, and sales-style Excel data.
It keeps the original OPF privacy labels and adds detection for:
| Category | What it detects | Examples |
|---|---|---|
company_name |
Supplier names, customer account names, corporate entities | Meridian Logistics Ltd, Apex Manufacturing PLC, TechStart Solutions Inc |
price |
Monetary values with currency symbols or codes | GBP 4,250.00, $12,500, EUR 5,000, 2,500 GBP |
id_number |
Purchase orders, invoice numbers, case IDs, internal references | PO-00442, INV/2024/00567, CASE-20240315-001, ORD-78542 |
The model and Excel script run locally. Your Excel data is read and processed on your own machine.
What This Repo Includes
This model repo contains:
model.safetensorsandconfig.json- the finetuned OPF checkpoint.clean_excel.py- a helper script for cleaning Excel workbooks.requirements.txt- Python packages needed by the helper script.dummy_procurement_data.xlsx- a sample workbook for testing the setup.label_space.json- the full label list used by the model.
What The Excel Script Does
clean_excel.py takes an input .xlsx file and creates a new cleaned workbook.
It:
- Loads the workbook.
- Detects sensitive values in selected text columns.
- Creates synthetic replacements using Faker.
- Adds new
<column>_cleancolumns containing the synthetic text. - Adds a
PII_Audit_Logsheet showing what was detected and replaced. - Leaves the original workbook untouched.
Repeated values are consistent within a single run. For example, if Meridian Logistics Ltd appears ten times in one workbook, it will be replaced with the same synthetic company each time in that run.
Requirements
You need:
- Python 3.10 or newer.
- Internet access for the first install and first model download.
- Enough disk space for the model checkpoint.
Use CPU unless you already have a working CUDA setup.
Fresh Install On Windows
Run these commands in PowerShell:
mkdir privacy-filter-demo
cd privacy-filter-demo
py -3.12 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -U pip huggingface_hub
hf download galexdav/privacy-filter-finetuned `
--include clean_excel.py `
--include requirements.txt `
--include dummy_procurement_data.xlsx `
--include label_space.json `
--local-dir .
python -m pip install -r requirements.txt
If py -3.12 does not work, use your installed Python launcher instead, for example:
python -m venv .venv
Fresh Install On macOS Or Linux
mkdir privacy-filter-demo
cd privacy-filter-demo
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -U pip huggingface_hub
hf download galexdav/privacy-filter-finetuned \
--include clean_excel.py \
--include requirements.txt \
--include dummy_procurement_data.xlsx \
--include label_space.json \
--local-dir .
python -m pip install -r requirements.txt
Test The Sample Workbook
After installing, run:
python clean_excel.py dummy_procurement_data.xlsx --device cpu
This creates:
dummy_procurement_data_cleaned.xlsx
The first run downloads the checkpoint into:
models/privacy-filter-finetuned
Later runs reuse that local copy.
Use Your Own Excel File
Put your workbook in the same folder as clean_excel.py, then run:
python clean_excel.py your_data.xlsx --device cpu
Choose specific columns:
python clean_excel.py your_data.xlsx --columns Supplier Notes ContactEmail InvoiceRef Amount --device cpu
Process every sheet:
python clean_excel.py your_data.xlsx --all-sheets --device cpu
Set the output filename:
python clean_excel.py your_data.xlsx --all-sheets --device cpu --output your_data_sanitised.xlsx
Use GPU if available:
python clean_excel.py your_data.xlsx --all-sheets --device cuda
Continued Use After Installation
You do not need to reinstall each time. Open a terminal in the same folder and reactivate the environment.
Windows:
cd privacy-filter-demo
.\.venv\Scripts\Activate.ps1
python clean_excel.py another_file.xlsx --all-sheets --device cpu
macOS or Linux:
cd privacy-filter-demo
source .venv/bin/activate
python clean_excel.py another_file.xlsx --all-sheets --device cpu
Important Notes For Real Data
- The source workbook is not modified; the script writes a new output workbook.
- The
PII_Audit_Logsheet contains original detected values, so treat the cleaned workbook as sensitive if you keep that audit sheet. - Replacement consistency is currently per run, not permanent across separate days or separate executions.
- If you need the same original value to always map to the same synthetic value across many files over time, add a persistent replacement map such as
replacement_map.json. - This is a privacy filtering aid, not a compliance guarantee. Review outputs before production use.
Direct Python Inference
You can also use the checkpoint directly from Python:
from huggingface_hub import snapshot_download
from opf import OPF
checkpoint = snapshot_download("galexdav/privacy-filter-finetuned")
model = OPF(model=checkpoint, device="cpu")
result = model.redact("PO-00442 raised for Meridian Logistics Ltd, total GBP 4,250.00.")
for span in result.detected_spans:
print(f"{span.label}: {span.text}")
Label Space
{
"category_version": "custom_v1_extended",
"span_class_names": [
"O",
"private_person",
"private_email",
"private_phone",
"private_address",
"account_number",
"private_url",
"private_date",
"secret",
"company_name",
"price",
"id_number"
]
}
Training Details
| Field | Value |
|---|---|
| Base model | openai/privacy-filter |
| Training examples | about 830 |
| Validation examples | about 130 |
| Epochs | 3 |
| Hardware | 1x NVIDIA L4, 24 GB, via Hugging Face Jobs |
| Training time | about 41 minutes |
Training data was generated programmatically using templates and entity cross-products, covering all 11 categories including the original OPF categories to reduce catastrophic forgetting.
Known Limitations
- Company names in isolated cells may be harder to detect without sentence context.
- Price span boundaries may occasionally exclude a currency symbol.
- API-key-like values can occasionally be classified as
id_numberrather thansecret. - Performance is intended for English text.
License
Apache 2.0, same as the base model. Commercial use is permitted under the license terms.
- Downloads last month
- 7
Model tree for galexdav/privacy-filter-finetuned
Base model
openai/privacy-filter