Mhonn YbañezSRE, DevOps, AI Engineer
 Today I Learned
Read the full page

How do ML engineers train and release models?

Posted
Tags
ai, llm, mlops

Training teaches a model from random weights, fine-tuning bends an existing model toward one job, and releasing it looks a lot like shipping any service: package it, push it to a registry, roll it out carefully, and watch it. The new part is that a model can get worse without any code changing.

This one is a follow-up to my AI roles post. I had written that ML engineers train and fine-tune models and MLOps engineers keep them running in production. But I realized I didn't know what that work actually looks like day to day.

The question I had

How do ML engineers actually train and fine-tune models, and how do they release a new one?

What I found

Training a model from scratch

Training from scratch means starting with a model whose weights are random and teaching it patterns from data.

  1. Prepare the data. Collect it, clean it, fill or drop missing values, and scale the features. Then split it three ways: a training set to learn from, a validation set to tune settings and catch overfitting along the way, and a test set that stays untouched until one final check.
  2. Pick a model. A neural network (usually in PyTorch) or a tree-based model like XGBoost, depending on the problem and the data.
  3. Define the loss. The loss function is a formula that scores how wrong the model's predictions are. Training is the work of making that number smaller.
  4. Run the training loop. For a neural network: feed in a batch of data, measure the loss, use backpropagation to work out how each weight contributed to the error, nudge the weights in the right direction, repeat. Tree models like XGBoost train differently, by adding one small tree at a time that fixes the mistakes of the ones before it.
  5. Evaluate. Check the model on the validation set with metrics like accuracy, F1 score, or AUC. If it scores great on training data but badly on validation data, it memorized instead of learned. That's overfitting.

Fine-tuning an existing model

Fine-tuning skips the expensive part. You take a model someone already trained on a huge amount of general data and adapt it to one domain or task with a much smaller dataset.

  1. Pick a base model. A pre-trained model like BERT or an open-weight LLM.
  2. Gather task data. Hundreds to thousands of good examples, like support chats or labeled medical scans. Quality matters more than size here.
  3. Choose how much of the model to change:
    • Full fine-tuning: update every weight. The deepest change, but it needs a lot of GPU memory and compute.
    • PEFT (parameter-efficient fine-tuning): freeze the base model and train a small add-on. The most common method is LoRA, which trains small extra matrices that sit alongside the frozen weights. QLoRA does the same on a base model squeezed to 4-bit, so it fits on a smaller GPU.
  4. Align it (for LLMs). SFT (supervised fine-tuning) trains on example prompts paired with good answers. RLHF (reinforcement learning from human feedback) goes further: people rank answers, and the model learns to prefer the higher-ranked ones. DPO is a simpler method that learns from those same rankings directly. These mostly shape tone and helpfulness. They help with made-up answers, but they don't remove them.
  5. Evaluate on the real task. Test the fine-tuned model on examples that look like what it will actually face.

Packaging it

Before a model can run anywhere, it gets packaged so it behaves the same in every environment.

  • Save the weights in a standard file format like Safetensors (loads fast and safely, with no hidden code) or ONNX (runs across different runtimes). Some teams also compile it with an optimizer like NVIDIA's TensorRT for faster inference on their GPUs.
  • Register the model in a model registry like MLflow, which tracks versions, the data each one was trained on, and its scores.
  • Build a container with the model, its runtime, its libraries, and its preprocessing code, then push the image to a container registry like Amazon ECR or Docker Hub.

Three ways to serve it

TypeHow it worksUsed forCommon tools
Real-timeRuns on a server behind an API and answers each request right awayChatbots, fraud checks, search autocompletevLLM (for LLMs), Triton Inference Server
BatchRuns on a schedule over a big dataset and saves the resultsProduct recommendations, weekly reportsApache Spark, Ray
EdgeShrunk down and shipped onto the device, runs without internetPhoto filters on phones, car vision, smart appliancesCore ML, LiteRT (formerly TensorFlow Lite), ONNX Runtime

Rolling it out

Nobody flips a new model to 100% of traffic on day one. The strategies are the same ones used for any service:

StrategyHow it worksWhat it tells you
ShadowThe new model gets a copy of real traffic, but its answers are only logged, never shownSpeed and errors under real load, with no risk to users. Costs double the compute, and can't tell you how users would react.
CanaryA small slice of users (say 1% to 5%) gets the new model, then the slice growsWhether it's safe to keep going
A/B testTwo groups get different models, and you compare outcomes like clicks or resolved ticketsWhether the new model is actually better, not just stable
Blue-greenTwo full environments, old and new. Once new passes its checks, traffic switches over all at onceFast switch, and an equally fast way back

CI/CD, plus CT

On top of the usual CI/CD, ML adds CT (continuous training): new data or a drop in quality can kick off retraining automatically.

  • Automated evaluation: every new model version runs against a fixed "golden dataset" to catch regressions, bias, and scores below a threshold before it goes anywhere.
  • Infrastructure: tools like Terraform provision what the model needs, like a GPU cluster, and Kubernetes manifests describe how it's deployed on that infrastructure.

Watching it in production

Once it's live, two kinds of things get watched, with tools like Prometheus and Grafana or ML-specific ones like Arize.

  • Drift. This was the new idea for me. There are two kinds:

    • Data drift: the inputs change. New kinds of users show up, and the model sees data unlike what it trained on.
    • Concept drift: the right answer changes for the same input. Fraud patterns shift, so what looked safe last year doesn't now.

    Either one can make a model worse without a single line of code changing. A drift alert usually starts the retraining pipeline, and the new model still goes through evaluation (and often a human review) before it ships.

  • System health: latency (the p99, not the average), throughput, GPU and memory use.

Where my epiphany came in

AI is like normal software, but instead of writing code in the development step, you train or fine-tune the model. Then you package it, put it in a registry, and release it, starting with shadow and moving step by step to full production.

What amazed me is how similar the workflows are. Normal software goes develop, test, build, release strategy, full prod release, then maintenance. ML goes:

SoftwareML
DevelopTrain or fine-tune
TestEvaluate on validation and test data, then a golden dataset
BuildPackage the weights and container, push to a registry
Release strategyShadow, canary, A/B
Full prod releaseFull rollout
MaintenanceRetrain when drift shows up

Even maintenance has its match. In normal software, maintenance means patching bugs and updating dependencies, then shipping a new version. In ML, it means retraining on fresher data, and the new model goes through the same pipeline again: evaluate, package, register, roll out. The difference is the trigger. Software usually needs maintenance because something in the code or its dependencies changed. A model needs it because the world it learned from changed.

Takeaway

Under the new words, an ML release is the same pipeline I already know: develop, test, build, roll out carefully, ship, maintain. What's different is that maintenance means retraining, because a model can get worse while nothing in the code changes.