CoreAIKit

Forecast — time-series forecasting on device

Give it your own univariate series — paste numbers, pick a CSV file, or use one of the bundled real series — and get a probabilistic forecast back, fully on device. Two models:

Model Horizon Output Catalog id
TimesFM 2.5 200M 128 steps mean + deciles 0.1…0.9 timesfm-2.5-200m
Timestral 209M any, 1…1,024 steps 21 quantiles 0.01…0.99 timestral-209m

The whole ML surface is two lines per model:

let forecaster = try await KitForecaster(catalog: "timesfm-2.5-200m")
let f = try await forecaster.forecast(series)                 // series: [Float]; f.mean, f.quantiles (128 × 10)

let timestral = try await KitTimestralForecaster(catalog: "timestral-209m")
let q = try await timestral.forecast(series, horizon: 96)     // NaN in series = a missing value
q.median, q.quantile(0.1), q.quantile(0.9)                    // 96 values each

Sources/QuickStart.swift holds exactly those functions (forecast, forecastQuantiles, loadTimestral), and both the app and the CLI call them; Sources/SeriesInput.swift turns pasted text or a CSV file into a series. Copy the two files into your own project and they run.

Your own series

Timestral reads at most its bucket’s context (2,048 points for the 64-patch graph, 8,192 for the 256-patch one); a longer series keeps its most recent points, and the forecast says how many it read. A series with no number at all, an empty input, or a horizon outside 1…1,024 is refused with the reason.

Run

swift run forecast-cli --help                                              # terminal
swift run forecast-cli --model timestral-209m --series sales.csv --horizon 48 --band 90
pbpaste | swift run forecast-cli --model timestral-209m --series - --horizon 24
# --compute auto (default: each graph on its form's unit) | gpu | ane (that unit for every graph)

xcodegen generate                                                          # app
open Forecast.xcodeproj

Each model downloads its bundle from the Hugging Face Hub once and caches it; later runs are local. The CLI also runs a local Timestral bundle — a graph (.aimodel / .aimodelc) or a folder of them — with --bundle.

Notes

Licence of the Timestral weights

Timestral-209M is released by Mistral AI under a Modified MIT License (attribution notice: 2026 - Mistral AI). Two conditions matter for an app:

  1. The attribution notice and the permission notice go with every copy of the model or a substantial portion of it.
  2. You may not exercise any rights under the licence if the global consolidated monthly revenue of your company (or of your employer) exceeded $20 million (or its equivalent in another currency) in the preceding month. This applies to the model and to any derivative, modification or combined work — the converted Core AI graph included. Mistral AI offers commercial licences (sales@mistral.ai).

Read the full terms before shipping: LICENSE. Once listed, its catalog entry carries license, so an app can show it.