W&B
~2 min read
Concept & How It Works
Why Does It Exist?
Teams already using W&B for ML model training can extend the same workflow to agent prompt iteration, A/B tests, and eval leaderboards.
Real-World Analogy
W&B for agents is a lab notebook that automatically records every experiment and charts which prompt version wins.
Visual Workflows
What is W&B?
Example
Scenario
Log 3 prompt variants on 100 eval questions; Weave leaderboard shows variant B has highest correctness at lowest token cost.
Solution
In Agent Evaluation & Observability, apply W&B to this scenario: Log 3 prompt variants on 100 eval questions; Weave leaderboard shows variant B has highest correctness at lowest token cost. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.
Practice Task
Do this before moving to the next module — reading alone is not enough.
Open the Code Walkthrough below and run it locally. Change one parameter related to W&B (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.
Code Walkthrough
Highlighted lines show where W&B happens in the code.
1import weave # import dependencies2weave.init("support-agent")3
4@weave.op5def answer_question(question: str) -> str: # define a reusable function6 return agent.invoke(question) # return the result7
8evaluation = weave.Evaluation(dataset=eval_ds, scorers=[correctness_scorer])9await evaluation.evaluate(answer_question)Commands to Remember
Commands to Remember
pip install langsmith # trace and evaluate LLM runspip install arize-phoenix # open-source LLM observabilitypip install opentelemetry-api opentelemetry-sdk # distributed tracing
Common Mistakes
- Treating W&B as a black box without evaluation
- Ignoring cost and latency in production
- Skipping error handling for wandb
Cheat Sheet
Quick recap — the most important points from this module.
Cheat Sheet
quick ref- •W&B
- •Weave
- •Scorers
- •Leaderboard