Skip to main content
A Model is a combination of data (which can include configuration, trained model weights, or other information) and code that defines how the model operates. By structuring your code to be compatible with this API, you benefit from a structured way to version your application so you can more systematically keep track of your experiments.
To create a model in Weave, you need the following:
  • a class that inherits from weave.Model
  • type definitions on all parameters
  • a typed predict function with @weave.op() decorator
You can call the model as usual with:
This will track the model settings along with the inputs and outputs anytime you call predict.

Automatic versioning of models

When you change the parameters or the code that defines your model, these changes will be logged and the version will be updated. This ensures that you can compare the predictions across different versions of your model. Use this to iterate on prompts or to try the latest LLM and compare predictions across different settings.For example, here we create a new model:
After calling this, you will see that you now have two versions of this Model in the UI, each with different tracked calls.

Serve models

To serve a model, you can easily spin up a FastAPI server by calling:
For additional instructions, see serve.

Track production calls

To separate production calls, you can add an additional attribute to the predictions for easy filtering in the UI or API.