Safety, licences and upkeep
9 min read
What the licences allow
A fine-tuned model combines several things, and each has its own terms: the base model, the training data, the libraries and any outputs you used from another model. Check each one for:
- Use. Some licences restrict commercial use, large deployments or particular fields.
- Distribution. Whether you may share or sell the tuned weights, and under which terms.
- Attribution. Whether you must name the base model or pass the licence on.
- Outputs from other models. Provider terms may limit using their outputs to train a competing model, as Distillation noted.
Record the exact model version, dataset versions and licence text with every release. Nothing in this Lesson is legal advice, so ask a lawyer when the stakes are high.
Private data in the training set
Training data collected from real use often holds email addresses, phone numbers, account numbers and secrets. A model can memorise rare strings, so removing the source file later does not remove the influence from trained weights. The safest time to act is before training. Keep only what you need, limit who can read it and set a deletion process.
The program below scans a few training rows for common patterns and replaces them with labels. The data is invented, and the patterns catch only simple cases. Names, addresses and free-text details need more than a regular expression, so treat the scan as a first filter and sample by hand afterwards.
import re
patterns = {
"email": re.compile(r"[\w.+-]+@[\w-]+\.[\w.]+"),
"phone": re.compile(r"\+?\d[\d \-]{7,}\d"),
"key": re.compile(r"\bsk-[A-Za-z0-9]{8,}\b"),
}
rows = [
"Please email maria@example.test about order 118.",
"Call me on +49 170 1234567 after noon.",
"My key is sk-test1234abcd, please check it.",
"How do I reset my password?",
]
found = {name: 0 for name in patterns}
clean = []
for row in rows:
for name, pattern in patterns.items():
found[name] += len(pattern.findall(row))
row = pattern.sub(f"[{name}]", row)
clean.append(row)
print("found:", found)
print(f"rows changed: {sum(a != b for a, b in zip(rows, clean))} of {len(rows)}")
for row in clean:
print(" ", row)It prints:
found: {'email': 1, 'phone': 1, 'key': 1}
rows changed: 3 of 4
Please email [email] about order 118.
Call me on [phone] after noon.
My key is [key], please check it.
How do I reset my password?Three of four rows held private details. Keep the raw file out of the repository and out of logs, and apply the same care to evaluation sets and review tools, as Cleaning data and checking quality describes.
Test for harmful output
Write tests for the harms that matter for your application, such as revealing private data, giving unsupported advice or following instructions hidden in user text. Include prompts that try to bypass the intended behaviour. Run them on the base model and on the tuned model, because fine-tuning can weaken safety behaviour that the base model had, as Catastrophic forgetting warned. Record failures, and decide in advance which outputs a person must review. The OWASP list for LLM applications is a useful starting checklist.
Watch it after release
A model that passed its tests can still get worse in use, because inputs and users change. Track error rate, latency, refusals and user reports, and compare them with the numbers from your evaluation. The program below flags the first week in which the weekly accuracy has stayed below an agreed floor for two weeks in a row.
evaluation_accuracy = 0.90
floor = evaluation_accuracy - 0.05
weekly = [0.91, 0.89, 0.88, 0.86, 0.84, 0.83]
below = 0
for week, accuracy in enumerate(weekly, start=1):
below = below + 1 if accuracy < floor else 0
status = "ALERT" if below >= 2 else "ok"
print(f"week {week}: {accuracy:.0%} {status}")It prints:
week 1: 91% ok
week 2: 89% ok
week 3: 88% ok
week 4: 86% ok
week 5: 84% ok
week 6: 83% ALERTWeek 5 is the first below the 85% floor, and week 6 is the second in a row, so the alert fires then. A single low week can be noise, so the rule waits for two. Pick the floor and the number of weeks before launch and write them down. Sample outputs for review only where your privacy rules permit it. Keep the previous model ready for a quick rollback.
When to retrain
Retrain when a measured change justifies it: new products, new policies, a shift in the inputs or a drop that error analysis ties to the data. First check whether updated retrieval, a changed prompt or application code solves it, as RAG or fine-tuning? explains, because a retrain costs time and risks new regressions. When you do retrain, evaluate on current cases and on the older behaviour you must keep, as Evaluating a fine-tuned model describes. The NIST AI Risk Management Framework offers a wider structure for these decisions.
- LicenceRecord model, data and licence versions.
- CleanRemove private details from training data.
- TestRun harm tests on the tuned and the base model.
- MonitorTrack quality, latency and reports against a floor.
- RespondRoll back, fix the data or retrain, then re-test.
When is private data easiest to remove?
Your training file holds emails.
A model can memorise strings, so removal later may not remove the influence.
What should you record with each release?
A model goes to production.
You need them to reproduce, audit and meet licence terms.
Why wait for two low weeks before an alert?
One weekly score dips.
Set the rule before launch and write it down.
Your reading position is saved
0 of 36 complete
Lesson complete
Safety, licences and upkeep
Up next