Interview's MateAI Engineering
Interview's Mate

AI Engineering

LLMs, RAG, agents & evals

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
AI Engineering topics
Lesson 137/ 160
07. Deployment

Model Versioning

Pin model IDs/checkpoints and migrate traffic safely across upgrades.

IntermediatePin Model · Migration3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidHands-onQuiz (3)Practice

In plain words

Model versioning means always naming the exact AI model you use and testing carefully before switching to a new one, so surprises don't break your app.

Think of it like…

A pharmacist who dispenses a specific batch of a drug and records the batch number: if a recall happens you know exactly who received it, and you never swap the supplier without testing and telling the prescriber.

Where you’ve seen it

The production config pins model_id = "provider-model-2026-05-01" instead of the alias. A new snapshot appears. The team's upgrade playbook: (1) read the release notes; (2) run the 300-case golden set and the injection suite on the candidate with the current prompt: quality +1.2 points, format compliance −2.1 points (JSON now sometimes wrapped in prose), refusals +0.4 points, p95 latency −15%; (3) adjust the prompt to restate the format rule and use structured outputs: format compliance back to 99.6%; (4) compare cost: the new price is 30% lower per token but the new tokenizer produces 12% more tokens for the same text, so cost per request changes by 0.70 × 1.12 = 0.784, −21.6%; (5) shadow for a day, canary 5% → 25% → 100% over a week with the guardrails from the canary lesson; (6) keep the old snapshot configured as the rollback target until the provider's retirement date, which was announced months ahead. A daily drift probe runs 50 fixed prompts at temperature 0 against the pinned model and alerts if outputs or pass rate shift by more than 3 points, catching provider-side changes to a supposedly fixed model. The fine-tuned classifier model is registered with base model, training data hash, hyperparameters and eval scores, and promoted from staging to production stage with an approval.

Words you’ll hear

Snapshot (pinned version)
A dated, immutable model identifier whose behaviour should not change.
Alias
A moving name such as latest that points to different models over time.
Deprecation / retirement
The provider's announced end-of-life date for a model version.
Drift probe
A scheduled fixed test set that detects behaviour changes in a model.

Visual diagram

Loading interactive diagram

Theory & deep dive

Pinning, identifying and tracking models

Hosted models: use the provider's dated snapshot identifier in configuration (see environment configs) and record it in every trace. Aliases like latest or family names without a date can be re-pointed, changing behaviour without a code change; use them only in exploration. Subscribe to deprecation notices and track retirement dates in a register (model, owner, dependent services, retirement date, replacement candidate) with reminders well ahead of the deadline. Fine-tuned models get a version record: base model and version, training data version and hash, method (LoRA, full), hyperparameters, evaluation results, creator and date. Open-weight models: pin the repository revision or checkpoint SHA-256, quantisation format and the serving engine version, since an engine upgrade can alter outputs.

A model registry (MLflow, a hub with revisions, a provider's fine-tune registry or a simple table) holds versions with stages (staging, production, archived) and transitions requiring approval, so "which model serves production?" has one authoritative answer. Include embedding models and rerankers: changing an embedding model requires re-embedding the corpus and rebuilding the index, so version indexes with the embedding model ID and migrate with a parallel index and alias switch (blue-green) rather than in place.

A registry entry

name: support-classifier, version: 7, base: open-8b@rev a1b2c3, train_data: sha256:77aa…, method: LoRA r=16, eval: pass 0.91 · macro-F1 0.88, stage: production, approved_by: ml-lead, rollback_to: version 6.

Key takeaway: Pin dated snapshots or hashed checkpoints, track deprecations and register fine-tuned and embedding models with their lineage.

Upgrading safely: evals, prompts, cost and drift

Run the same golden set, safety suite and latency tests on the candidate, per slice, and compare with the current model: expect trade-offs (quality up, format compliance down) and fix them with prompt changes or structured outputs; re-tune few-shot examples and tool descriptions where needed. Check cost properly: effective cost per request = price per token × tokens per request, and tokenizers differ between versions, so a 30% price cut combined with 12% more tokens is 0.70 × 1.12 = 0.784, a 21.6% saving, not 30%. Also check latency, rate limits, context window, tool-calling and structured-output support and safety behaviour (refusals, injection resistance). Then roll out progressively: shadow, canary with guardrails, full rollout, and keep the previous snapshot as the rollback target until you are confident and before its retirement.

Guard against silent drift: even pinned snapshots can change due to infrastructure or serving updates, and aliases change by design. Run drift probes (a fixed set of prompts at temperature 0, comparing outputs or scores to a stored baseline, alerting on a pass-rate shift beyond 3 points) and monitor production quality metrics by model version. Maintain fallback models (see model fallbacks), test that they work with current prompts and treat provider incidents as part of operations. For multi-model setups (routers), version the routing policy with the models it references. Document each migration (what changed, eval results, decisions) so the next one is faster and the history is auditable.

Effective cost change

New model: price per token ×0.70, tokens per request ×1.12 (new tokenizer). Cost per request ×0.784 = −21.6%. At 100,000 requests a day and $1,195 baseline LLM spend, savings ≈ $258 a day, not the $358 the price cut alone suggests.

Key takeaway: Evaluate candidates on your own suites, account for tokenizer effects, roll out gradually and watch for drift with scheduled probes.

How it works, step by step

Step 1 of 4
Platform + ML

1. Pin and register models

Use dated snapshots or hashed checkpoints in config; record lineage for fine-tuned and embedding models.

provider-model-2026-05-01
Key numbers at this step
Track
retirement dates

When to use it & trade-offs

What it is

Model versioning means pinning the exact model your application uses (a dated snapshot ID from a provider, a fine-tuned model ID, or an open-weight checkpoint with its hash) and managing upgrades as controlled migrations. Provider aliases such as latest or an unversioned name can silently change behaviour; snapshots don't. A safe upgrade follows a playbook: read the changelog, run your golden evals on the candidate, adjust prompts, check tokenizer, price and latency differences, shadow and canary the new model and keep the old one available for rollback until it is deprecated. For models you train or fine-tune, versioning also records the base model, dataset version, hyperparameters and evaluation results.

Why it matters: Models change under your feet: providers release new versions, retire old ones on a schedule and sometimes update aliases, shifting output format, refusal behaviour, tool-calling reliability, latency and cost. Unpinned dependencies cause mysterious regressions; unmanaged deprecations cause deadline-driven emergency migrations. Treating a model like any other critical dependency (pinned, tested, upgraded deliberately, with a rollback) keeps quality and cost predictable.

When to reach for it

  • Production model configuration
  • Planning provider deprecations
  • Tracking fine-tuned and embedding model lineage

When to avoid or be careful

  • Using moving aliases in production
  • Upgrading without re-running your own evals
  • Changing the embedding model without rebuilding the index

Referencing a model

Dated snapshot or hashed checkpoint
Best for: Production

Strengths: Stable behaviour; reproducible; controlled upgrades.

Watch out: Must manage migrations and deprecations.

Alias such as latest
Best for: Exploration only

Strengths: Automatic improvements.

Watch out: Silent behaviour changes and regressions.

Self-hosted open checkpoint
Best for: Full control and reproducibility

Strengths: No provider deprecation; pinned by hash.

Watch out: You maintain serving and upgrades.

Interview signals & numbers to know

When this topic comes up

  • “Quality changed and we didn't deploy anything”
  • Model deprecation notice
  • Snapshot pinning
  • Drift probes
  • Model registry stages

Benchmarks & rules of thumb

0.70 × 1.12 = 0.784 -
cost change from a 30% price cut with 12% more tokens
3 points -
example drift-probe alert threshold
50 prompts at T=0 -
size of the example daily drift probe

Common mistakes & follow-ups

Common interview mistakes

  • Assuming a price cut equals a cost cut without checking tokenizer changes.
  • Dropping the old model before the new one proves stable.
  • Forgetting that embedding changes require re-indexing.

Likely interviewer follow-ups

  • How would you migrate to a new model version?
  • Why pin model versions in production?
  • How do you detect provider-side behaviour changes?
Interview tip: Compute effective cost as price × tokens. It shows you check tokenizer effects instead of trusting headline price cuts.
Loading hands-on exercise

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Model Versioning with generative AI interview Q&A and hands-on practice.

Open Generative AI Q&A →Tech Learn Q&A
Previous topic
Prompt Versioning
Next topic
Health Checks