Class Model
java.lang.Object
smile.onnx.genai.Model
- All Implemented Interfaces:
AutoCloseable
An ONNX Runtime GenAI model. Outlives tokenizers and generators created from it.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Creates generator parameters for this model.Creates a tokenizer bound to this model.name()Returns the model directory leaf name (or a placeholder when loaded from Config).static ModelLoads a model from a GenAI model directory using providers fromgenai_config.json.static ModelLoads a model from a GenAI model directory using providers fromgenai_config.json.static ModelLoads a model from an existingConfig.static ModelOpens a model with an accelerator cascade, then CPU.static ModelOpens a model with an accelerator cascade, then CPU.provider()Returns which execution-provider path was selected for this instance.
-
Method Details
-
of
-
of
-
open
Opens a model with an accelerator cascade, then CPU.Default
SMILE_ONNX_GENAI_PROVIDER=autoorder: CUDA → RyzenAI → OpenVINO NPU → QNN → DirectML (Windows) → CPU (of(String)). Each accelerator is attempted only when matching EP natives are present; Java failures fall through to the next candidate.Classical Vitis AI for general ONNX is
SessionOptions.appendVitisAiExecutionProvider(), not part of this GenAI cascade.- Parameters:
modelDir- GenAI model directory.- Returns:
- a new model owned by the caller.
-
open
-
of
-
createTokenizer
Creates a tokenizer bound to this model.- Returns:
- a new tokenizer owned by the caller.
-
createGeneratorParams
Creates generator parameters for this model.- Returns:
- a new params object owned by the caller.
-
name
Returns the model directory leaf name (or a placeholder when loaded from Config).- Returns:
- display name.
-
provider
Returns which execution-provider path was selected for this instance.- Returns:
cuda,ryzenai,openvino,qnn,dml,default, orconfig.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-