Sub topic 4
Weights & Biases: runs, projects, and the hosted service
Assume you know basic Python, can run commands in a shell, and have trained a model with hyperparameters and validation metrics. You should also understand that a client application can send data to a remote service through an API.
Weights & Biases, usually called W&B, is a hosted experiment-tracking platform. Its Python client sends information from your training process to the W&B service. The service stores the data, builds charts, and provides a web interface for comparing runs.
The W&B data model
A run is one execution of a training or evaluation script. A run usually contains:
- Config values, such as learning rate, batch size, and model depth.
- Metrics, such as training loss and validation AUC.
- A step number or timestamp for each metric value.
- Tags and notes that describe the run.
- Files, called artifacts, such as datasets, checkpoints, and model outputs.
A project groups related runs. For example, every run for a churn model can belong to the churn-model project. Projects give a team one place to compare experiments and discuss results.
A team or user account owns projects. Access settings control who can view, edit, or manage the data. The exact controls depend on the W&B account and plan.
| W&B object | Purpose | Example |
|---|---|---|
| Project | Groups related runs | `churn-model` |
| Run | Records one execution | `baseline-2026-11-30` |
| Config | Stores chosen inputs | `learning_rate=0.1` |
| Metric | Stores measured values | `val_auc=0.91` |
| Artifact | Stores a versioned file or dataset | `model:v3` |
How a run reaches the service
The training process uses the W&B Python SDK. wandb.init creates a run and returns a run object. The SDK records configuration and sends metric data during training. A background process usually handles communication so logging does not block every training step.
The service then stores the run and presents it in the project page. You can create charts, filter runs by config or tags, and compare metric histories.
pip install wandb
wandb loginThe wandb login command connects the local environment to your W&B account. In automated jobs, provide the API key through a secret or environment variable rather than placing it in source code.
import wandb
run = wandb.init(
project="churn-model",
name="baseline",
config={
"max_depth": 6,
"learning_rate": 0.1,
"model": "gradient_boosting",
},
)
for step, auc in enumerate([0.84, 0.88, 0.91]):
run.log(
{
"train_loss": 0.42 - step * 0.05,
"val_auc": auc,
},
step=step,
)
run.summary["selected_for_review"] = True
run.finish()The config dictionary records what the run used. The log call records observations over time. The step argument makes the order explicit. The summary stores final or selected values that do not form a time series.
Hosted-service architecture
W&B normally provides the control plane and user interface as a hosted service. Your training job remains in your environment, such as a laptop, virtual machine, or Kubernetes job. The SDK sends run data to W&B over the network.
This arrangement reduces the infrastructure your team must operate. It also means that network access, account permissions, retention rules, and vendor policies become part of your system design.
You can often run in offline mode when a job cannot access the network. The SDK writes run data locally, and you synchronize it later. This helps with restricted environments, but delayed synchronization makes real-time monitoring unavailable.
W&B compared with a self-hosted tracker
A hosted W&B project emphasizes collaboration. Team members can open the same project page, inspect charts, filter runs, and comment on results without operating a tracking database.
MLflow can also provide a web interface and team collaboration, but a common MLflow deployment separates the tracking server, metadata backend, and artifact store. W&B hides more of that infrastructure behind its hosted service. The trade-off is less operational work but greater dependence on the service's account model, network access, pricing, and export capabilities.
For either system, decide which information is authoritative. A run page can show that a model achieved a score, but the score is useful only when the data version, code revision, evaluation split, and metric definition are recorded with it.
Exercise
A training job runs in a private network without outbound access. What W&B approach can record the run for later upload, and what capability is unavailable until synchronization?
Show answer
Use offline mode and synchronize the run later. Real-time charts and remote run comparison are unavailable until the data reaches the hosted service.