Skip to main content

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:

Release files for litespecformer 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for litespecformer 0.0.3
File Size Uploaded
litespecformer-0.0.3.tar.gz 7.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for litespecformer 0.0.3
File Interpreter ABI Platform
litespecformer-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 8.0 MB

Release files / litespecformer-0.0.3.tar.gz

Download URL litespecformer-0.0.3.tar.gz
Size 7.9 MB
Tags Source
SHA-256 checksum
How to use checksums
c03fb614326f1142cedcd78d0644675ff0afd785972c82d332259be3d53bc8c8
BLAKE2b-256 checksum
How to use checksums
1875e4d8185f4657b11955c7ddffe048a150e7d180fc0e674ab26df905d13d72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / litespecformer-0.0.3-py3-none-any.whl

Download URL litespecformer-0.0.3-py3-none-any.whl
Size 75.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65e97b88c2023d45af7eeacf41b663d1e78b64d89f61d8d34841be796d89188b
BLAKE2b-256 checksum
How to use checksums
63d320798369b4b910d29b8a14f48739a87ad2d6126786212f8d7b594519be0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page