All templates
Sequence template

ML model training pipeline

Data ingestion, preprocessing, training, validation, and deployment steps.

Every data science team owns a machine learning model somewhere in production, and almost every team discovers — during a model audit or an accuracy regression — that nobody has an accurate picture of how it gets trained and deployed. This template maps the pipeline in eight steps: data fetch, cleaning, feature engineering, training, validation, registration, deployment, and monitoring.

The sequence shows the handoff between data engineers (managing the source), ML engineers (training), and DevOps (monitoring production predictions). By making this visible, you align on what "training succeeded" means and where each team's responsibilities begin and end.

When to use this template

  • ML platform design — map your training infrastructure before writing code, so data engineers, ML engineers, and DevOps agree on data format, model versioning, and deployment gates.
  • Onboarding ML engineers — explain the pipeline so new hires understand where models come from, how often they retrain, and what happens when accuracy drops.
  • MLOps debugging — when a model stops improving, trace which step in the pipeline stalled: did the data source change? Did feature engineering break? Did validation become stricter?

How to adapt it

Rename the participants and steps to your real ML stack:

  • Add data quality checks (null rates, schema validation) between data fetch and preprocessing to catch broken data sources early.
  • Insert hyperparameter tuning (grid search, random search) as a separate loop after training, showing how you optimize learning rate and regularization.
  • Extend monitoring to show alert routing: if accuracy drops below 85%, page the on-call ML engineer; if it's slightly below target, auto-trigger a retraining job.

Visual edits regenerate the sequence syntax, so you can sketch your training orchestration and share it with data science and ops teams.

Mermaid code

Copy it anywhere Mermaid is supported — GitHub, Notion, or your docs.

sequenceDiagram
    participant Engineer
    participant DataSource as Data Source
    participant Pipeline
    participant Trainer
    participant Validator
    participant Registry
    participant Monitor

    Engineer->>Pipeline: Trigger training job
    Pipeline->>DataSource: Fetch raw data
    DataSource-->>Pipeline: Return dataset
    
    Pipeline->>Pipeline: Clean & normalize
    Pipeline->>Pipeline: Feature engineering
    Pipeline->>Trainer: Send training data
    
    Trainer->>Trainer: Initialize model
    Trainer->>Trainer: Train on batches
    Trainer-->>Pipeline: Model checkpoint
    
    Pipeline->>Validator: Send validation set
    Validator->>Validator: Compute metrics
    Validator-->>Pipeline: Accuracy, AUC, loss
    
    alt Metrics meet threshold
        Pipeline->>Registry: Register model version
        Registry->>Monitor: Deploy to staging
        Monitor-->>Engineer: Training succeeded
    else Metrics below threshold
        Pipeline->>Engineer: Alert: training failed
    end

Frequently asked questions

What is an ML model training pipeline?
A training pipeline is the automated sequence from raw data to a model ready for production. It fetches data, cleans it, extracts features, trains a model on batches, validates accuracy against test data, and registers the best model for deployment. Pipelines run on a schedule (hourly, daily) to retrain on fresh data, catching model drift and performance degradation before it hits users.
Why separate training data from validation data?
Training data teaches the model; validation data tests whether it learned something real or just memorized the training set. If you validate on training data, the model always looks perfect. Validation data is held-out (the model never sees it during training), so accuracy on validation data predicts real-world performance.
What does 'model drift' mean and why does this diagram show monitoring?
Over time, real-world data shifts — user behavior changes, the market moves — and a model trained months ago performs worse. Drift is invisible until you measure it. Monitoring compares predictions on fresh data against a holdout ground truth. When accuracy drops below a threshold, the pipeline retrains. This feedback loop keeps the model fresh.
How do I adapt this diagram for my ML stack (TensorFlow, PyTorch, scikit-learn)?
The pipeline structure is framework-agnostic. Rename 'Trainer' to your library, add preprocessing steps (scaling, encoding) specific to your data, and customize the validation metrics (accuracy for classification, RMSE for regression). Visual edits regenerate clean Mermaid, so you can sketch your actual pipeline and share it with the team.

Related templates