SMILE CLI

Train, predict, serve, and script from the terminal

SMILE ships with a unified command-line launcher (smile on macOS/Linux, smile.bat on Windows) that exposes interactive REPLs, no-code model training, batch inference with SHAP explanations, online HTTP serving, and the autonomous Agent Hub runtime. Depending on the first argument you pass (or the absence of one), the launcher routes to:

InvocationDescription
smile (no args)Open the Agent Studio desktop IDE
smile shellStart the Java (JShell) interactive REPL
smile scalaStart the Scala 3 interactive REPL
smile train …Train a machine learning model (classification, regression, clustering, vector quantization, or anomaly detection)
smile predict …Predict on a file using a saved model (with optional posterior probabilities and SHAP explanations)
smile serve …Serve a saved model, ONNX graph, or LLM as an HTTP inference service (SMILE Serve)
smile hub …Start the always-on Agent Hub & Bot service

Installation & Setup

Prerequisites

First-Time Setup

Run the provided setup script once after unzipping the distribution. It installs optional native libraries (libarpack, libopenblas) via the system package manager and creates a Python virtual environment with the packages listed in conf/requirements.txt:

Bash

# macOS / Linux
path/to/smile/bin/setup

# Windows
path\to\smile\bin\setup.bat
    

Running the Launcher

Bash

# macOS / Linux
path/to/smile/bin/smile [command] [options]

# Windows
path\to\smile\bin\smile.bat [command] [options]
    

The launcher reads JVM options from conf/smile.ini before forwarding the remaining arguments to smile.Main. The system property smile.home points to the distribution root and is used by all launchers to locate resources such as bin/predef.jsh, bin/predef.sc, and serve/quarkus-run.jar. See JVM Tuning for how to add custom properties.

Java Shell (smile shell)

Bash

smile shell [jshell-options…]
    

Starts an interactive JShell session pre-configured for SMILE development:

  1. The full SMILE classpath is added with --class-path.
  2. JVM flags are injected into the remote JVM started by JShell: -XX:MaxMetaspaceSize=1024M, -Xss4M, -XX:MaxRAMPercentage=75, -XX:+UseZGC, --add-opens java.base/java.nio=ALL-UNNAMED, and --enable-native-access.
  3. DEFAULT and PRINTING JShell startup scripts are loaded (making println() available without a class qualifier).
  4. bin/predef.jsh is loaded, defining the compact color smile feedback mode, pre-importing every major SMILE package, and printing the SMILE banner.
  5. Command history is persisted across sessions via java.util.prefs.Preferences.

Pre-Imported Packages

The following packages (along with static methods from java.lang.Math and smile.math.MathEx) are imported automatically by predef.jsh:

Java

smile.util.*          smile.graph.*          smile.math.*
smile.stat.*          smile.data.*           smile.data.formula.*
smile.data.measure.*  smile.data.type.*      smile.data.vector.*
smile.io.*            smile.plot.swing.*     smile.interpolation.*
smile.validation.*    smile.classification.* smile.regression.*
smile.feature.*       smile.clustering.*     smile.hpo.*
smile.vq.*            smile.manifold.*       smile.sequence.*
smile.nlp.*           smile.wavelet.*        smile.tensor.*
smile.anomaly.*       smile.association.*
    

Any arguments after shell are forwarded directly to JShell. You can execute a script file non-interactively or save/restore interactive sessions:

Bash

# Execute a JShell script non-interactively
smile shell examples/toy.jsh

# Inside an interactive session: save and reload snippets
smile> /save session.jsh
smile> /open session.jsh
    

Scala REPL (smile scala)

Bash

smile scala [scalac-options…]
    

Starts a Scala 3 REPL pre-configured with -usejavacp and bin/predef.sc, which imports the top-level smile._ DSL, smile.io._, formula operators (e.g. "class" ~ "."), and high-level training helpers:

Scala

import smile._              // top-level Smile DSL
import smile.io._           // Read/Write helpers
import smile.data.formula._ // formula DSL
import smile.classification._
import smile.regression.{lm, ridge, lasso, gpr}
import smile.feature.*
import smile.clustering.*
    

Training Models (smile train)

Bash

smile train -d <file> -m <model> [global-options] <algorithm> [algo-options]
    

smile train trains a machine learning model (classification, regression, clustering, vector quantization, or anomaly detection) from a data file and serializes it to disk (.sml). It uses a two-level command structure: global options come first, followed by the algorithm sub-command and its options.

Global Options

OptionShortRequiredDefaultDescription
--data <file>-dYes—Training data file path
--model <file>-mYes—Output model file path (.sml)
--test <file>—Optional hold-out test file
--format <fmt>auto-detectData format specification (see Supported File Formats)
--formula <expr>auto-detectModel formula, e.g. class ~ .
--model-id <id>—Metadata tag: model identifier
--model-version <ver>—Metadata tag: model version string
--kfold <k>-k1Enable k-fold cross-validation
--round <n>-r1Repeated cross-validation rounds
--ensemble-efalseBuild ensemble from cross-validation fold models
--seed <n>-s0 (off)RNG seed for reproducibility
--help-hPrint help and exit
--version-VPrint SMILE version and exit

Formula Auto-Detection

If --formula is omitted:

Classification Algorithms

All classification sub-commands default to classification mode. Algorithms that also support regression expose --regression to switch modes.

Sub-commandAlgorithmModesKey Options
random-forestRandom ForestClassification, Regression (--regression)--trees <n> (default 500), --mtry <n>, --split <GINI|ENTROPY|CLASSIFICATION_ERROR>, --max-depth <n>, --max-nodes <n>, --node-size <n>, --sampling <rate>, --class-weight <w>
gradient-boostGradient Boosted TreesClassification, Regression (--regression)--trees <n>, --shrinkage <rate>, --max-depth <n>, --max-nodes <n>, --node-size <n>, --sampling <rate>
ada-boostAdaBoostClassification--trees <n>, --max-depth <n>, --max-nodes <n>, --node-size <n>
cartDecision Tree (CART)Classification, Regression (--regression)--split <rule>, --max-depth <n>, --max-nodes <n>, --node-size <n>
logisticLogistic RegressionClassification--lambda <λ>, --iterations <n>, --tolerance <ε>, --transform <rule>
fisherFisher’s Linear DiscriminantClassification--dimension <d>, --tolerance <ε>, --transform <rule>
ldaLinear Discriminant AnalysisClassification--priori <p0,p1,…>, --tolerance <ε>, --transform <rule>
qdaQuadratic Discriminant AnalysisClassification--priori <p0,p1,…>, --tolerance <ε>, --transform <rule>
rdaRegularized Discriminant AnalysisClassification--alpha <α> (required, in [0, 1]), --priori <p0,p1,…>, --tolerance <ε>, --transform <rule>
mlpMultilayer PerceptronClassification, Regression (--regression)--layers <spec> (required, e.g. ReLU(100)|Sigmoid(30)), --epochs <n>, --mini-batch <n>, --learning-rate <sched>, --momentum <sched>, --weight-decay <λ>, --clip_norm <n>, --rho <ρ>, --epsilon <ε>, --transform <rule>
svmSupport Vector MachineClassification, Regression (--regression)--kernel <fn> (required: Gaussian(σ), Linear, Polynomial(d,s,o), Laplacian(σ), PearsonVII(ω,ν), Hellinger, Tanh(s,o)), -C <val>, --epsilon <ε>, --ovr, --ovo, --tolerance <ε>, --transform <rule>
rbfRadial Basis Function NetworkClassification, Regression (--regression)--neurons <n> (required), --normalize, --transform <rule>

Regression-Only Algorithms

In addition to passing --regression to random-forest, gradient-boost, cart, mlp, svm, or rbf, the following sub-commands are dedicated to regression:

Sub-commandAlgorithmKey Options
olsOrdinary Least Squares--method <qr|svd> (default qr), --stderr, --recursive
lassoLASSO Regression--lambda <λ> (required, L1 penalty), --iterations <n>, --tolerance <ε>
ridgeRidge Regression--lambda <λ> (required, L2 penalty)
elastic-netElastic Net--lambda1 <λ1> (required, L1), --lambda2 <λ2> (required, L2), --iterations <n>, --tolerance <ε>
gaussian-processGaussian Process Regression--kernel <fn> (required), --noise <σ²> (required), --normalize, --iterations <n>, --tolerance <ε>, --transform <rule>

Clustering, Vector Quantization & Anomaly Detection

Unsupervised sub-commands serialize a ClusteringModel, VectorQuantizerModel, or AnomalyModel:

CategorySub-commandAlgorithmKey Options
ClusteringkmeansK-Means-k, --clusters <k> (required), --iterations <n>, --tolerance <ε>, --runs <n>, --transform <rule>
ClusteringxmeansX-Means-k, --clusters <kmax> (required), --iterations <n>, --tolerance <ε>, --transform <rule>
ClusteringgmeansG-Means-k, --clusters <kmax> (required), --iterations <n>, --tolerance <ε>, --transform <rule>
Clusteringdeterministic-annealing (da)Deterministic Annealing-k, --clusters <kmax> (required), --alpha <α>, --iterations <n>, --tolerance <ε>, --split-tolerance <ε>, --transform <rule>
Vector QuantizationsomSelf-Organizing Map--nrow <rows> (default 10), --ncol <cols> (default 10), --epochs <n>, --alpha <sched>, --neighborhood <fn>, --transform <rule>
Vector Quantizationneural-gasNeural Gas-k, --neurons <k> (default 10), --epochs <n>, --alpha <sched>, --theta <sched>, --lifetime <sched>, --transform <rule>
Vector Quantizationgrowing-neural-gas (gng)Growing Neural Gas--epochs <n>, --eps-best <ε>, --eps-neighbor <ε>, --edge-lifetime <n>, --lambda <n>, --alpha <α>, --beta <β>, --transform <rule>
Vector Quantizationneural-mapNeuralMap--radius <r> (required), --epochs <n>, --eps-best <ε>, --eps-neighbor <ε>, --edge-lifetime <n>, --beta <β>, --transform <rule>
Vector QuantizationbirchBIRCH--radius <T> (required), --branching <B>, --leaves <L>, --transform <rule>
Anomaly Detectionisolation-forest (iforest)Isolation Forest--trees <n> (default 100), --max-depth <n>, --sampling <rate>, --extension-level <n>, --threshold <score> (default 0.5), --transform <rule>
Anomaly DetectionlofLocal Outlier Factor-k, --neighbors <k> (default 20), --threshold <score> (default 1.5), --transform <rule>
Anomaly Detectionocsvm (one-class-svm)One-Class SVM--kernel <fn> (required), --nu <ν> (default 0.5), --tolerance <ε>, --threshold <score> (default 0.0), --transform <rule>

Feature Transformation & Cross-Validation

Algorithms that sensitive to feature scale accept --transform <rule> to fit a smile.feature.transform pipeline alongside the model:

--transform ValueClassDescription
standardizerStandardizerZero mean, unit variance
robustRobustStandardizerMedian and IQR scaling (robust to outliers)
winsor(lo,hi)WinsorScalerWinsorize at percentiles, e.g. winsor(0.01,0.99)
minmaxScalerScale features to [0, 1]
MaxAbsMaxAbsScalerScale by maximum absolute value
L1, L2, LinfNormalizerL1, L2, or L∞ unit norm per sample

Pass -k <folds> (and optionally -r <rounds>) to evaluate with stratified cross-validation. By default, the saved model is retrained on the full training dataset; pass --ensemble (-e) to save the ensemble of fold models instead:

Bash

# 5-fold cross-validation, 3 repetitions, tagged with model ID and version
smile train -d data/weka/iris.arff -m iris_rf.sml \
  --model-id "iris-classifier-v1" --model-version "2.0.0" \
  -k 5 -r 3 --ensemble random-forest --trees 200
    

Batch Prediction (smile predict)

Bash

smile predict <data-file> --model <model-file> [options]
    

Loads a saved .sml model, scores every row in <data-file>, and writes one prediction per line to stdout.

OptionShortRequiredDescription
<data-file>YesInput data file (positional argument)
--model <file>-mYesSaved model file (.sml)
--format <fmt>Data file format (see Supported File Formats)
--probability-pAppend posterior probabilities for soft classifiers
--explain-eCompute local SHAP feature explanations (automatically enables --json)
--jsonOutput predictions as JSON lines matching the SMILE Serve response format

Output Formats & SHAP Explanations

In plain-text mode, smile predict prints the predicted label (plus space-separated probabilities with -p), regression value, cluster ID + centroid, SOM grid cell + centroid + quantization error, or boolean anomaly flag + score. With --json or --explain, it emits one JSON object per line:

Bash

# Batch predict with posterior probabilities and local SHAP explanations
smile predict test.arff --model iris_rf.sml --probability --explain

# Example JSON Lines output across model types:
{"prediction":0,"probabilities":[0.982,0.018,0.000],"explanations":{"shap":[[0.142,-0.051,0.812,0.003],[...],[...]]}}
{"prediction":1,"centroid":[5.9016,2.7484,4.3935,1.4339]}
{"prediction":[0,2],"centroid":[5.0121,3.4210,1.4612,0.2415],"error":0.1423}
{"prediction":false,"score":0.3842}
    

All built-in classification and regression models support SHAP explanations (tree ensembles via exact TreeSHAP, linear models via exact linear attribution, and other models via KernelSHAP).

Online Serving (smile serve)

Bash

smile serve [model-options] [server-options] [llm-options]
    

Launches the Quarkus-based SMILE Serve HTTP inference server, combining three inference capabilities and a bundled React Web UI (/infer and /chat) in a single process:

OptionDefaultDescription
-m, --model <path>—Model file or folder (loads .sml, .onnx if present, or HF repo ID)
--sml-model <path>—Path to SMILE model file or folder (smile.serve.model)
--onnx-model <path>—Path to ONNX model file or folder (smile.onnx.model)
--chat-model, --llm <model>—Local checkpoint folder or Hugging Face repo ID (smile.chat.model)
--host <addr>localhostNetwork interface to bind (quarkus.http.host)
-p, --port <n>8888HTTP listen port (quarkus.http.port)
--devices <list>0CUDA device index or comma-separated tensor-parallel list (e.g. 0,1)
--tp-size <n>1Tensor-parallel world size
--max-batch-size <n>16Maximum in-flight requests for continuous batching
--max-seq-len <n>0 (auto)Maximum context length in tokens
--attention <backend>flashinferAttention kernel backend (flashinfer or torch_native)
--quantization <mode>autoWeight GEMM quantization (auto, dense, fp8, nvfp4, marlin)
--speculative / --no-speculativetrueEnable or disable native MTP speculative decoding
--kv-dtype <type>autoKV-cache dtype (auto, bfloat16, float16, float32, fp8_e4m3, fp8_e5m2)
--prefix-reuse / --no-prefix-reusetrueEnable or disable radix KV prefix cache reuse
--oga-provider <ep>autoONNX GenAI execution provider (auto, cuda, dml, cpu, npu, ryzenai, openvino, qnn)
-D<key>=<value>—Pass a system property directly to the server process
-J<jvm-arg>, --jvm-arg <arg>—Pass a JVM argument to the server process (e.g. -J-Xmx16g)
Bash

# 1. Serve a classic ML model on port 9090
smile serve --model iris_rf.sml --port 9090

# 2. Serve an LLM with ONNX Runtime GenAI
smile serve --llm microsoft/Phi-4-mini-instruct-onnx --port 8888

# 3. Serve a large language model with continuous batching & multi-GPU tensor parallelism
smile serve --llm Qwen/Qwen3.8-27B --devices 0,1 --tp-size 2 --max-batch-size 32

# 4. Query classic ML prediction
curl -X POST http://localhost:9090/api/v1/smile/iris_random_forest-1 \
     -H "Content-Type: application/json" \
     -d '{"sepallength":5.1,"sepalwidth":3.5,"petallength":1.4,"petalwidth":0.2}'
    

Agent Hub & Bot Service (smile hub)

Bash

smile hub [options]
    

Starts the always-on autonomous Agent Hub runtime backing Agent Studio. Agent Hub runs in the background (locally or on a server) to execute scheduled routines, ingest external events (timers, webhooks, emails, and calendar feeds), consolidate cross-project memory logs, stage outbound drafts for human approval, and publish live HTML Bot Pages.

OptionDefaultDescription
--host <addr>localhostNetwork interface to bind (quarkus.http.host)
-p, --port <n>8890HTTP listen port (quarkus.http.port)
--profile <name>localQuarkus runtime profile: local (embedded H2) or server (PostgreSQL)
-w, --workspace <path>$SMILE_HOME/botBot workspace directory (hub.agent.workspace)
--admin-token <token>dev-admin-tokenBearer token required by /v1/admin/* endpoints
--log-level <level>INFOLogging level (INFO, DEBUG, WARN, ERROR)

Supported File Formats

smile train and smile predict use smile.io.Read.data(path, format) to load data. The format is auto-detected from the file extension (or defaults to CSV if the path has no extension); override it with --format.

ExtensionFormatDefault Behavior / --format Options
.arffWeka ARFFReads schema (column types and nominal levels) and data from the ARFF header.
.csv, .txt, .datDelimited text (CSV)Defaults to comma-delimited (,) with no header row (V1, V2, …). Customize via comma-separated key=value pairs: header=true, header=col1|col2, delimiter=\t, quote=", escape=\, comment=#.
.tsvTab-separated valuesDefaults to delimiter=\t,header=true.
.json, .jsonlJSON / JSON LinesDefaults to SINGLE_LINE (one flat JSON object per line). Pass --format MULTI_LINE for a JSON array [{...}, {...}].
.parquetApache ParquetColumnar format with embedded schema.
.avroApache AvroUses the embedded writer schema, or pass --format <schema.avsc> for an external schema file.
.arrow, .featherApache Arrow IPC / FeatherColumnar format with embedded schema.
.sas, .sas7bdatSAS7BDATReads SAS metadata and records.

Quoting --format and --formula on the Command Line

Because the launcher script and OS argument parser strip outer unescaped double quotes before forwarding arguments to smile.Main, escape inner double quotes when passing values containing =, spaces, or commas:


smile train -d data/iris.csv --format "\"header=true\"" --formula "species ~ ." -m iris_kmeans.sml kmeans -k 3
smile train -d data/prostate.csv --format "\"header=true,delimiter=\t\"" --formula "lpsa ~ ." -m prostate_ols.sml ols
    

JVM Tuning (conf/smile.ini)

The file conf/smile.ini contains JVM flags passed to every smile invocation. Defaults are tuned for modern multi-core hardware (75% max RAM, ZGC, compact object headers, NUMA, and string deduplication):

INI

# Heap: use up to 75% of RAM
-J-XX:MaxRAMPercentage=75
-J-XX:MaxMetaspaceSize=1024M
-J-Xss4M
-J-XX:+UseZGC
-J-XX:+UnlockExperimentalVMOptions -J-XX:+UseCompactObjectHeaders
-J-XX:+UseNUMA
-J-XX:+UseStringDeduplication

# System properties use the plain -Dname=value form (no -J prefix):
-Dsmile.agent.max-output-tokens=16384
    

Important: Always use the plain -Dname=value form (without a -J prefix) for system properties in conf/smile.ini so that both the Unix smile script and Windows smile.bat launcher forward the key-value pair intact.

Quick Reference Card

CLI Reference

ROUTING
  smile                           → Agent Studio (GUI)
  smile shell  [args]             → JShell REPL
  smile scala  [args]             → Scala 3 REPL
  smile train  -d FILE -m MODEL <algo> [algo-opts]
  smile predict FILE -m MODEL [-p] [-e] [--json]
  smile serve  [-m MODEL] [--onnx-model O] [--llm CHAT] [--port P]
  smile hub    [--host H] [--port P] [--profile local|server]

CLASSIFICATION ALGORITHMS
  random-forest  gradient-boost  ada-boost  cart
  logistic  fisher  lda  qda  rda  mlp  svm  rbf

REGRESSION ALGORITHMS
  random-forest  gradient-boost  cart  mlp  svm  rbf
  ols  lasso  ridge  elastic-net  gaussian-process

CLUSTERING ALGORITHMS
  kmeans  xmeans  gmeans  deterministic-annealing (da)

VECTOR QUANTIZATION ALGORITHMS
  som  neural-gas  growing-neural-gas (gng)  neural-map  birch

ANOMALY DETECTION ALGORITHMS
  isolation-forest (iforest)  lof  ocsvm (one-class-svm)

CROSS-VALIDATION FLAGS (train)
  -k <fold>    k-fold CV
  -r <rounds>  repeated CV
  -e           save ensemble of fold models
  -s <seed>    fix RNG seed

FEATURE TRANSFORMS (--transform)
  standardizer  robust  winsor(lo,hi)  minmax  MaxAbs  L1  L2  Linf
    
←   Agent Studio Tutorial  →