Interface ModelHandler

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
DjlModelHandler

public interface ModelHandler extends AutoCloseable
Interface responsible for low-level interaction with machine learning models. This handles model initialization, prediction execution, and resource management.
  • Method Details

    • initialize

      CompletableFuture<Void> initialize(org.gridgain.ml.model.ModelInfo modelInfo, ModelSource modelSource)
      Initializes the model handler with a model source asynchronously.
      Parameters:
      modelInfo - Information about the model to initialize
      modelSource - The source from which to load the model
      Returns:
      A CompletableFuture that completes when initialization is done
    • predict

      <I, O> CompletableFuture<O> predict(I input)
      Executes a prediction using the model asynchronously.
      Type Parameters:
      I - The input type
      O - The output type
      Parameters:
      input - The input data for prediction
      Returns:
      A CompletableFuture containing the prediction result
    • batchPredict

      <I, O> CompletableFuture<List<O>> batchPredict(List<I> inputs)
      Executes a batch prediction using the model asynchronously.
      Type Parameters:
      I - The input type
      O - The output type
      Parameters:
      inputs - A list of input data items for batch prediction
      Returns:
      A CompletableFuture containing a list of prediction results
    • close

      void close()
      Releases resources associated with the model.
      Specified by:
      close in interface AutoCloseable
    • checkAndMarkInitialized

      boolean checkAndMarkInitialized()
      Atomically checks whether the model handler was already initialized. If this is the first call, it marks the handler as initialized and returns false. Subsequent calls return true, indicating that initialization had already occurred.
      Returns:
      true if the handler was already initialized before this call, false if this call performed the initial marking.
    • getModelInfo

      org.gridgain.ml.model.ModelInfo getModelInfo()
      Gets information about the model being handled.
      Returns:
      Information about the model
    • getEngineProperties

      Map<String,String> getEngineProperties()
      Gets engine-specific properties.
      Returns:
      Map of engine properties
    • getModelMetadata

      Map<String,Object> getModelMetadata()
      Gets metadata about the model.
      Returns:
      Map of model metadata