Skip to content

cloudy-kz/TimeLM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Time Series Forecast — In Your Browser

Compare 5 state-of-the-art foundation models for time series forecasting — entirely client-side. No server. No Python. No install.

Live Demo License: MIT Single File Zero Dependencies


What is this?

time-lm is a zero-install browser tool that runs five time-series foundation models locally on your device using ONNX Runtime Web and Transformers.js. Upload a CSV, pick a column, and get forecasts from all five models side by side — with error metrics, trend indicators, and a full comparison table.

All computation happens inside your browser tab. Your data never leaves your machine.


Features

  • 5 foundation models compared side by side in a single run
  • Upload any CSV — date/time and numeric columns are auto-detected
  • 3 built-in demo datasets (Sales, Traffic, Crypto) — no file needed to start
  • Adjustable forecast horizon — 5 to 96 steps ahead
  • Automatic RMSE backtesting on a held-out test slice for each model
  • Uncertainty bands (p10/p90) where available
  • Export to CSV — history + all model forecasts in one file
  • Model weight caching — second runs are instant (browser Cache API)
  • Progressive rendering — chart updates as each model finishes
  • Fully offline after first load — weights are cached locally
  • Private by design — zero data leaves the browser

Models

Model Author Year Size Engine Notes
TimesFM 2.5 Google Research 2024 ~1 GB ONNX (WASM) General-purpose; strongest on trends and seasonality
Chronos-2 Amazon / Hugging Face 2025 ~130 MB ONNX (WASM) T5-based; native quantile output (p10/p50/p90)
Moirai Salesforce AI 2024 ~0.5 MB Transformers.js PatchTST proxy until official ONNX export is available
Granite TTM IBM 2024 ~0.2 MB Transformers.js Tiny Time Mixer; fastest startup, good for quick checks
TiRex NX-AI 2025 ~140 MB ONNX (WASM) xLSTM architecture; strong on long, complex series

First-run note: TimesFM downloads ~1 GB on first use. All other models are under 150 MB. Weights are cached in the browser after the first download — subsequent runs start in seconds.


Quick Start

Option 1 — Open directly (no setup)

open index.html

Drag the file into any modern browser. That's it.

Option 2 — GitHub Pages

Fork this repo, go to Settings → Pages, set source to the main branch root. Your app will be live at https://<your-username>.github.io/time-lm/.

The official hosted demo is available at timelm.ree.kz.

Option 3 — Local dev server (avoids CORS on some browsers)

# Python
python -m http.server 8080

# Node.js
npx serve .

Then open http://localhost:8080.


Usage

  1. Load data — drop a CSV file onto the upload zone, or click one of the three demo dataset buttons (Sales / Traffic / Crypto).
  2. Choose target column — the app auto-selects the most variable numeric column. Override via the dropdown.
  3. Set horizon — drag the slider to set how many future steps to predict (default: 30).
  4. Select models — uncheck any models you don't need (disabling TimesFM saves significant download time).
  5. Run forecast — click Run forecast. Models load and execute sequentially; the chart updates as each one finishes.
  6. Inspect results — compare RMSE, trend direction, and final predicted value in the comparison table.
  7. Export — click Download CSV to get history + all forecasts in a single file.

CSV format

The app accepts any CSV with a header row. It auto-detects:

  • Date/time column — ISO dates (2024-01-15), times (14:00), or any label-like string in the first column.
  • Numeric target column — any column with at least 8 finite numeric values (commas in numbers are stripped automatically).

Minimum: 8 rows of numeric data.

Date,Sales
2024-01-01,142
2024-01-02,138
2024-01-03,155
...

How it works

Browser
  └── index.html (single file, ~1 700 lines)
        ├── UI: Tailwind CSS · Chart.js · Lucide icons
        ├── CSV parsing: PapaParse
        ├── ONNX inference: onnxruntime-web (WASM worker)
        │     ├── TimesFM 2.5  (pdufour/timesfm-2.5-200m-transformers-onnx)
        │     ├── Chronos-2    (kashif/chronos-2-onnx)
        │     └── TiRex        (NX-AI/TiRex)
        └── Transformers.js
              ├── Moirai proxy (onnx-community/granite-timeseries-patchtst)
              └── Granite TTM  (onnx-community/granite-timeseries-patchtsmixer)

Inference pipeline (per model):

  1. History is extracted from the CSV and normalised.
  2. Context window is padded/truncated to the model's expected input length.
  3. ONNX session runs in a WASM worker (non-blocking).
  4. Output is de-normalised and appended to the chart.
  5. A backtest RMSE is computed on a held-out tail slice (≤16 points) to rank models.

Hybrid decomposition (Moirai / Granite TTM): PatchTST and PatchTSMixer were trained on ETTh1 electricity data, so raw inference on arbitrary series produces artefacts. The app applies OLS trend + peak-to-peak seasonal decomposition first, feeds only the residuals to the neural model, and recombines — limiting the neural contribution to ±30% to keep the statistical base dominant.

Statistical fallback: If a model's ONNX weights cannot be loaded (e.g. Chronos-2 Gather-op type mismatch in some browser/WASM combinations), the app transparently falls back to a linear-trend + seasonal ETS model and marks the result ETS fallback in the status column.


Browser compatibility

Browser Status
Chrome / Edge 113+ Fully supported
Firefox 115+ Supported
Safari 17+ Supported (WASM SIMD required)
Mobile Chrome Supported (desktop mode recommended for large models)

WebGPU acceleration is not yet enabled; all inference runs on the CPU via WASM.


Tech stack

Library Version Purpose
Tailwind CSS CDN UI layout and styling
Chart.js CDN Time-series chart
PapaParse 5.4.1 CSV parsing
Lucide 0.469.0 Icons
jQuery 3.7.1 DOM utilities
onnxruntime-web 1.26.0 ONNX inference in WASM
Transformers.js 3.8.1 Hugging Face model loader

All loaded from public CDNs. No npm, no bundler, no build step.


Roadmap

  • WebGPU execution provider for GPU-accelerated inference
  • Multi-variate forecasting (multiple target columns)
  • Additional models: Lag-Llama, Moirai-MoE (when official ONNX is available)
  • Forecast confidence interval visualisation on the chart
  • PWA / offline-first manifest

Contributing

Contributions are welcome! Please read CONTRIBUTING.md before opening a pull request.

Good first issues:

  • Add a new ONNX-exportable foundation model
  • Improve mobile layout
  • Add WebGPU support via ort.env.wasm.proxy = false + WebGPU EP

License

MIT — use it, fork it, ship it.


Acknowledgements

This project stands on the shoulders of:

About

Run 5 time-series foundation models (TimesFM, Chronos-2, Moirai, Granite TTM, TiRex) side by side — entirely in your browser. No server, no install.

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages