Get the FREE Ultimate OpenClaw Setup Guide →

forecasting-reverso

Scanned
npx machina-cli add skill oaustegard/claude-skills/forecasting-reverso --openclaw
Files (1)
SKILL.md
5.7 KB

Reverso Time Series Forecasting

Produce zero-shot univariate time series forecasts using the Reverso foundation model family (arXiv:2602.17634), implemented in NumPy/Numba for CPU-only container execution.

Setup (run once per conversation)

uv pip install numba --system --break-system-packages
cp /mnt/skills/user/forecasting-reverso/scripts/reverso.py /home/claude/reverso.py
cp /mnt/skills/user/forecasting-reverso/scripts/load_checkpoint.py /home/claude/load_checkpoint.py

Obtaining Weights

Two paths depending on network access:

Path A: Direct download (HuggingFace allow-listed)

import urllib.request, os
os.makedirs("/tmp/reverso", exist_ok=True)
url = "https://huggingface.co/shinfxh/reverso/resolve/main/checkpoints/reverso_small/checkpoint.pth"
urllib.request.urlretrieve(url, "/tmp/reverso/checkpoint.pth")

Path B: User upload (HuggingFace not accessible)

If the download fails with a network error, tell the user:

I can't reach HuggingFace from this environment. Please download the checkpoint from https://huggingface.co/shinfxh/reverso/blob/main/checkpoints/reverso_small/checkpoint.pth and upload it here.

Then load from /mnt/user-data/uploads/checkpoint.pth.

Loading weights

from load_checkpoint import load_checkpoint
weights = load_checkpoint("/tmp/reverso/checkpoint.pth")  # or upload path

Model Configuration

Reverso Small uses this config (matching the published args.json):

from reverso import ReversoConfig
config = ReversoConfig(d_model=64, module_list=["conv", "attn", "conv", "attn"])

Forecasting

from reverso import forecast, warmup_jit
warmup_jit()  # ~2s one-time JIT compilation

result = forecast(
    series=data,               # 1-D array/list of floats
    prediction_length=96,      # how many future steps
    weights=weights,           # dict from load_checkpoint
    config=config,
)

The function handles preprocessing (NaN interpolation, padding, min-max normalization) and autoregressive rollout internally.

Key parameters

flip_equivariant=True — averages forward pass on original and vertically-flipped input. Slightly improves single-step predictions but can dampen amplitude over multi-step rollout. Default is False.

Input Handling

Accept time series as Python list, NumPy array, CSV column, or inline values. Convert to 1-D float array before calling forecast().

For CSV/DataFrame input, ask the user which column to forecast if ambiguous.

The model's context window is 2048 steps. Series shorter than 2048 are left-padded with the first value. Series longer than 2048 use only the most recent 2048 observations. Provide at least a few hundred real data points for meaningful results — heavily padded context degrades forecast quality because the long convolution kernels process mostly constant input.

Visualization

import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(12, 4))
n = len(history)
ax.plot(range(n), history, label="Historical", color="#2563eb")
ax.plot(range(n, n + len(preds)), preds,
        label="Forecast", color="#dc2626", linewidth=2)
ax.axvline(x=n, color="gray", linestyle="--", alpha=0.4)
ax.set_xlabel("Time step"); ax.set_ylabel("Value")
ax.legend(); fig.tight_layout()
fig.savefig("/mnt/user-data/outputs/forecast.png", dpi=150)

Performance

PhaseLatency
numba install (uv)~1.6s
Weight loading (.pth)<1s
JIT warmup~2s
Forward pass (L=2048)~80ms
96-step forecast (2 chunks)~160ms
192-step forecast (4 chunks)~320ms

Container Environment Limits

Each forward pass takes ~65ms at L=2048. In the ephemeral container, reject batch forecasting requests that would exceed ~1500 forward passes (~100s wall time) to avoid timeouts.

Detect the container environment by checking for /mnt/user-data or /mnt/skills:

import os
IN_CONTAINER = os.path.exists("/mnt/user-data")

Estimate cost before running when processing multiple series:

n_forwards = n_series * n_windows * max(1, pred_length // 48)
est_seconds = n_forwards * 0.065
if IN_CONTAINER and est_seconds > 100:
    # Reject or subsample
    max_series = int(1500 / (n_windows * max(1, pred_length // 48)))

Practical limits at ~100s budget:

ScenarioSeriesWindowsPred stepsForwardsTime
Single series, 96-step112 chunks20.1s
Small dataset (sz_taxi)15664893661s
Medium dataset, short horizon300448120078s
Large dataset (m4_yearly)229741482297425min ✗

When a request exceeds the budget, inform the user with the estimated time and suggest either subsampling or running locally. For benchmark evaluation of large datasets, recommend running outside the container.

Limitations

The model is strongest with periodic or quasi-periodic signals and full 2048-point context. Short series (under ~200 points) are heavily padded and produce degraded forecasts — this is a model limitation, not an implementation bug. Edge cases: binary-valued input (e.g. step functions normalizing to exactly 0/1) and series ending at the exact min-max boundary are out-of-distribution for the training data.

For architecture details, weight mapping, and debugging guidance, read references/architecture.md.

Source

git clone https://github.com/oaustegard/claude-skills/blob/main/forecasting-reverso/SKILL.mdView on GitHub

Overview

Forecast univariate time series without retraining using the Reverso foundation model. It runs on CPU with NumPy/Numba, handles preprocessing and autoregressive rollout, and supports Reverso Small (~550K params). This makes rapid, offline forecasts feasible in constrained environments.

How This Skill Works

Inputs are converted to a 1-D float array. The model performs NaN interpolation, padding, and min–max normalization, then executes autoregressive rollout to generate future values. It uses a 2048-step context window; shorter series are left-padded, longer series retain the most recent 2048 points. The flip_equivariant option averages forward and flipped inputs for potential accuracy gains with trade-offs on long rollouts.

When to Use It

  • Forecast future values from a univariate time series (e.g., temperature, energy) without retraining.
  • CPU-only inference is required; you cannot or prefer not to use GPUs.
  • Deploy with Reverso Small (≈550K parameters) for a lightweight baseline.
  • A tabular dataset has a temporal column and you need to estimate future values.
  • You want a zero-shot forecast for rapid prototyping or offline environments with limited internet access.

Quick Start

  1. Step 1: Install dependencies and set up weights loading: uv pip install numba --system --break-system-packages; copy reverso.py and load_checkpoint.py into your working directory.
  2. Step 2: Load weights (direct HuggingFace download or upload if offline) and configure the model (e.g., config = ReversoConfig(d_model=64, module_list=["conv", "attn", "conv", "attn"])) and then call forecast(series=data, prediction_length=N, weights=weights, config=config).
  3. Step 3: Visualize or save the forecast results from the returned sequence and compare against actuals to validate performance.

Best Practices

  • Provide hundreds of real data points to ensure meaningful forecasts.
  • Ensure input is a 1-D numeric array; apply NaN interpolation if missing values exist.
  • Keep the context window near 2048 steps; if the series is longer, use only the most recent 2048 observations.
  • Choose an appropriate prediction_length (e.g., 96) based on your planning horizon; avoid overly long horizons for noisy data.
  • Consider using flip_equivariant judiciously; it may improve single-step accuracy but can dampen amplitude in longer rollouts.

Example Use Cases

  • Forecasting daily electricity consumption for the next 96 time steps.
  • Predicting the next 24 hours of sensor temperature in an offline device.
  • Extending weekly product demand history for quarterly planning.
  • Estimating future website visits from historical analytics in a CPU-only setup.
  • Baseline forecasting in an environment with restricted network access for weights.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers