How haifengl/smile works
1. What this repo is
SMILE is a monorepo for a JVM-based machine learning platform, but it is not one runtime. It contains several deployable/library boundaries: core ML libraries, deep learning/LLM code, NLP, visualization, a REST inference server, a desktop IDE/shell, Spark wrappers, language bindings, and the public website/docs.
2. Foundation layer: base/
base is the shared substrate. It provides the data model and utilities used across the rest of the repo: DataFrame, tuple/vector types, schemas and data types, formula parsing, transforms, I/O readers/writers, math utilities, linear algebra, kernels, distances, random generation, distributions, graphs, nearest-neighbor indexes, wavelets, and small support utilities. If you are drawing dependencies, this is the lowest common library most other modules build on.
3. Algorithm layer: core/
core is the main classical ML engine on top of base. It contains supervised learning, clustering, manifold learning, feature engineering, anomaly detection, association rules, sequence learning, time series, validation, metrics, and hyperparameter optimization. Its internal flow is typically: data structures from base → feature preparation/validation → model training → metrics/prediction. Most of the repository’s “traditional ML” APIs live here.
4. Deep learning and LLM stack: deep/
deep is a separate tensor-and-model stack centered on LibTorch/GPU support. It defines its own tensor, device, activation, layer, loss, optimizer, metric, and model abstractions instead of reusing the base tensor code. On top of that sit higher-level packages for LLaMA/chat generation and vision/EfficientNet workflows. Architecturally, this module bridges Java APIs to native PyTorch/Libtorch and CUDA when available.
5. NLP subsystem: nlp/
nlp is a self-contained text-processing layer: tokenization, sentence/paragraph splitting, normalization, stemming, POS tagging, relevance ranking, collocations, and taxonomy/WordNet-style relationships. It is mostly preprocessing and text-analysis infrastructure rather than a model-serving layer, and it feeds text-oriented applications and examples elsewhere in the repo.
6. Visualization subsystem: plot/
plot provides two distinct presentation paths. smile.plot.swing is an interactive desktop plotting API for charts and scientific visualization, while smile.plot.vega generates declarative Vega-Lite specs for browser/Jupyter rendering. This module depends heavily on the data structures in the rest of SMILE, and acts as the presentation boundary for analysis results.
7. Inference server: serve/
serve is a Quarkus-based server for model inference and chat. It exposes REST resources for generic inference and OpenAI-compatible chat/completions, plus SSE streaming for incremental responses. The server side includes ONNX-backed model loading and a chat service layer, and it also ships a React/Vite web UI under src/main/webui for interactive inference and chat. The main external boundary here is HTTP/SSE on the outside and serialized model artifacts on the inside.
8. Desktop IDE / shell: studio/
studio is the interactive authoring environment. It bundles a desktop UI, notebook support, text editor, workspace management, kernels for Java/Scala/Python/script execution, and CLI entry points such as shell/train/predict/serve. It is the main human-facing runtime for experimentation, with its own resource bundle, notebooks, and launcher scripts under src/universal.
9. Language bindings and cross-language ergonomics
scala/ and kotlin/ provide idiomatic wrappers over the Java APIs so the same underlying engine can be used with Scala and Kotlin syntax/collections/builders. clojure/ offers a smaller set of Clojure-facing wrappers. These are API-adaptation layers, not separate engines. json/ is a separate Scala JSON library used by the ecosystem where lightweight parsing/printing is needed.
10. Spark integration boundary: spark/
spark adapts SMILE models into Spark ML-compatible components such as transformers, classifiers, and regressors. Its role is to let trained SMILE algorithms participate in distributed Spark DataFrame pipelines, so the architectural boundary is between Spark’s distributed data flow and SMILE’s local model objects.
11. Common supporting infrastructure
The repo is heavily test-driven and ships many resource fixtures: benchmark datasets, sample images, ONNX models, notebooks, and parser inputs. Build and packaging are split across Gradle and SBT, with module-specific conventions in buildSrc and CI/release workflows in .github/workflows. That matters architecturally because the repo is organized as a multi-module platform with multiple packaging targets, not a single application.
12. Overall data flow
Most workflows start with data ingestion in base/nlp/deep/serve, move through feature engineering or tensor/model layers, then go into algorithm modules in core or deep, and finally emerge through validation/metrics, visualization, serialization, or serving. The primary boundaries are: native-backed math/deep learning vs pure-Java ML, local libraries vs server/desktop runtimes, and core engine vs language-specific façades.
Main entry points: base Base · core Core ML · studio Studio · deep Deep
Components 18
Foundation
Shared data model, math, linear algebra, I/O, and utility substrate.
- Base · Shared data frames, types, math, I/O, linear algebra, graphs, and utilities.
base
Classical ML
Traditional machine learning, feature processing, validation, and model families.
Deep Stack
Native-backed tensor, LLM, and vision components.
- Deep · LibTorch-based tensor, layers, optimization, LLM, and vision workflows.
deep
Runtimes
User-facing inference and desktop environments.
Bindings
Language façades and integration adapters.
- Spark · Spark ML wrappers that bridge distributed pipelines to SMILE models.
spark - Scala · Idiomatic Scala wrappers and extension APIs over the Java libraries.
scala - Kotlin · Kotlin-friendly wrappers for the SMILE API surface.
kotlin - Clojure · Clojure bindings for selected SMILE functionality.
clojure - JSON · Standalone Scala JSON parser/printer/serializer library.
json
Platform
Website, build, and release infrastructure around the library modules.
- Website · Public documentation and marketing site for the platform.
website - Build Logic · Shared Gradle/SBT build conventions and packaging logic.
buildSrc - Project · SBT project-level settings, overrides, and plugins.
project - Scripts · Packaging, setup, publishing, and convenience shell scripts.
bin - CI/CD · Automation for CI, publishing, release, and security checks.
.github - Binder · Reproducible notebook environment definition for hosted use.
binder
Connections 21
- Base → Core ML: foundation · Classical ML builds on shared data, math, and I/O primitives.
- Base → NLP: foundation · Text processing uses shared utilities and data structures.
- Base → Plot: data feed · Visualization consumes shared datasets and tabular structures.
- Base → Spark: data bridge · Spark adapters rely on common data-frame and type abstractions.
- Base → Scala: wraps · Scala APIs expose the base library with idiomatic syntax.
- Base → Kotlin: wraps · Kotlin APIs adapt the base and core libraries.
- Base → Clojure: wraps · Clojure bindings sit on top of the shared Java engine.
- Base → Studio: workspace data · Studio uses shared notebook, kernel, and model utilities.
- Core ML → Deep: parallel stack · Deep learning is a separate model stack alongside classical ML.
- Core ML → Serve: model export · Inference server loads and serves trained model artifacts.
- Core ML → Spark: model bridge · Spark wrappers adapt core models into distributed pipelines.
- NLP → Core ML: feeds · Text features and preprocessing feed classical ML workflows.
- Deep → Serve: chat/infer · Serve can expose deep models for inference and chat.
- Deep → Website: docs · Website documents deep learning and LLM workflows.
- Plot → Website: showcase · Website highlights visualization capabilities and examples.
- Studio → Serve: launch · Studio includes entry points to start serving workflows.
- Studio → Core ML: experiments · Studio notebooks and CLI drive training and prediction tasks.
- Website → Base: explains · Docs cover foundational data, math, and I/O concepts.
- Build Logic → Project: build system · Shared build logic works with the SBT project settings.
- CI/CD → Scripts: automation · CI and release workflows exercise repository scripts.
- Binder → Studio: notebooks · Binder provides a hosted environment for Studio-style notebooks.