Principle:Wandb Weave Model Definition
| Knowledge Sources | |
|---|---|
| Domains | Model_Architecture, Evaluation |
| Last Updated | 2026-02-14 00:00 GMT |
Overview
A model abstraction pattern that encapsulates inference logic and configuration as a versioned, evaluable unit.
Description
Model Definition provides a standard interface for wrapping inference logic (LLM calls, ML models, rule-based systems) into a structured object whose configuration is automatically version-tracked. By defining model attributes as class fields and the inference logic as a traced method, changes to either the code or configuration are captured as new versions.
Usage
Use this principle when building an evaluable model. The model must expose a standard inference method (predict, infer, forward, or invoke) so the evaluation framework can automatically dispatch dataset examples to it.
Theoretical Basis
The Model pattern combines:
- Configuration as State: Model parameters (prompt templates, temperature, model name) are stored as Pydantic fields, enabling automatic serialization and versioning.
- Inference as Method: A single entry point method processes inputs and returns predictions.
- Method Discovery: The framework searches for methods named predict, infer, forward, or invoke (in that order).
- Automatic Tracing: The inference method must be decorated with @weave.op to enable call tracking during evaluation.