πŸ€– AI/ML

Weights & Biases

WandB / W&B

An ML experiment tracking and visualization platform. Supports hyperparameter optimization and model versioning.

πŸ“– Detailed Explanation

Weights & Biases (W&B, WandB) is an MLOps platform founded in 2017 that provides machine learning experiment tracking, model version management, and hyperparameter optimization. The name derives from 'Weights' and 'Biases,' the core components of neural networks. It is an industry-standard tool used by thousands of AI research teams, including OpenAI, NVIDIA, and DeepMind.

Before W&B appeared, ML engineers managed experiment results in spreadsheets or text files. This caused reproducibility problems and difficulties in team collaboration. By adding just one line of code, W&B automatically records and visualizes all experiment metrics, hyperparameters, code versions, and system information.

There are four core features. Experiments (experiment tracking) lets you check metrics such as training loss and accuracy on a real-time dashboard. Sweeps (hyperparameter tuning) automates Bayesian optimization and grid search. Artifacts manages dataset and model versions, and Tables lets you analyze prediction results interactively.

In practice, W&B integrates natively with major frameworks such as PyTorch, TensorFlow, Hugging Face, and LangChain. In 2025, it added LLM tracing (Weave), prompt engineering tools, and an open-source LLM inference service (W&B Inference), evolving to fit the generative AI era.

πŸ’» Code Example

import wandb
import torch
import torch.nn as nn

# 1. W&B μ΄ˆκΈ°ν™”
wandb.init(
    project="my-ml-project",
    config={
        "learning_rate": 0.001,
        "epochs": 10,
        "batch_size": 32,
        "architecture": "ResNet18"
    }
)
config = wandb.config

# 2. λͺ¨λΈ μ •μ˜
model = nn.Sequential(
    nn.Linear(784, 256),
    nn.ReLU(),
    nn.Linear(256, 10)
)

# 3. ν•™μŠ΅ 루프 with W&B λ‘œκΉ…
optimizer = torch.optim.Adam(model.parameters(), lr=config.learning_rate)
criterion = nn.CrossEntropyLoss()

for epoch in range(config.epochs):
    # 더미 ν•™μŠ΅ (μ‹€μ œλ‘œλŠ” DataLoader μ‚¬μš©)
    x = torch.randn(config.batch_size, 784)
    y = torch.randint(0, 10, (config.batch_size,))

    optimizer.zero_grad()
    output = model(x)
    loss = criterion(output, y)
    loss.backward()
    optimizer.step()

    accuracy = (output.argmax(dim=1) == y).float().mean()

    # λ©”νŠΈλ¦­ λ‘œκΉ…
    wandb.log({
        "epoch": epoch,
        "train_loss": loss.item(),
        "train_accuracy": accuracy.item(),
        "learning_rate": optimizer.param_groups[0]["lr"]
    })

    print(f"Epoch {epoch}: loss={loss.item():.4f}, acc={accuracy.item():.4f}")

# 4. λͺ¨λΈ μ €μž₯ (Artifact)
artifact = wandb.Artifact("model", type="model")
torch.save(model.state_dict(), "model.pt")
artifact.add_file("model.pt")
wandb.log_artifact(artifact)

# 5. ν•˜μ΄νΌνŒŒλΌλ―Έν„° μŠ€μœ• μ„€μ • μ˜ˆμ‹œ
sweep_config = {
    "method": "bayes",  # bayes, grid, random
    "metric": {"name": "val_loss", "goal": "minimize"},
    "parameters": {
        "learning_rate": {"min": 0.0001, "max": 0.1},
        "batch_size": {"values": [16, 32, 64]},
        "epochs": {"value": 10}
    }
}

# sweep_id = wandb.sweep(sweep_config, project="my-ml-project")
# wandb.agent(sweep_id, train_function, count=20)

# 6. Hugging Face Transformers 톡합
# from transformers import Trainer, TrainingArguments
#
# training_args = TrainingArguments(
#     output_dir="./results",
#     report_to="wandb",  # W&B μžλ™ 톡합
#     run_name="bert-finetune"
# )

wandb.finish()

πŸ“Š Performance & Cost

Weights & Biases Pricing Plans as of January 2025

Plan Price Features Storage
Free (Individual) $0 5 model seats, personal projects only 5GB
Pro (Teams) $50/user/month 500 tracked hours, team collaboration 100GB
Enterprise ~$315-400/seat/month Unlimited tracking, SSO, HIPAA Custom

Additional Charges (Pro Plan)

  • Additional tracked hours: $1/hour (beyond 500 hours)
  • Additional storage: $0.03/GB (beyond 100GB)
  • Estimated annual cost for a 10-person team: ~$6,000 + overage usage
  • Academic institutions: free Pro license available

New Features in 2025

  • W&B Weave: LLM application tracing and evaluation
  • W&B Inference (CoreWeave): open-source LLM APIs such as GPT OSS, Llama 4, and Qwen3
  • Limited inference credits provided to Free/Pro users

πŸ—£οΈ Say It Like This in Practice

πŸ’¬ In a Meeting

"I think tracking experiments with W&B would be a good idea. Right now we record training results by hand in Notion, but with just one line, wandb.init(), metrics, hyperparameters, and even code versions are recorded automatically. It also makes reproduction easier later."

πŸ’¬ In an Interview

"How do you manage experiments?" - "We mainly use W&B. We automate hyperparameter tuning with Sweeps and manage model versions with Artifacts. Team members can check training progress in real time on the dashboard, so collaboration is easy."

πŸ’¬ In a Technical Discussion

"If you trace an LLM pipeline with W&B Weave, it shows everything, including prompt versions, token usage, and latency. It's similar to LangSmith, but if you're already a W&B user, the integration is more convenient."

Take a mock interview on this topic β†’ WIA SOOM AI Interview Β· Start for free

⚠️ Common Mistakes & Cautions

❌
Running a company project on the Free plan

The Free plan is for personal projects only, and corporate use is prohibited. To use it at a company, you need the Pro plan or higher. For academic research, you can apply for a free Pro license.

❌
Logging sensitive data

If you include customer data or API keys in wandb.log(), they are uploaded to the cloud. Filter sensitive information, or consider self-hosting with the Enterprise plan. Do not put API keys in config.

βœ…
Using offline mode

When training without internet, setting WANDB_MODE=offline saves data locally. You can upload it later with the wandb sync command. It is useful on GPU servers.

πŸ”— Related Terms

πŸ“š Learn More