IModelSerializer

Interfaces · AiDotNet.Interfaces

Defines methods for converting machine learning models to and from binary data for storage or transmission.

Known implementations: ContentClassifierBase<T>, IAdversarialAttack<T, TInput, TOutput>, IAdversarialDefense<T, TInput, TOutput>, IAlignmentMethod<T>, ICertifiedDefense<T, TInput, TOutput>, IFineTuning<T, TInput, TOutput>, IFullModel<T, TInput, TOutput>, IOptimizer<T, TInput, TOutput>, IPredictiveModel<T, TInput, TOutput>, ISafetyFilter<T>, TabularDataTransformer<T>

How It Works

This interface provides functionality to save trained models to binary format and load them back. Serialization allows models to be stored to disk, transmitted over networks, or embedded in applications.

For Beginners: Think of serialization like taking a snapshot of your model.

Imagine you’ve spent hours training a machine learning model:

  • Serialization is like taking a photo of your model’s current state
  • This “photo” (binary data) can be saved to your computer
  • Later, you can use this “photo” to recreate the exact same model
  • You don’t need to train the model again - it’s ready to use immediately

Real-world examples:

  • Saving a trained model to use it in a mobile app
  • Sharing your trained model with colleagues
  • Backing up your model before experimenting with changes
  • Deploying your model to a production environment

Without serialization, you would need to retrain your model from scratch every time you restart your application, which could take hours or days depending on the complexity of your model and data.

Methods

Method Summary
byte[] Serialize() Converts the current state of a machine learning model into a binary format.
void Deserialize(byte[] data) Loads a previously serialized model from binary data.
void LoadModel(string filePath) Loads the model from a file.
void SaveModel(string filePath) Saves the model to a file.