Save and Load Models
Persist trained Plexe models to disk and load them back for later use.
Once you have successfully built a plexe.Model
(model.state == ModelState.READY
), you can save its state, including the trained predictor, source code, artifacts, and metadata, to a file. You can then load this file later to reuse the model without rebuilding it.
Plexe saves models as .tar.gz
archives.
Saving a Model
Use the plexe.save_model()
function.
The save_model
function requires the full path including the .tar.gz
extension. It will create the necessary parent directories if they don’t exist.
The saved archive contains:
- Metadata (intent, state, metrics, identifier)
- Schemas (input, output)
- Code (trainer source, predictor source)
- Artifacts (serialized model files, e.g.,
.joblib
,.pkl
,.pt
) - Constraints (if any were defined)
Loading a Model
Use the plexe.load_model()
function, providing the path to the .tar.gz
archive.
Loading a model reconstructs the plexe.Model
instance, including its state, predictor, and associated data, allowing you to immediately use it for inference or further inspection.