Package org.gridgain.internal.ml.handler
Interface ModelHandler
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
DjlModelHandler
Interface responsible for low-level interaction with machine learning models.
This handles model initialization, prediction execution, and resource management.
-
Method Summary
Modifier and TypeMethodDescription<I,O> CompletableFuture<List<O>> batchPredict(List<I> inputs) Executes a batch prediction using the model asynchronously.booleanAtomically checks whether the model handler was already initialized.voidclose()Releases resources associated with the model.Gets engine-specific properties.org.gridgain.ml.model.ModelInfoGets information about the model being handled.Gets metadata about the model.initialize(org.gridgain.ml.model.ModelInfo modelInfo, ModelSource modelSource) Initializes the model handler with a model source asynchronously.<I,O> CompletableFuture<O> predict(I input) Executes a prediction using the model asynchronously.
-
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 initializemodelSource- The source from which to load the model- Returns:
- A CompletableFuture that completes when initialization is done
-
predict
Executes a prediction using the model asynchronously.- Type Parameters:
I- The input typeO- The output type- Parameters:
input- The input data for prediction- Returns:
- A CompletableFuture containing the prediction result
-
batchPredict
Executes a batch prediction using the model asynchronously.- Type Parameters:
I- The input typeO- 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:
closein interfaceAutoCloseable
-
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 returnsfalse. Subsequent calls returntrue, indicating that initialization had already occurred.- Returns:
trueif the handler was already initialized before this call,falseif 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
Gets engine-specific properties.- Returns:
- Map of engine properties
-
getModelMetadata
Gets metadata about the model.- Returns:
- Map of model metadata
-