Skip to main content

Weights & Biases: Experiment Tracking, Sweeps & Reports

W&B is the go-to ML experiment tracker for research teams. Log metrics, visualize training, run automated hyperparameter sweeps, version datasets, and share results — all from a single Python SDK call.

✓ Real-time training visualization ✓ Bayesian hyperparameter sweeps ✓ Dataset & model artifact versioning ✓ HuggingFace native integration
Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →

Getting Started: wandb.init() and Logging

Install with pip install wandb, authenticate with wandb login, then add three lines to any training script:

import wandb
import torch

# Initialize a run — creates a unique run in your project
run = wandb.init(
    project="image-classifier",
    name="resnet50-lr-0.001",
    config={
        "architecture": "ResNet50",
        "learning_rate": 1e-3,
        "batch_size": 64,
        "epochs": 30,
        "optimizer": "AdamW",
    }
)

for epoch in range(config.epochs):
    train_loss, val_loss, val_acc = train_epoch(model, ...)

    # Log metrics — visible in real time on wandb.ai
    wandb.log({
        "epoch": epoch,
        "train/loss": train_loss,
        "val/loss": val_loss,
        "val/accuracy": val_acc,
        "lr": scheduler.get_last_lr()[0],
    })

    # Log images, confusion matrices, histograms
    wandb.log({"predictions": wandb.Image(sample_img, caption="epoch " + str(epoch))})

# Save model as artifact
artifact = wandb.Artifact("resnet50-classifier", type="model")
artifact.add_file("model.pth")
run.log_artifact(artifact)
wandb.finish()

W&B Sweeps: Automated Hyperparameter Search

Define a sweep config, then launch agents that automatically sample and run experiments:

import wandb

# Define the search space and strategy
sweep_config = {
    "method": "bayes",        # bayes | random | grid
    "metric": {"name": "val/accuracy", "goal": "maximize"},
    "parameters": {
        "learning_rate": {"distribution": "log_uniform_values", "min": 1e-5, "max": 1e-1},
        "batch_size": {"values": [16, 32, 64, 128]},
        "dropout": {"distribution": "uniform", "min": 0.1, "max": 0.5},
        "optimizer": {"values": ["adam", "adamw", "sgd"]},
    },
    "early_terminate": {"type": "hyperband", "min_iter": 3},
}

sweep_id = wandb.sweep(sweep_config, project="image-classifier")

def train_sweep():
    with wandb.init() as run:
        cfg = run.config
        model = build_model(dropout=cfg.dropout)
        optimizer = get_optimizer(cfg.optimizer, cfg.learning_rate)
        # ... training loop
        wandb.log({"val/accuracy": final_acc})

# Launch 10 parallel agents
wandb.agent(sweep_id, function=train_sweep, count=50)

HuggingFace Transformers Integration

Zero-config logging with HuggingFace Trainer — just set report_to="wandb":

from transformers import TrainingArguments, Trainer
import wandb

wandb.init(project="llm-finetuning", name="llama3-8b-qlora")

training_args = TrainingArguments(
    output_dir="./results",
    num_train_epochs=3,
    per_device_train_batch_size=4,
    gradient_accumulation_steps=4,
    warmup_ratio=0.03,
    lr_scheduler_type="cosine",
    learning_rate=2e-4,
    report_to="wandb",                # ← enable W&B logging
    logging_steps=10,
    evaluation_strategy="steps",
    eval_steps=100,
    save_strategy="steps",
    save_steps=500,
    load_best_model_at_end=True,
    metric_for_best_model="eval_loss",
)
# W&B auto-logs: loss curves, learning rate, GPU util, eval metrics, model checkpoints

W&B vs MLflow vs Comet vs Neptune

Feature W&B MLflow Comet ML Neptune.ai
Hyperparameter sweepsExcellent (Bayesian)Plugin (Optuna)OptimizerGrid/random
Collaboration reportsW&B Reports (best)Basic UIPanelsDashboards
Data/model versioningArtifacts + lineageMLflow ModelsModel registryArtifact store
Self-hostableEnterprise onlyYes (open-source)Enterprise onlyEnterprise only
Free storage100 GBUnlimited (local)Limited200 GB
HuggingFace integrationNative (report_to)ManualCallbackCallback
Best forResearch, DL teamsMLOps, self-hostedMid-size teamsScientific logs

Frequently Asked Questions

What is Weights & Biases (W&B)?▼

Weights & Biases (W&B, pronounced 'wandb') is a cloud-based MLOps platform for experiment tracking, hyperparameter optimization, and team collaboration. It provides a Python SDK that logs training metrics, model weights, datasets, and media (images, audio, tables) to a central dashboard. W&B is especially popular in research settings where sweep-based hyperparameter search and rich run comparison are essential.

How do W&B Sweeps work for hyperparameter optimization?▼

W&B Sweeps automates hyperparameter search. You define a sweep config (search space, strategy, metric to optimize), then launch agents that pick hyperparameter combinations from the controller and run your training function. Strategies include grid, random, and Bayesian optimization. Multiple agents can run in parallel on different machines, all reporting to the same sweep dashboard.

What are W&B Artifacts and when should I use them?▼

W&B Artifacts are versioned datasets, models, or other files tracked through the ML pipeline. Use them to version your training datasets alongside experiments so you always know which data produced which model. Artifacts have lineage tracking: you can see the DAG from raw data → preprocessed dataset → trained model → evaluation results. This is critical for compliance and reproducibility.

How do W&B Reports differ from regular run comparisons?▼

W&B Reports are shareable, richly formatted documents that embed live run charts, text annotations, and media. You can write a report explaining your experimental findings with embedded plots that auto-update as new runs come in. Reports are ideal for communicating results to stakeholders, writing internal research memos, or producing ablation study summaries.

Does W&B work with HuggingFace Transformers?▼

Yes, W&B integrates natively with HuggingFace Transformers via the report_to parameter. Set report_to='wandb' in your TrainingArguments and W&B automatically logs loss curves, learning rate schedules, GPU utilization, and model checkpoints as artifacts. This zero-config integration covers both Trainer and Seq2SeqTrainer.

Is W&B free for individual use?▼

W&B offers a free tier for individuals with unlimited logged data, 100 GB of artifact storage, and access to Sweeps and Reports. Teams beyond a certain size require paid plans. An on-premise/self-hosted deployment (W&B Server) is available on Enterprise plans, which is relevant for organizations with strict data residency requirements.