Skip to content

PII Fine-Tuning ​

GhostAI supports true ML fine-tuning for PII detection: train a custom model on your labeled data so detection better matches your entity types and domain. The fine-tuned model runs entirely in your environment — no labeled data is ever sent to GhostAI.

When to Use It ​

  • High false-positive or false-negative rates: The default detection model and vertical presets do not match your data well enough.
  • Custom entity types: You need to detect internal identifiers, project codes, or vertical-specific terms that the default model does not cover.
  • Strict compliance naming: You want detected entity type names to align exactly with your compliance reports and audit requirements.
  • Data sovereignty: Training and inference use only your data and your infrastructure.

Prerequisites ​

  • Python 3.10+ with the GhostAI backend dependencies installed.
  • GPU is recommended for larger datasets. CPU works for small-to-moderate training runs.

Training Data Format ​

Provide labeled data as JSONL (one JSON object per line). Each record contains:

  • text — the raw input string.
  • entities — an array of labeled spans, each with character-level start/end offsets and an entity label.

Use entity labels that are consistent with the labels your deployment already recognizes. This ensures the fine-tuned model's output integrates seamlessly with the PII pipeline.

Privacy Considerations ​

You are responsible for the content of training files. Use synthetic or de-identified data whenever possible to avoid storing real PII on disk. All training runs locally — no data leaves your environment.

Training Workflow ​

Fine-tuning follows three steps:

  1. Prepare data. Collect and label representative text samples in JSONL format. Include a mix of positive examples (text containing PII) and negative examples (clean text) for best results.

  2. Run training. Execute the provided training utility from the backend root. The tool accepts your JSONL file and an output directory for the resulting model checkpoint. Optional parameters control epoch count, batch size, learning rate, and validation split.

  3. Deploy the model. Point your GhostAI instance at the new checkpoint directory. See Deployment below.

Deploying the Fine-Tuned Model ​

Custom models can be scoped at two levels:

  • Per-organization — Each organization can specify its own custom model path through organization policies in Admin settings. This supports multi-tenant deployments where different customers need different detection profiles.
  • Per-vertical — Industry vertical configurations can reference a custom model, so healthcare, financial, and other verticals each use a model tuned for their entity types.

After setting the model path, restart or reload the application so the PII pipeline picks up the new model.

Fallback Behavior ​

If a custom model path is invalid or the model fails to load, GhostAI logs a warning and automatically falls back to the default detection model. PII detection continues to function — it never silently stops.

Verifying the Deployment ​

  • Check application logs at startup for a confirmation message indicating the custom PII model was loaded.
  • In Admin → Security → AI Protection (when the status UI is enabled), the PII model should display as Custom.
  • Send test messages containing known PII and confirm the detected types and spans match expectations.

Troubleshooting ​

IssueWhat to do
Out of memoryReduce batch size, use a smaller base model, or train on a machine with more RAM/GPU.
Label mismatchUse entity labels recognized by the pipeline. Unknown labels may be dropped or mapped incorrectly.
Slow inferenceFine-tuned models are comparable in size to the base model. Ensure adequate CPU or GPU resources.
Model not loadingConfirm the checkpoint path is correct and accessible by the application process. Check logs for the specific error and fallback message.

Vertical Considerations ​

Fine-tuning is especially valuable for verticals with specialized identifiers that general-purpose models miss:

  • Healthcare — Medical record numbers, health plan IDs, Medicare beneficiary identifiers, and other HIPAA-relevant types.
  • Financial services — Credit card numbers, bank account and routing numbers, IBANs, and SSNs for PCI-DSS and GLBA compliance.
  • Legal — Client and matter identifiers, party names, and case-specific PII relevant to privilege and confidentiality rules.
  • Manufacturing — Trade secrets, formula IDs, batch codes, and proprietary process identifiers.
  • Government — CUI markers, clearance-related identifiers, and ITAR-sensitive content alongside standard PII.
  • Technology — API keys, tokens, internal service names, and source code fragments.

Other verticals (retail, education, consumer, automotive) benefit by combining the entity types above as applicable to their domain.

Privacy and Compliance Benefits ​

  • Zero data exfiltration — All training and inference happen in your environment.
  • Audit-ready labels — Fine-tuning lets you align detected entity names with your compliance framework.
  • Minimized over-detection — Domain-tuned models reduce false positives, so less legitimate content is unnecessarily flagged or redacted.
  • Regulatory alignment — Supports HIPAA, PCI-DSS, GLBA, GDPR, and other frameworks by detecting exactly the entity types your compliance program requires.

For more detail, see the True ML Fine-Tuning whitepaper and PII Detection.

SOC 2 Type II Certified | BAA Available | HIPAA-Ready