Built by Minibase - Train and deploy small AI models from your browser.Browse all of the models and datasets available on the Minibase Marketplace.
📋 Model Summary
Minibase-DeId-Small is a specialized language model fine-tuned for text de-identification tasks. It automatically detects and replaces personal identifiers (PII) such as names, dates, addresses, phone numbers, and other sensitive information with standardized placeholder tags while preserving the original meaning and context of the text.
Key Features
🔒 Privacy-First: Removes personal identifiers automatically
🎯 Perfect PII Detection: 100% detection rate when PII is present
✅ Strong PII Removal: 65% of texts completely de-identified
📏 Compact Size: 136MB (Q8_0 quantized)
⚡ Fast Inference: 477ms average response time
🌐 Multi-Domain: Works across medical, legal, HR, and general text
🔄 Local Processing: No data sent to external servers
🚀 Quick Start
Local Inference (Recommended)
Install llama.cpp (if not already installed):
bash
1# Clone and build llama.cpp2git clone https://github.com/ggerganov/llama.cpp
3cd llama.cpp
4make56# Return to project directory7cd../de-id-small
Download the GGUF model:
bash
1# Download model files from HuggingFace2wget https://huggingface.co/Minibase/DeId-Small/resolve/main/model.gguf
3wget https://huggingface.co/Minibase/DeId-Small/resolve/main/deid_inference.py
4wget https://huggingface.co/Minibase/DeId-Small/resolve/main/config.json
5wget https://huggingface.co/Minibase/DeId-Small/resolve/main/tokenizer_config.json
6wget https://huggingface.co/Minibase/DeId-Small/resolve/main/generation_config.json
Start the model server:
bash
1# Start llama.cpp server with the GGUF model2../llama.cpp/llama-server \3 -m model.gguf \4 --host 127.0.0.1 \5 --port 8000\6 --ctx-size 2048\7 --n-gpu-layers 0\8 --chat-template
Make API calls:
python
1import requests
23# De-identify text via REST API4response = requests.post("http://127.0.0.1:8000/completion", json={5"prompt":"Instruction: De-identify this text by replacing all personal information with placeholders.\n\nInput: Patient John Smith, born 1985-03-15, lives at 123 Main St.\n\nResponse: ",6"max_tokens":256,7"temperature":0.18})910result = response.json()11print(result["content"])12# Output: "Patient [FIRSTNAME_1] [LASTNAME_1], born [DOB_1], lives at [BUILDINGNUMBER_1] [STREET_1]."
Python Client (Recommended)
python
1# Download and use the provided Python client2from deid_inference import DeIdClient
34# Initialize client (connects to local server)5client = DeIdClient()67# De-identify sensitive text8sensitive_text ="Dr. Sarah Johnson called from (555) 123-4567 about patient Michael Brown."9clean_text = client.deidentify_text(sensitive_text)1011print(clean_text)12# Output: "Dr. [FIRSTNAME_1] [LASTNAME_1] called from [PHONE_1] about patient [FIRSTNAME_2] [LASTNAME_2]."1314# Batch processing15texts =[16"Employee John Doe earns $85,000 annually.",17"Contact jane.smith@company.com for details."18]19clean_texts = client.deidentify_batch(texts)20print(clean_texts)21# Output: ["Employee [FIRSTNAME_1] Doe earns [CURRENCYSYMBOL_1][AMOUNT_1] annually.", "Contact [EMAIL_1] for details."]
Direct llama.cpp Usage
python
1# Alternative: Use llama.cpp directly without server2import subprocess
3import json
45defdeidentify_with_llama_cpp(text:str)->str:6 prompt =f"Instruction: De-identify this text by replacing all personal information with placeholders.\n\nInput: {text}\n\nResponse: "78# Run llama.cpp directly9 cmd =[10"../llama.cpp/llama-cli",11"-m","model.gguf",12"--prompt", prompt,13"--ctx-size","2048",14"--n-predict","256",15"--temp","0.1",16"--log-disable"17]1819 result = subprocess.run(cmd, capture_output=True, text=True, cwd=".")20return result.stdout.strip()2122# Usage23result = deidentify_with_llama_cpp("Patient Sarah Johnson, DOB 05/12/1980.")24print(result)
📊 Benchmarks & Performance
Overall Performance (100 samples)
Metric
Score
Description
PII Detection Rate
100%
Model responds to PII presence with placeholders
PII Removal Completeness
65%
Successfully removes all detectable PII from output
Semantic Preservation
81.1%
How well original meaning is preserved
Average Latency
477ms
Response time performance
Understanding the Metrics
PII Detection Rate (100%): Measures whether the model recognizes when personal information is present in the input text and responds by generating placeholders. This is a measure of the model's sensitivity to PII presence.
PII Removal Completeness (65%): Measures whether the model successfully removes ALL detectable personal identifiers from the output text. This is a strict measure - even one remaining PII element (like a name, date, or phone number) counts as incomplete.
Why 65% is Strong Performance: Achieving 100% completeness is extremely challenging because:
PII can be contextually important (e.g., "Dr. Smith" in medical records)
Some PII might be embedded in complex ways
Perfect removal could harm text coherence or meaning
65% completeness means the model reliably sanitizes most texts while preserving utility
Performance Insights
✅ Perfect PII Detection: 100% of texts with PII trigger placeholder generation
✅ Strong PII Removal: 65% of outputs are completely free of detectable PII
✅ Excellent Semantic Preservation: 81.1% meaning retention during de-identification
✅ Fast Inference: 477ms average response time
✅ Unified Performance: Consistent across medical, legal, HR, and general text
✅ Apple Silicon users get Metal acceleration automatically
📖 Usage Examples
Basic De-identification
python
1# Input: "John Smith from New York called about his account."2# Output: "[FIRSTNAME_1] [LASTNAME_1] from [CITY_1] called about his account."34# Input: "Patient born on 1990-05-15 visited Dr. Williams."5# Output: "Patient born on [DOB_1] visited Dr. [LASTNAME_1]."
Medical Records
python
1# Input: "Sarah Johnson, DOB 05/12/1980, visited St. Jude Hospital."2# Output: "[FIRSTNAME_1] [LASTNAME_1], DOB [DOB_1], visited [HOSPITAL_1]."34# Input: "Dr. Michael Brown called from (555) 123-4567."5# Output: "Dr. [FIRSTNAME_1] [LASTNAME_1] called from [PHONE_1]."
Legal Documents
python
1# Input: "Attorney Robert Davis from Legal Eagles LLP filed the motion."2# Output: "Attorney [FIRSTNAME_1] [LASTNAME_1] from [ORGANIZATION_1] filed the motion."34# Input: "Case LD-2022-007 was filed on December 1, 2022."5# Output: "Case [CASE_ID_1] was filed on [DATE_1]."
HR Records
python
1# Input: "Employee John Doe earns $85,000 annually."2# Output: "Employee [FIRSTNAME_1] Doe earns [CURRENCYSYMBOL_1][AMOUNT_1] annually."34# Input: "Contact jane.smith@company.com for details."5# Output: "Contact [EMAIL_1] for details."
Here are real examples of the model in action, tested across different sectors and text types:
🏥 Medical Records
Input:
Patient John Smith, born on March 15, 1985, visited Dr. Emily Johnson at St. Mary Hospital on January 10, 2024. His phone number is (555) 123-4567 and he lives at 123 Oak Street, Springfield, IL 62701.
Output:
Patient [FIRSTNAME_1] [MIDDLENAME_1], born on [DOB_1], visited Dr. [MIDDLENAME_2] [LASTNAME_1] at [CITY_1] Hospital on [DATE_1]. His phone number is [PHONENUMBER_1] and he lives at [BUILDINGNUMBER_1] [STREET_1], [STATE_1], [STATE_2] [STATE_3].
⚖️ Legal Documents
Input:
Attorney Robert Davis from Davis & Associates LLP filed a lawsuit on behalf of client Sarah Johnson. The case involves Ms. Johnson's accident on December 15, 2023, at 456 Main Street, Boston, MA. Contact information: rdavis@lawfirm.com, (617) 555-0123.
Output:
Attorney [FIRSTNAME_1] [LASTNAME_1] from [COMPANYNAME_1] filed a lawsuit on behalf of client [FIRSTNAME_2] [LASTNAME_2]. The case involves Ms. [LASTNAME_3]'s accident on [DATE_1], at [BUILDINGNUMBER_1] [STREET_1], [STATE_1], [STATE_2]. Contact information: [EMAIL_1], [PHONENUMBER_1].
👥 HR Records
Input:
Employee record for Michael Chen (ID: EMP-2023-0456). Born: July 22, 1990. Position: Senior Software Engineer. Salary: $125,000 annually. Address: 789 Pine Avenue, Seattle, WA 98101. Email: mchen@techcorp.com. Emergency contact: Jennifer Chen, sister, phone (206) 555-9876.
Bank statement for account holder Lisa Rodriguez, Account #9876543210. Transaction on March 5, 2024: Deposit of $2,500 from employer TechSolutions Inc. Address: 321 Elm Drive, Austin, TX 78701. Phone: (512) 555-2468. Email: lisa.rodriguez@email.com.
Output:
Bank statement for account holder [FIRSTNAME_1] [MIDDLENAME_1], Account #[ACCOUNTNUMBER_1]. Transaction on [DATE_1]: Deposit of [CURRENCYSYMBOL_1]2,500 from employer [COMPANYNAME_1]. Address: [BUILDINGNUMBER_1] [STREET_1], [CITY_1], [STATE_1] [STATE_2]. Phone: [PHONENUMBER_1]. Email: [EMAIL_1].
💬 Social Media / Personal
Input:
Hey everyone! My friend David Wilson just got engaged to his girlfriend Maria Garcia. They met at Stanford University in 2018 and have been dating for 5 years. David works as a data scientist at Google in Mountain View, CA. Maria is a doctor at Stanford Hospital. Their wedding is planned for June 15, 2025, at Napa Valley Vineyard. Send congratulations to david.wilson@gmail.com or call (650) 555-0199!
Output:
Hey everyone! My friend [FIRSTNAME_1] [LASTNAME_1] just got engaged to his girlfriend [FIRSTNAME_2] [LASTNAME_2]. They met at Stanford University in 2018 and have been dating for 5 years. [FIRSTNAME_3] works as a data scientist at Google in [CITY_1], [STATE_1]. [FIRSTNAME_4] is a doctor at Stanford Hospital. Their wedding is planned for [DATE_1], at [STREET_1]. Send congratulations to [EMAIL_1] or call [PHONENUMBER_1]!
📋 Meeting Notes
Input:
Meeting notes: Dr. Amanda White (awhite@hospital.org, (415) 555-1122) discussed patient care with nurse James Brown. Patient: Mark Johnson, DOB 11/20/1975, diagnosed with diabetes on 03/10/2023. Address: 789 Oak Ave, San Francisco, CA 94102.
Output:
Meeting notes: Dr. [FIRSTNAME_1] [MIDDLENAME_1] [LASTNAME_1], [PHONENUMBER_1] discussed patient care with nurse [FIRSTNAME_2] [LASTNAME_2]. Patient: [FIRSTNAME_3] [MIDDLENAME_3], DOB [DOB_1], diagnosed with diabetes on [DATE_1]. Address: [BUILDINGNUMBER_1] [STREET_1], [CITY_1], [STATE_1] [STATE_2].
📚 Limitations & Biases
Current Limitations
Limitation
Description
Impact
Placeholder Format
Uses specific naming conventions (e.g., [FIRSTNAME_1])
May not match all expected formats
Complex Contexts
May struggle with highly nested or ambiguous PII
Could miss subtle personal information
Language Scope
Primarily trained on English text
Limited performance on other languages
Context Window
Limited to 2,048 token context window
Cannot process very long documents
Structured Data
Less effective on highly formatted data (tables, forms)
Lower performance on structured HR/financial data
Potential Biases
Bias Type
Description
Mitigation
Cultural Names
May not recognize all international naming patterns
Regular updates with diverse data
Regional Formats
Limited exposure to regional address/phone formats
Expand training data coverage
Emerging PII
May not recognize newest types of personal data
Continuous model updates
Domain Specificity
Performance varies across different text types
Use domain-specific fine-tuning
Development Setup
bash
1# Clone the repository2git clone https://github.com/minibase-ai/deid-small
3cd deid-small
45# Install dependencies6pip install -r requirements.txt
78# Run tests9python -m pytest tests/
📜 Citation
If you use DeId-Small in your research, please cite:
bibtex
1@misc{deid-small-2025,
2 title={DeId-Small: A Compact Text De-identification Model},
3 author={Minibase AI Team},
4 year={2025},
5 publisher={Hugging Face},
6 url={https://huggingface.co/Minibase/DeId-Small}
7}