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
- PII detected and replaced locally (
John Smith→[PERSON_1]) - Only anonymized text is sent to the cleaning API
- Cleaned result is restored with original values locally
- 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
Metadata
Release files for mask-llm 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mask_llm-0.1.1.tar.gz | 7.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mask_llm-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.3 kB
Release files / mask_llm-0.1.1.tar.gz
| Download URL | mask_llm-0.1.1.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bacc9c12bdf2516682af53878489a705d539e460b1a7c489f0dbd5a388b623ed
|
|
BLAKE2b-256 checksum How to use checksums |
520e3e1c935b301b9a12d4331db38d234a26361d4d30d7a3cba1c7892526e90f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / mask_llm-0.1.1-py3-none-any.whl
| Download URL | mask_llm-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1c706c200c40454aa1b4c6529e799e38101883b8d1570ec21c0477ae8fb202b
|
|
BLAKE2b-256 checksum How to use checksums |
26ed6802fcead814af6a7de7f792c1e30ccbdbdc52235d0e371196d5a5016c39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|