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:
| Invocation | Description |
|---|---|
smile (no args) | Open the Agent Studio desktop IDE |
smile shell | Start the Java (JShell) interactive REPL |
smile scala | Start 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
- Java 25 or later (the bundled JBR in the distribution is sufficient).
- Python 3 (optional — required only for the Studio notebook’s Python kernel and the
tylanguage server). - ARPACK / OpenBLAS (optional — for hardware-accelerated linear algebra).
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:
# macOS / Linux
path/to/smile/bin/setup
# Windows
path\to\smile\bin\setup.bat
Running the Launcher
# 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)
smile shell [jshell-options…]
Starts an interactive JShell session pre-configured for SMILE development:
- The full SMILE classpath is added with
--class-path. - 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. DEFAULTandPRINTINGJShell startup scripts are loaded (makingprintln()available without a class qualifier).bin/predef.jshis loaded, defining the compact colorsmilefeedback mode, pre-importing every major SMILE package, and printing the SMILE banner.- 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:
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:
# 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)
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:
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)
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
| Option | Short | Required | Default | Description |
|---|---|---|---|---|
--data <file> | -d | Yes | — | Training data file path |
--model <file> | -m | Yes | — | Output model file path (.sml) |
--test <file> | — | Optional hold-out test file | ||
--format <fmt> | auto-detect | Data format specification (see Supported File Formats) | ||
--formula <expr> | auto-detect | Model formula, e.g. class ~ . | ||
--model-id <id> | — | Metadata tag: model identifier | ||
--model-version <ver> | — | Metadata tag: model version string | ||
--kfold <k> | -k | 1 | Enable k-fold cross-validation | |
--round <n> | -r | 1 | Repeated cross-validation rounds | |
--ensemble | -e | false | Build ensemble from cross-validation fold models | |
--seed <n> | -s | 0 (off) | RNG seed for reproducibility | |
--help | -h | Print help and exit | ||
--version | -V | Print SMILE version and exit |
Formula Auto-Detection
If --formula is omitted:
- Supervised learning (classification and regression): the response variable is chosen automatically by inspecting column names in priority order:
class→target→y→ the first column in the file. - Unsupervised learning (clustering, vector quantization, and anomaly detection): all columns are included as features (
~ .). If you supply a formula with a left-hand side (e.g.--formula "class ~ ."), the response column is excluded from the input feature schema.
Classification Algorithms
All classification sub-commands default to classification mode. Algorithms that also support regression expose --regression to switch modes.
| Sub-command | Algorithm | Modes | Key Options |
|---|---|---|---|
random-forest | Random Forest | Classification, 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-boost | Gradient Boosted Trees | Classification, Regression (--regression) | --trees <n>, --shrinkage <rate>, --max-depth <n>, --max-nodes <n>, --node-size <n>, --sampling <rate> |
ada-boost | AdaBoost | Classification | --trees <n>, --max-depth <n>, --max-nodes <n>, --node-size <n> |
cart | Decision Tree (CART) | Classification, Regression (--regression) | --split <rule>, --max-depth <n>, --max-nodes <n>, --node-size <n> |
logistic | Logistic Regression | Classification | --lambda <λ>, --iterations <n>, --tolerance <ε>, --transform <rule> |
fisher | Fisher’s Linear Discriminant | Classification | --dimension <d>, --tolerance <ε>, --transform <rule> |
lda | Linear Discriminant Analysis | Classification | --priori <p0,p1,…>, --tolerance <ε>, --transform <rule> |
qda | Quadratic Discriminant Analysis | Classification | --priori <p0,p1,…>, --tolerance <ε>, --transform <rule> |
rda | Regularized Discriminant Analysis | Classification | --alpha <α> (required, in [0, 1]), --priori <p0,p1,…>, --tolerance <ε>, --transform <rule> |
mlp | Multilayer Perceptron | Classification, 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> |
svm | Support Vector Machine | Classification, 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> |
rbf | Radial Basis Function Network | Classification, 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-command | Algorithm | Key Options |
|---|---|---|
ols | Ordinary Least Squares | --method <qr|svd> (default qr), --stderr, --recursive |
lasso | LASSO Regression | --lambda <λ> (required, L1 penalty), --iterations <n>, --tolerance <ε> |
ridge | Ridge Regression | --lambda <λ> (required, L2 penalty) |
elastic-net | Elastic Net | --lambda1 <λ1> (required, L1), --lambda2 <λ2> (required, L2), --iterations <n>, --tolerance <ε> |
gaussian-process | Gaussian 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:
| Category | Sub-command | Algorithm | Key Options |
|---|---|---|---|
| Clustering | kmeans | K-Means | -k, --clusters <k> (required), --iterations <n>, --tolerance <ε>, --runs <n>, --transform <rule> |
| Clustering | xmeans | X-Means | -k, --clusters <kmax> (required), --iterations <n>, --tolerance <ε>, --transform <rule> |
| Clustering | gmeans | G-Means | -k, --clusters <kmax> (required), --iterations <n>, --tolerance <ε>, --transform <rule> |
| Clustering | deterministic-annealing (da) | Deterministic Annealing | -k, --clusters <kmax> (required), --alpha <α>, --iterations <n>, --tolerance <ε>, --split-tolerance <ε>, --transform <rule> |
| Vector Quantization | som | Self-Organizing Map | --nrow <rows> (default 10), --ncol <cols> (default 10), --epochs <n>, --alpha <sched>, --neighborhood <fn>, --transform <rule> |
| Vector Quantization | neural-gas | Neural Gas | -k, --neurons <k> (default 10), --epochs <n>, --alpha <sched>, --theta <sched>, --lifetime <sched>, --transform <rule> |
| Vector Quantization | growing-neural-gas (gng) | Growing Neural Gas | --epochs <n>, --eps-best <ε>, --eps-neighbor <ε>, --edge-lifetime <n>, --lambda <n>, --alpha <α>, --beta <β>, --transform <rule> |
| Vector Quantization | neural-map | NeuralMap | --radius <r> (required), --epochs <n>, --eps-best <ε>, --eps-neighbor <ε>, --edge-lifetime <n>, --beta <β>, --transform <rule> |
| Vector Quantization | birch | BIRCH | --radius <T> (required), --branching <B>, --leaves <L>, --transform <rule> |
| Anomaly Detection | isolation-forest (iforest) | Isolation Forest | --trees <n> (default 100), --max-depth <n>, --sampling <rate>, --extension-level <n>, --threshold <score> (default 0.5), --transform <rule> |
| Anomaly Detection | lof | Local Outlier Factor | -k, --neighbors <k> (default 20), --threshold <score> (default 1.5), --transform <rule> |
| Anomaly Detection | ocsvm (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 Value | Class | Description |
|---|---|---|
standardizer | Standardizer | Zero mean, unit variance |
robust | RobustStandardizer | Median and IQR scaling (robust to outliers) |
winsor(lo,hi) | WinsorScaler | Winsorize at percentiles, e.g. winsor(0.01,0.99) |
minmax | Scaler | Scale features to [0, 1] |
MaxAbs | MaxAbsScaler | Scale by maximum absolute value |
L1, L2, Linf | Normalizer | L1, 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:
# 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)
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.
| Option | Short | Required | Description |
|---|---|---|---|
<data-file> | Yes | Input data file (positional argument) | |
--model <file> | -m | Yes | Saved model file (.sml) |
--format <fmt> | Data file format (see Supported File Formats) | ||
--probability | -p | Append posterior probabilities for soft classifiers | |
--explain | -e | Compute local SHAP feature explanations (automatically enables --json) | |
--json | Output 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:
# 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)
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:
- Classic ML (
/api/v1/smile,/api/v1/ml/models) — serialized SMILE models (.sml) - ONNX Runtime (
/api/v1/onnx) — open neural network format (.onnx) - LLM Chat (
/api/v1/chat/completions,/api/v1/models) — OpenAI-compatible chat completions with continuous batching or ONNX Runtime GenAI
| Option | Default | Description |
|---|---|---|
-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> | localhost | Network interface to bind (quarkus.http.host) |
-p, --port <n> | 8888 | HTTP listen port (quarkus.http.port) |
--devices <list> | 0 | CUDA device index or comma-separated tensor-parallel list (e.g. 0,1) |
--tp-size <n> | 1 | Tensor-parallel world size |
--max-batch-size <n> | 16 | Maximum in-flight requests for continuous batching |
--max-seq-len <n> | 0 (auto) | Maximum context length in tokens |
--attention <backend> | flashinfer | Attention kernel backend (flashinfer or torch_native) |
--quantization <mode> | auto | Weight GEMM quantization (auto, dense, fp8, nvfp4, marlin) |
--speculative / --no-speculative | true | Enable or disable native MTP speculative decoding |
--kv-dtype <type> | auto | KV-cache dtype (auto, bfloat16, float16, float32, fp8_e4m3, fp8_e5m2) |
--prefix-reuse / --no-prefix-reuse | true | Enable or disable radix KV prefix cache reuse |
--oga-provider <ep> | auto | ONNX 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) |
# 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)
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.
| Option | Default | Description |
|---|---|---|
--host <addr> | localhost | Network interface to bind (quarkus.http.host) |
-p, --port <n> | 8890 | HTTP listen port (quarkus.http.port) |
--profile <name> | local | Quarkus runtime profile: local (embedded H2) or server (PostgreSQL) |
-w, --workspace <path> | $SMILE_HOME/bot | Bot workspace directory (hub.agent.workspace) |
--admin-token <token> | dev-admin-token | Bearer token required by /v1/admin/* endpoints |
--log-level <level> | INFO | Logging 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.
| Extension | Format | Default Behavior / --format Options |
|---|---|---|
.arff | Weka ARFF | Reads schema (column types and nominal levels) and data from the ARFF header. |
.csv, .txt, .dat | Delimited 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=#. |
.tsv | Tab-separated values | Defaults to delimiter=\t,header=true. |
.json, .jsonl | JSON / JSON Lines | Defaults to SINGLE_LINE (one flat JSON object per line). Pass --format MULTI_LINE for a JSON array [{...}, {...}]. |
.parquet | Apache Parquet | Columnar format with embedded schema. |
.avro | Apache Avro | Uses the embedded writer schema, or pass --format <schema.avsc> for an external schema file. |
.arrow, .feather | Apache Arrow IPC / Feather | Columnar format with embedded schema. |
.sas, .sas7bdat | SAS7BDAT | Reads 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
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):
# 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
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