Fine-tuning safely: training data security basics

Fine-tuning goes wrong in four predictable ways: the model memorizes personal data, the training set is poisoned or used without the right to use it, a model file runs code when it loads, or the new model ships without being tested. Each has a cheap control, and all of them are easier before the first training run than after.

Can a fine-tuned model leak its training data?

Yes. A model can reproduce rare strings from its training data word for word when prompted with the right prefix, and fine-tuning often passes over a small set several times, which makes that more likely. Assume any personal information in the set can be recovered.

A typical case: a team fine-tunes on exported support tickets so the model learns the house tone. The tickets also hold names, email addresses and the occasional card number pasted by a customer. Nobody meant to teach the model those, but a well-chosen prompt can bring them back. Treat the weights as holding the same class of data as the dataset, and strip what the task does not need before training.

Poisoned or unlicensed training data

Whoever can write to the training set can change what the model does. That might be a colleague with access to a shared bucket, a labelling contractor, or a feedback loop where users rate answers and the ratings flow back into training. A small number of crafted examples can teach a model to behave differently when it sees a trigger phrase. The OWASP Top 10 for LLM applications (2025) lists this as LLM04, Data and Model Poisoning.

Unlicensed data is the quieter version. Scraped text, a public dataset with non-commercial terms, or customer records collected for billing can all end up in a training set. Under PIPEDA and the provincial privacy laws such as BC PIPA, purpose matters.

Do we need consent to train on customer data?

Possibly. Canadian privacy law ties personal information to the purposes it was collected for, and model training is often not one of them. Whether your case needs fresh consent is a question for your counsel; we are not lawyers and work alongside them.

Why is pickle a problem for model files?

Loading a pickle file can run arbitrary code, and several common model formats are pickle underneath. Loading an untrusted model file is the same as running an untrusted program with the loader’s access. Python’s own pickle documentation warns that the module is not secure and that you should only unpickle data you trust.

The fix is mostly habit. Prefer the safetensors format, which stores weights without executable content. Scan model files before loading them, and load anything from outside in an isolated environment that holds no production credentials. Sourcing models safely is covered in more depth under AI supply chain and model integrity.

What is an evaluation gate?

An evaluation gate is a set of tests a new model must pass before release, written before training starts: task quality, memorization probes, safety checks against the base model and known trigger phrases. A failure blocks the release.

Without one, a fine-tuned model reaches users because the loss curve looked good. Write the tests first, so nobody tunes them to fit the result. Include probes built from real records in the training set: if the model completes them, the minimization step failed.

What to put in place before the first training run

  1. A dataset record for each source: where it came from, the terms it came under, and what people were told it was for.
  2. Minimization: drop fields the task does not need and replace direct identifiers, including those buried in free text.
  3. Write control: few people can change the training set, and each run trains on a hashed, frozen version.
  4. Safe model files: safetensors where possible, scanning before load, isolation for anything external.
  5. Restricted weights: know who can download them and where copies live.
  6. An evaluation gate that can block a release.

None of this needs a new platform. It needs someone to decide it before the data is copied into a training bucket.

Getting a review before you train

Our secure model fine-tuning and training data governance service reviews the pipeline and specifies these controls. Related pieces are indexed at writing.

Discuss a scope