Skip to main content
These examples show how to use W&B Inference with Weave for tracing, evaluation, and comparison.

Basic example: Trace Llama 3.1 8B with Weave

This example shows how to send a prompt to the Llama 3.1 8B model and trace the call with Weave. Tracing captures the full input and output of the LLM call, monitors performance, and lets you analyze results in the Weave UI.
Learn more about tracing in Weave.
In this example:
  • You define a @weave.op()-decorated function that makes a chat completion request
  • Your traces are recorded and linked to your W&B entity and project
  • The function is automatically traced, logging inputs, outputs, latency, and metadata
  • The result prints in the terminal, and the trace appears in your Traces tab at https://wandb.ai
Before running this example, complete the prerequisites.
After running the code, view the trace in Weave by:
  1. Clicking the link printed in the terminal (for example: https://wandb.ai/<your-team>/<your-project>/r/call/01977f8f-839d-7dda-b0c2-27292ef0e04g)
  2. Or navigating to https://wandb.ai and selecting the Traces tab

Advanced example: Use Weave Evaluations and Leaderboards

Besides tracing model calls, you can also evaluate performance and publish leaderboards. This example compares two models on a question-answer dataset. Before running this example, complete the prerequisites.
After running this code, go to your W&B account at https://wandb.ai/ and:
View your model evaluations
View your leaderboard

Next steps