Skip to main content
These examples show how to use Serverless Inference with Weave for tracing, evaluation, and comparison. Work through them to learn how to instrument model calls so you can observe their behavior, measure performance against a dataset, and compare models side by side. The following sections walk through a basic tracing example and a more advanced evaluation workflow. Before running either example, complete the prerequisites.

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.
  • Weave records your traces and links them to your W&B entity and project.
  • Weave automatically traces the function, logging inputs, outputs, latency, and metadata.
  • The result prints in the terminal, and the trace appears in your Traces tab at https://wandb.ai.
After running the code, view the trace in Weave using one of the following methods:
  • Click the link printed in the terminal. For example, https://wandb.ai/[YOUR-TEAM]/[YOUR-PROJECT]/r/call/01977f8f-839d-7dda-b0c2-27292ef0e04g.
  • Navigate to https://wandb.ai and select the Traces tab.
With the basic trace working, you can move on to a richer workflow that goes beyond inspecting individual calls.

Advanced example: use Weave evaluations and leaderboards

Besides tracing model calls, you can evaluate performance and publish leaderboards. This example compares two models on a question-answer dataset to show how Llama 3.1 8B and DeepSeek-V3 perform against the same prompts.
After running this code, navigate to your W&B account at https://wandb.ai/ and do the following:
View your model evaluations
View your leaderboard
After completing both examples, you have a set of traced model calls, a published evaluation, and a leaderboard comparing models on your dataset.

Next steps

To continue exploring Serverless Inference, try the following:
  • Explore the API reference for all available methods.
  • Try models in the UI.