# Weights & Biases (wandb)

> Track, visualize, and version your machine learning experiments

- Category: Training & Fine-Tuning / Experiment Tracking
- Language: Python
- Licence: MIT
- Repository: https://github.com/wandb/wandb
- Website: https://wandb.ai
- Canonical page: https://ai-tldr.dev/tools/weights-and-biases-wandb/

## In short

Weights & Biases (wandb) is an open-source Python client library for tracking machine learning experiments. It sits in the Experiment Tracking category of the Training & Fine-Tuning tools and is open-source, written in Python and licensed MIT. To get started: install the wandb library.

## Overview

Weights & Biases (wandb) is an open-source Python client library for tracking machine learning experiments. You add a few lines of code to your training script, and it records your hyperparameters, metrics, and other run details so you can review and compare them later in the W&B web app.

It's built for ML engineers and researchers who want a record of every run instead of scattered logs and spreadsheets. As an experiment tracking tool, it sits alongside your existing training code and integrates with common ML frameworks, so you can add it to projects without rewriting them.

Beyond plain metric logging, wandb supports hyperparameter sweeps and versioning of models and datasets. The library is free and open source; the backend runs on W&B's hosted cloud or on infrastructure you manage yourself.

## What it does

- Log metrics, hyperparameters, and run metadata from a Python script or notebook with wandb.init() and run.log()
- Visualize and compare runs in the W&B web app, including how metrics change across training steps
- Run hyperparameter sweeps to search over configurations
- Version models and datasets as artifacts
- Integrates with popular ML frameworks and libraries for quick setup in existing projects
- Choose hosted multi-tenant cloud, dedicated cloud, or self-managed deployment on your own infrastructure

## Getting started

Install the library, create an API key, then log a run from your training code.

1. Install the wandb library

   Install wandb from PyPI with pip.

```bash
pip install wandb
```

2. Sign up and create an API key

   Sign up for a W&B account and create an API key at wandb.ai/settings. Optionally run wandb login to store it on your machine; otherwise W&B prompts you the first time you use it.

```bash
wandb login
```

3. Track a training experiment

   In your Python script or notebook, initialize a run with wandb.init(), pass your hyperparameters as config, and log metrics with run.log().

```python
import wandb

project = "my-awesome-project"
config = {"epochs": 1337, "lr": 3e-4}

with wandb.init(project=project, config=config) as run:
    # Training code here
    run.log({"accuracy": 0.9, "loss": 0.1})
```

## When to use it

- Keep a searchable record of every training run's hyperparameters and metrics instead of manual logs or spreadsheets
- Compare accuracy and loss curves across many runs to pick the best configuration
- Run hyperparameter sweeps to find good settings for a model
- Version datasets and trained models so results stay reproducible over time
