Metadata-Version: 2.4
Name: dualweaver
Version: 0.1.0
Summary: DualWeaver: A PyPI package for adapting Hugging Face Time Series Foundation Models with Synergistic Feature Weaving.
Home-page: https://github.com/li-jinpeng/dualweaver-package.git
Author: Jinpeng Li
Author-email: li-jp23@mails.tsinghua.edu.cn
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: datasets
Requires-Dist: gluonts
Requires-Dist: numpy==2.1.3
Requires-Dist: pandas
Requires-Dist: pyarrow
Requires-Dist: torch==2.4.0
Requires-Dist: transformers==4.40.1
Requires-Dist: arch
Requires-Dist: tqdm
Requires-Dist: torchmetrics
Requires-Dist: scipy
Requires-Dist: safetensors
Requires-Dist: pyarrow
Requires-Dist: matplotlib
Requires-Dist: accelerate
Requires-Dist: h5py
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# DualWeaver

DualWeaver is an official PyPI package for adapting Hugging Face Time Series Foundation Models (TSFMs) using **Synergistic Feature Weaving**. 

This package allows you to seamlessly integrate the DualWeaver methodology with any open-source pre-trained model based on the `transformers` library to significantly improve forecasting performance while preserving the original pre-trained knowledge.

## Installation

```bash
pip install dualweaver
```

Or install from source:

```bash
git clone https://github.com/yourusername/dualweaver.git
cd dualweaver
pip install -e .
```

## Quick Start

```python
import torch
from transformers import AutoConfig, AutoModelForCausalLM
from dualweaver import DualWeaverConfig, DualWeaverModel

# 1. Load an open-source TSFM from Hugging Face
hf_config = AutoConfig.from_pretrained("thuml/timer-base-84m")
hf_model = AutoModelForCausalLM.from_config(hf_config) # or from_pretrained

# 2. Configure DualWeaver
config = DualWeaverConfig(
    adapter="WeaverMLP", # or "WeaverCNN"
    input_channel=7,
    hf_model_type="timer"
)

# 3. Wrap with DualWeaver
model = DualWeaverModel(config, hf_model)

# 4. Train
model.train()
batch_x = torch.randn(32, 672, 7) # Batch, Length, Channel
batch_y = torch.randn(32, 96, 7)  # Batch, Length, Channel
loss = model(batch_x, batch_y)
loss.backward()

# 5. Inference
model.eval()
with torch.no_grad():
    predictions = model(batch_x)

# 6. Save
model.save_pretrained("./dualweaver_model")

# 7. Load
loaded_model = DualWeaverModel.from_pretrained("./dualweaver_model")
```

## Citation
If you find this useful or use it in your research, please consider citing the DualWeaver paper:

```bibtex
@misc{li2026dualweaversynergisticfeatureweaving,
      title={DualWeaver: Synergistic Feature Weaving Surrogates for Multivariate Forecasting with Univariate Time Series Foundation Models}, 
      author={Jinpeng Li and Zhongyi Pei and Huaze Xue and Bojian Zheng and Chen Wang and Jianmin Wang},
      year={2026},
      eprint={2602.22066},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2602.22066}, 
}
```
