Research & Innovation

Getting Started With Weights & Biases: Stop Losing Track of Which Run Actually Worked

A few lines added to a training script turn every run into a logged, comparable, shareable experiment — the difference between 'I think the third run was best' and actually knowing.

If you’ve ever fine-tuned a model, changed one hyperparameter, run it again, and then genuinely couldn’t remember whether run three or run five had the better loss curve, you’ve hit the exact problem Weights & Biases (W&B) exists to solve. It’s an experiment-tracking tool: add a few lines to a training script, and every run gets logged — metrics, hyperparameters, system stats, even sample outputs — into a browser dashboard where runs sit next to each other and you can actually compare them instead of reconstructing them from memory or scattered log files.

1. Install and authenticate

pip install wandb
wandb login

wandb login opens a browser flow to grab your free API key from wandb.ai (an account is free for individuals and small projects, with usage limits on team/enterprise tiers). Paste the key back into the terminal once, and it’s cached locally for future runs.

2. Instrument a training script

The core pattern is three calls wrapped around your existing training loop:

import wandb

wandb.init(project="my-fine-tune", config={
    "learning_rate": 2e-5,
    "batch_size": 16,
    "epochs": 3,
})

for epoch in range(config.epochs):
    for step, batch in enumerate(dataloader):
        loss = train_step(batch)
        wandb.log({"loss": loss, "epoch": epoch})

wandb.finish()

wandb.init() starts a tracked run and records your config — every hyperparameter you care about reproducing later. wandb.log() can be called anywhere in the loop with any dictionary of scalars, and it’s cheap enough to call every step without meaningfully slowing training. If you’re using a common framework — Hugging Face Trainer, PyTorch Lightning, Keras — W&B has a built-in integration that logs automatically with a single flag or callback, no manual wandb.log() calls needed.

3. Read the dashboard

Once a run is logging, the W&B web dashboard shows live, updating charts for everything you logged — loss curves, learning rate schedules, GPU utilization if you’re tracking system metrics. The useful part shows up once you have more than one run: select multiple runs and W&B overlays their metrics on the same chart, with hyperparameters shown in a sortable table alongside, so “which config actually got the lowest validation loss” becomes a sort click instead of an archaeology project through old terminal output.

4. Log more than scalars

Beyond numbers, wandb.log() accepts images, audio, tables, and even 3D point clouds — genuinely relevant if your pipeline is a creative one, since you can log generated sample outputs at each checkpoint and watch training quality evolve visually across a run, not just watch a loss number go down. wandb.Artifact also versions datasets and model checkpoints, so a specific model file stays traceable back to the exact run and config that produced it.

Where this fits in your pipeline

W&B is a tracking layer, not a training framework — it doesn’t replace anything you’re already using, it just stops every run’s results from evaporating the moment your terminal scrolls past them. Pair it with running your own model benchmark for the evaluation side, and a reproducible training setup in Docker for the environment side, and you’ve got the three pieces most ad hoc fine-tuning setups are missing.