getCurrentState

abstract suspend fun getCurrentState(): KarlContainerState(source)

Serializes the current state of the learning model for persistent storage.

This method captures the complete state of the learning engine including model weights, hyperparameters, training history, and configuration settings. The serialized state enables seamless continuation of learning across application sessions and provides the foundation for backup, recovery, and migration scenarios.

State components captured:

  • Model weights and biases: All trainable parameters of the neural network or ML model

  • Hyperparameters: Learning rates, regularization settings, architectural parameters

  • Training metadata: Learning progress, iteration counts, convergence metrics

  • Configuration settings: Model architecture definitions, feature engineering parameters

  • Historical statistics: Performance metrics, validation scores, adaptation indicators

Serialization requirements:

  • Completeness: All information needed to restore identical model behavior

  • Versioning: Include format version for backward compatibility and migration

  • Compression: Efficient encoding to minimize storage space and transfer time

  • Integrity: Checksums or validation data to detect corruption

  • Privacy: Ensure no sensitive user data is inadvertently included

Return

A KarlContainerState object containing the serialized model state, metadata, and version information required for restoration in future sessions.

See also

for state restoration process

for state format documentation

Throws

IllegalStateException

if engine is not properly initialized

SerializationException

if model state cannot be properly serialized