# Foundation models on Asense data

> Guides to running and fine-tuning time-series foundation models (TimesFM, Chronos-2, MOMENT, TOTO) on Asense records, each compared with a simple baseline.

> **Coming soon:** The guides' repository, `asense-tsfm`, is not public yet. This page describes what it holds and the results so far.

## What the guides are

Each guide asks one question about Asense data and answers it with a time-series foundation model, a model pre-trained on many kinds of time series that can forecast or score a new one without being trained on it first. Every guide also runs a simple baseline on the same data, and reports the result as it came out, including when the baseline wins.

The guides run on the [public dataset](https://asense.semitronica.pt/docs/dataset/) of one reference sensor, ASENSE00000005, read from Parquet with DuckDB. They run locally on a laptop: Apple Silicon (MPS) or CPU, with the small model sizes. Model checkpoints are downloaded from Hugging Face on first use.

ASENSE00000005 is a stationary unit on a bench. Its tilt changes by thousandths of a degree, close to the sensor's resolution, and it was re-mounted several times, so the guides work on its longest stable stretches. That makes them tests of method: they show how to run each model on Asense records and what it does on a quiet sensor, not how it performs on a structure that moves.

## The guides

| Guide | Question | Model | Status and result |
|---|---|---|---|
| 1 | Can a foundation model forecast a sensor's tilt from temperature? | TimesFM 2.5, with temperature as a covariate | Run. A straight line on temperature forecast best: 0.23 against 0.29 thousandths of a degree of mean error over 128 hours |
| 2 | Which days in a tilt record look unusual? | TimesFM 2.5 and Chronos-2 forecast error, against a rolling z-score | Run. The two models agree closely and flag days whose shape changed; the z-score flags slow shifts in level |
| 3 | Does fine-tuning Chronos-2 on your own sensor improve its forecasts? | Chronos-2 with LoRA fine-tuning | Run. No: about 1,400 hours of a quiet record were too few, and the fine-tuned model was worse than both zero-shot and "same hour yesterday" |
| 4 | Which vibration records look odd? | MOMENT reconstruction error, against an RMS threshold and an FFT peak rule | Run. The methods flag different records; MOMENT's top record falls on a day the unit was re-mounted |
| 5 | Can one model learn a whole tilt chain at once? | TOTO multivariate fine-tune | Outline. Uses simulated demo data, since one device is not a chain |
| 6 | Does a model trained on one structure forecast another? | TOTO refit | Outline. Two mountings of ASENSE00000005 stand in for two structures |
| 7 | Can a model forecast tomorrow's noise levels? | Chronos-2 and TOTO 2 zero-shot | Outline. Needs an Environmental Sensor's `env` records |
| 8 | Does a small model trained from scratch match a fine-tuned one? | TimesNet | Outline, on the same data as guide 3 |

Each run guide has a notebook version with the question as its title, and saves its plots.

## Running a guide

```sh
export ASENSE_DATA=/path/to/asense-dataset/data
cd guides
uv run --with-requirements ../requirements.txt python 01_tilt_from_temperature.py
```

Guide 4 uses the MOMENT package, which needs an older version of `transformers`, so it has its own requirements file, `requirements-moment.txt`.

## What the results say so far

On a quiet sensor, simple methods are hard to beat. A line on temperature explains this unit's tilt better than any forecast model, and fine-tuning on a short record overfits. Where the models add something is in noticing records or days whose shape is unusual even when their level is not. That is worth having as a list of records to look at, rather than as alarms. The guides are meant to be re-run on longer records of structures that really move, where the models have more to learn.

## Models and licences

| Model | Checkpoint | Licence |
|---|---|---|
| TimesFM 2.5 | `google/timesfm-2.5-200m-transformers` | Apache-2.0 |
| Chronos-2 | `amazon/chronos-2` | Apache-2.0 |
| MOMENT | `AutonLab/MOMENT-1-small` | MIT |

Licences are as stated on each model's Hugging Face model card. The models for guides 5 to 8 are added here when those guides are written.

Source page: https://asense.semitronica.pt/docs/foundation-models/
