Skip to main content

Privacy-safe LLM data cleaning for fine-tuning datasets

Project description

mask-llm

Privacy-safe data cleaning for LLM fine-tuning datasets.

Your data never leaves your machine unprotected. Names, emails, and phone numbers are masked locally before being sent to any LLM API. Results are automatically restored after cleaning.

The Problem

When preparing fine-tuning datasets, your data often contains sensitive information: customer names, emails, internal project codenames. Sending this raw data to OpenAI or any cloud LLM is a privacy risk and may violate GDPR, HIPAA, or your company's data policy.

How It Works

Your Data → [Local PII Masking] → Anonymized Text → [Cloud LLM Cleaning] → [Local Restore] → Clean Data

  1. PII detected and replaced locally (John Smith[PERSON_1])
  2. Only anonymized text is sent to the cleaning API
  3. Cleaned result is restored with original values locally
  4. Output as standard JSONL ready for fine-tuning

Install

pip install mask-llm
python -m spacy download en_core_web_sm

Quick Start

Prepare your input as a JSONL file (one JSON object per line):

{"text": "John Smith at john@company.com needs this dataset cleaned."}
{"text": "Call Sarah on 123-456-7890 to confirm the order."}

Run the cleaner:

python -m mask_llm \
  --input your_data.jsonl \
  --output cleaned_data.jsonl \
  --key YOUR_API_KEY

Get your free API key at: https://nexus.xiaoku88.com

Output Fine-Tuning Format

Add --finetune to output standard instruction/input/output format:

python -m mask_llm \
  --input your_data.jsonl \
  --output cleaned_data.jsonl \
  --key YOUR_API_KEY \
  --finetune

Output:

{"instruction": "Clean and format the following text for fine-tuning.", "input": "John Smith at john@company.com...", "output": "John Smith at john@company.com..."}

Options

Option Default Description
--input required Input JSONL file
--output required Output JSONL file
--key required Your API key
--model deepseek-chat Model to use
--concurrency 10 Parallel requests
--finetune false Output fine-tuning format
--prompt built-in Custom system prompt

What Gets Masked

Type Example Masked As
Person names John Smith [PERSON_1]
Organizations Apple Inc [ORG_1]
Email addresses john@example.com [EMAIL_1]
Phone numbers 123-456-7890 [PHONE_1]
IP addresses 192.168.1.1 [IP_1]
SSN 123-45-6789 [SSN_1]

License

MIT


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mask_llm-0.1.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mask_llm-0.1.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file mask_llm-0.1.1.tar.gz.

File metadata

  • Download URL: mask_llm-0.1.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for mask_llm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bacc9c12bdf2516682af53878489a705d539e460b1a7c489f0dbd5a388b623ed
MD5 35bb2eaba83300ae79ac9cde298743dc
BLAKE2b-256 520e3e1c935b301b9a12d4331db38d234a26361d4d30d7a3cba1c7892526e90f

See more details on using hashes here.

File details

Details for the file mask_llm-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mask_llm-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for mask_llm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d1c706c200c40454aa1b4c6529e799e38101883b8d1570ec21c0477ae8fb202b
MD5 e8c9615007c78bbf16c05ff6af768977
BLAKE2b-256 26ed6802fcead814af6a7de7f792c1e30ccbdbdc52235d0e371196d5a5016c39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page