Skip to main content

A lightweight Transformer-based model for spectrum prediction and time series forecasting

Project description

LiteSpecFormer

PyPI version huggingface huggingface License: MIT

✨Overview

LiteSpecFormer is the first lightweight wireless foundation model for zero-shot confidence spectrum prediction. Built on a channel-independent Transformer with a sliding autoregressive paradigm and a novel linear correlation loss to mitigate error accumulation, it achieves state-of-the-art performance across arbitrary frequency bands and sequence lengths without downstream fine-tuning.

model

We present Large-Spectrum-Prediction-Dataset (LSPD), the first large-scale dataset specifically designed for pre-training spectrum prediction foundation models. It comprises 18 billion timestamps and integrates two learnable data generation mechanisms to generate high-quality, diverse spectrum samples.

dataset

🧭 Quickstart

Installation

First create a Python virtual environment with 3.11+, then install the required dependencies through PyPI:

pip install litespecformer

Then, you can refer to our demo file to create our pipeline and then use the prediction method for zero-shot prediction:

from s2generator.utils import generate_nonstationary_sine
from litespecformer import LiteSpecFormerPipeline


# Load our model using our pipeline.
pipeline = LiteSpecFormerPipeline.from_pretrained("FlowVortex/LiteSpecFormer")

# Set the context length and prediction length
context_length = 256
# Generate a non-stationary sine wave time series with the specified lengths
time_series = np.vstack(
    [
        generate_nonstationary_sine(
            seq_length=context_length + prediction_length, freq=2 + i
        )
        for i in range(5)
    ]
)

# Prediction the inputs through our pipeline
outputs = pipeline.predict(
    time_series[:, :context_length], prediction_length=prediction_length
)

Data Preparation

Download Large-Spectrum-Prediction-Dataset (LSPD) for pre-training or downstream evaluation:

hf download FlowVortex/Large-Spectrum-Prediction-Dataset \
  --local-dir ./data \
  --type dataset

To fetch only the test split (useful for quick benchmarking):

hf download FlowVortex/Large-Spectrum-Prediction-Dataset \
  --local-dir ./data \
  --type dataset \
  --include "test/*"

The simulation and augmentation pipelines used to build LSPD are available in S2Generator: see the simulator and augmentation modules.

Model Pre-Train and Fine-Tune

We provide scripts for pre-training, fine-tuning, and zero-shot out-of-distribution evaluation on downstream tasks:

# Pre-train LiteSpecFormer
bash scripts/pre-training.sh

# Fine-tune LiteSpecFormer
bash scripts/fine_tuning.sh

Zero-Shot Evaluation

After downloading the test split, run the evaluation scripts for zero-shot out-of-distribution prediction. At inference time, LiteSpecFormer performs channel-independent forecasting:

# Example: Madrid dataset
bash scripts/zero_shot_prediction/Madrid.sh

Other benchmark datasets are available under scripts/zero_shot_prediction/ (e.g., Alcorcon1, IADAM, Nudelsalat, Oreland, PiSDR1).

📊 Results

Benchmark Results

After large-scale pre-training, LiteSpecFormer achieves stronger out-of-distribution generalization and scalability than existing supervised baselines:

benchmark

Forecasting Visualization

Predictions on the Madrid dataset. Compared with supervised in-distribution models and other out-of-distribution zero-shot baselines, LiteSpecFormer produces more accurate forecasts, especially in fine-grained spectral detail:

visualization

🎖️ Acknowledgement

We appreciate the following GitHub repos a lot for their valuable code and efforts.

🤗 Contact

If you have any questions or are interested in our view on the complex dynamics of time series, feel free to contact:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

litespecformer-0.0.2.tar.gz (7.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litespecformer-0.0.2-py3-none-any.whl (75.4 kB view details)

Uploaded Python 3

File details

Details for the file litespecformer-0.0.2.tar.gz.

File metadata

  • Download URL: litespecformer-0.0.2.tar.gz
  • Upload date:
  • Size: 7.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for litespecformer-0.0.2.tar.gz
Algorithm Hash digest
SHA256 db26a42a16eb2a79df6f664bac80a2ca723846cdc0e52fbb5231d6d906b50587
MD5 fcb7492d5913e2eeeef36835995cf0dd
BLAKE2b-256 60b9ff2e312f198c447b1ad2caacb2b85874f2c94547222ba2073a051a5dfaa2

See more details on using hashes here.

File details

Details for the file litespecformer-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: litespecformer-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 75.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for litespecformer-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8e391d1130e7bf1858f8a4da46e256a9889c4dc868a324f161e62e0f134210b6
MD5 5ac133e3b330e70a1f48ec2b9c18c7ed
BLAKE2b-256 ccc37750bed69259bec80d925931a0e8148f449e192065665f3aa101234bb4fc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page