Skip to main content

BuildModelUnit

Unit
DashAI.back.units.BuildModelUnit

Instantiate an untrained model bound to its data and metrics.

ModelFactory attaches the run id and the metric classes to the model instance, which is what later lets the model log metrics on its own during and after training. The metrics are configured here rather than in the evaluation unit because models use them while training to log at the step and epoch levels.

The data is not attached here. It used to be, and that only worked because a model was fitted once on one split. A model fitted over folds sees different data on every iteration, so binding one partition at construction would leave the metrics describing whichever fold happened to be built with. Whoever fits the model points it at the data it is being fitted on, and this unit no longer needs x or y at all -- only the label count, which is a property of the dataset rather than of a split.

validate checks that the model and every component nested in its parameters have been downloaded, so an impossible run is rejected before anything observable happens.

The model is configured as a component field, the same way a model picks its own sub-components: the value is {"component": <name>, "params": {...}}. The parameter tree stays an opaque dict in the schema and the front resolves it recursively, fetching the chosen component's schema to render the nested form. ModelFactory walks the same shape to build the object graph.

Parameters​

model : object
Model to instantiate, along with its own configuration.
train_metrics : array, default=[]
Metrics evaluated on the train split.
validation_metrics : array, default=[]
Metrics evaluated on the validation split.
test_metrics : array, default=[]
Metrics evaluated on the test split.

Methods​

execute(self, ctx: DashAI.back.units.context.ExecutionContext) -> None

Defined on BuildModelUnit

Do the unit's work, reading from and writing to the context.

Parameters

ctx : ExecutionContext
The shared execution context.

validate(self, ctx: DashAI.back.units.context.ExecutionContext) -> None

Defined on BuildModelUnit

Check preconditions without executing the unit.

Parameters

ctx : ExecutionContext
The shared execution context.

get_credential(self, name: str)

Defined on ConfigObject

Resolve a registered credential component by name.

Parameters

name : str
Credential component class name (e.g. "HuggingFaceCredential").

Returns

BaseCredential
An instance of the requested credential component.

get_schema(cls) -> dict

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

validate_and_transform(self, raw_data: dict) -> dict

Defined on ConfigObject

It takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.

Parameters

raw_data : dict
A dictionary with the data provided by the user to initialize the model.

Returns

dict
A validated dictionary with the necessary objects.