Skip to main content
This is an interactive notebook. You can run it locally or use the following links:
This notebook introduces W&B Weave evaluations by walking you through a minimal end-to-end example. You define a Weave Model, run it against a small dataset, score the outputs with a custom scoring function, and review the results in Weave. It’s intended for developers who are new to Weave and want a quick, hands-on starting point before exploring more advanced evaluation workflows.

Prerequisites

Before you can run a Weave evaluation, complete the following prerequisites.
  1. Install the W&B Weave SDK and log in with your API key.
  2. Install the OpenAI SDK and log in with your API key.
  3. Initialize your W&B project.

Run your first evaluation

With your environment set up, you’re ready to define and run an evaluation. The following code sample shows how to evaluate an LLM using Weave’s Model and Evaluation APIs. First, define a Weave model by subclassing weave.Model, specifying the model name and prompt format, and tracking a predict method with @weave.op. The predict method sends a prompt to OpenAI and parses the response into a structured output using a Pydantic schema (FruitExtract). Then, create a small evaluation dataset that consists of input sentences and expected targets. Next, define a custom scoring function (also tracked using @weave.op) that compares the model’s output to the target label. Finally, wrap everything in a weave.Evaluation, specifying your dataset and scorers, and call evaluate() to run the evaluation pipeline asynchronously.
After the evaluation finishes, Weave logs the model, dataset, and per-example scores to your project so you can inspect the results in the Weave UI.

Looking for more examples

Now that you’ve run a basic evaluation, you can explore more advanced workflows in the following tutorials: