W&B Advanced Best Practices
Enterprise patterns, team collaboration workflows, CI/CD integration, and production ML pipelines with Weights & Biases.
Team Collaboration Patterns
| Pattern | Implementation |
|---|---|
| Project naming | Use consistent naming: team/task-version (e.g., nlp/sentiment-v2) |
| Run naming | Descriptive names: resnet50-augmented-lr0.001-bs64 |
| Tags | Use tags for lifecycle: ["experiment", "baseline", "production"] |
| Groups | Group related runs: cross-validation folds, ablation studies |
| Weekly reports | Create template Reports that auto-update with latest runs |
CI/CD Integration
name: ML Pipeline
on:
push:
branches: [main]
paths: ['models/**', 'data/**']
jobs:
train-and-evaluate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: pip install -r requirements.txt
- name: Train model
env:
WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }}
run: python train.py --config configs/prod.yaml
- name: Evaluate and promote
env:
WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }}
run: |
python evaluate.py --model latest
python promote.py --alias staging
Model Registry Workflow
import wandb
# After training: log model as artifact
run = wandb.init(project="production-models")
artifact = wandb.Artifact("sentiment-model", type="model")
artifact.add_dir("./model_weights")
run.log_artifact(artifact)
# Link to Model Registry
run.link_artifact(artifact, "my-team/model-registry/sentiment-model")
run.finish()
# Promote to staging
api = wandb.Api()
artifact = api.artifact("my-team/model-registry/sentiment-model:latest")
artifact.aliases.append("staging")
artifact.save()
# After validation: promote to production
artifact.aliases.append("production")
artifact.save()
Production Monitoring
import wandb
# Log inference metrics
run = wandb.init(project="production-monitoring",
name="inference-monitor",
tags=["production", "monitoring"])
# Log predictions and latency
for batch in inference_stream:
predictions = model.predict(batch)
wandb.log({
"inference_latency_ms": latency,
"prediction_distribution": wandb.Histogram(predictions),
"confidence_mean": predictions.mean(),
"low_confidence_count": (predictions < 0.5).sum(),
"requests_per_second": rps,
})
Common Pitfalls
- Too many projects: Consolidate related experiments into one project. Use tags and groups to organize, not separate projects.
- Inconsistent configs: Use the same config key names across all runs. Standardize with a config schema.
- Not using Model Registry: Track model lifecycle with aliases (staging, production) instead of manual file management.
- Ignoring Reports: Reports are how you communicate results. Make weekly reporting a team habit.
- API key in code: Always use
WANDB_API_KEYenvironment variable orwandb login. Never hardcode keys.
Frequently Asked Questions
W&B provides an MLflow import tool. Use wandb sync mlruns/ to import existing MLflow runs. For ongoing migration, you can log to both platforms simultaneously during the transition period.
W&B Enterprise supports on-premises deployment, SOC 2 Type II compliance, SSO/SAML, and audit logging. For sensitive data, use W&B Server (self-hosted) to keep all data within your infrastructure.
Use W&B Artifacts with reference-type artifacts that point to data in S3/GCS instead of uploading to W&B servers. This tracks lineage without duplicating large datasets. Set type="dataset" and use artifact.add_reference().
Ready to Go Deeper?
Live instructor-led courses from our partners. Affiliate disclosure.
AI & ML Courses - 30% Off
Live instructor-led AI, machine learning, data science, and cloud courses for working professionals. Use code Limited30 at checkout.
EdurekaDataCamp - AI & Data Science
Hands-on Python, machine learning, and AI courses with interactive exercises and real projects.
DataCampedX - Top AI Courses
University-level AI courses from MIT, Harvard, Stanford. Earn certificates that employers recognize.
edX