• Stars
    star
    100
  • Rank 340,703 (Top 7 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pyraformer: Low-complexity Pyramidal Attention for Long-range Time Series Modeling and Forecasting

This is the Pytorch implementation of Pyraformer (Pyramidal Attention based Transformer) in the ICLR paper: Pyraformer: Low-complexity Pyramidal Attention for Long-range Time Series Modeling and Forecasting.

The network architecture of Pyraformer.

Figure 1. The network architecture of Pyraformer.

Pyramidal Attention

As demonstrated in Figure 2, we leverage a pyramidal graph to describe the temporal dependencies of the observed time series in a multiresolution fashion. We can decompose the pyramidal graph into two parts: the inter-scale and the intra-scale connections. The inter-scale connections form a C-ary tree, in which each parent has C children. For example, if we associate the finest scale of the pyramidal graph with hourly observations of the original time series, the nodes at coarser scales can be regarded as the daily, weekly, and even monthly features of the time series. As a consequence, the pyramidal graph offers a multiresolution representation of the original time series. Furthermore, it is easier to capture long-range dependencies (e.g., monthly dependence) in the coarser scales by simply connecting the neighboring nodes via the intra-scale connections. In other words, the coarser scales are instrumental in describing long-range correlations in a manner that is graphically far more parsimonious than could be solely captured with a single, finest scale model.

The Pyramidal Attention Mechanism.

Figure 2. The Pyramidal Attention Mechanism.

Requirements

  • Ubuntu OS
  • Python 3.7
  • pytorch 1.8.0
  • CUDA 11.1
  • TVM 0.8.0 (optional)

Dependencies can be installed by:

pip install -r requirements.txt

If you are using CUDA 11.1, you can use the compiled TVM runtime version in the our code to run PAM-TVM. Due to the short history length in the experiments, PAM-TVM does not provide a speed increase. If you want to compile our PAM-TVM kernel yourself, see here to compile TVM 0.8.0 first.

Data preparetion

The four datasets (Electricity, Wind, ETT and App Flow) used in this paper can be downloaded from the following links:

The downloaded datasets can be put in the 'data' directory. For single step forecasting, we preprocess Electricity, Wind and App Flow using scripts preprocess_elect.py, preprocess_wind.py and preprocess_flow.py respectively. You can also download preprocessed data here. and put them in the 'data' directory. The directory structure looks like:

${CODE_ROOT}
    ......
    |-- data
        |-- elect
            |-- test_data_elect.npy
            |-- train_data_elect.npy
            ......
        |-- flow
            ......
        |-- wind
            ......
        |-- ETT
            |-- ETTh1.csv
            |-- ETTh2.csv
            |-- ETTm1.csv
            |-- ETTm2.csv
        |-- LD2011_2014.txt
        |-- synthetic.npy

Where synthetic.npy is generated by running:

python simulate_sin.py

Training

To perform long-range forecasting, run:

sh scripts/Pyraformer_LR_FC.sh

To perform single step forecasting, run:

sh scripts/Pyraformer_SS.sh

The meaning of each command line argument is explained in long_range_main.py and single_step_main.py, respectively.

Evaluate

Evaluation can be done by adding the -eval option to the command line. We provide pretrained models here. The downloaded models should be put in the 'models' directory. The directory structure is as follows:

${CODE_ROOT}
    ......
    |-- models
        |-- LongRange
            |-- elect
                |-- 168
                    |-- best_iter0.pth
                    |-- best_iter1.pth
                    |-- best_iter2.pth
                    |-- best_iter3.pth
                    |-- best_iter4.pth
                |-- 336
                    ......
                |-- 720
                    ......
            |-- ETTh1
                ......
            |-- ETTm1
                ......
        |-- SingleStep
            |-- elect
                |-- best_model.pth
            |-- flow
                |-- best_model.pth
            |-- wind
                |-- best_model.pth

Below are evaluation examples:

python long_range_main.py -data ETTh1 -input_size 168 -predict_step 168 -n_head 6 -eval

python single_step_main.py -data_path data/elect/ -dataset elect -eval

Citation

@inproceedings{liu2022pyraformer,
title={Pyraformer: Low-Complexity Pyramidal Attention for Long-Range Time Series Modeling and Forecasting},
author={Liu, Shizhan and Yu, Hang and Liao, Cong and Li, Jianguo and Lin, Weiyao and Liu, Alex X and Dustdar, Schahram},
booktitle={International Conference on Learning Representations},
year={2022}
}

Contact

For any questions w.r.t. Pyraformer, please submit them to Github Issues.

If you have interests in business cooperation with us or using our time-series forecasting products, please scan the QR code below and join our DingTalk customer group. A Chinese version introdution of Pyraformer and its practical applications can be found at https://mp.weixin.qq.com/s/kNvQOSEIv0itiqeN-EDKxw.

钉钉客户群

More Repositories

1

SoloPi

SoloPi 自动化测试工具
Java
5,736
star
2

alipay-easysdk

Alipay Easy SDK for multi-language(java、c#、php、ts etc.) allows you to enjoy a minimalist programming experience and quickly access the various high-frequency capabilities of the Alipay Open Platform.
Java
1,099
star
3

agentUniverse

agentUniverse is a LLM multi-agent framework that allows developers to easily build multi-agent applications.
Python
799
star
4

alipay-sdk-java-all

支付宝开放平台 Alipay SDK for Java
Java
521
star
5

alipay-sdk-nodejs-all

支付宝开放平台 Alipay SDK for Node.js
TypeScript
408
star
6

mPaaS

mPaaS Demo 合集,mPaaS 是源自于支付宝的移动开发平台。The collection of demos for mPaaS components. mPaaS is the Mobile Development Platform which oriented from Alipay.
C
323
star
7

ant-application-security-testing-benchmark

xAST评价体系,让安全工具不再“黑盒”. The xAST evaluation benchmark makes security tools no longer a "black box".
Java
301
star
8

PainlessInferenceAcceleration

Python
283
star
9

alipay-sdk-python-all

支付宝开放平台 Alipay SDK for Python
Python
268
star
10

Owfuzz

Owfuzz: a WiFi protocol fuzzing tool
C
216
star
11

alipay-sdk-net-all

支付宝开放平台 Alipay SDK for .NET
C#
200
star
12

cvpr2020-plant-pathology

Python
170
star
13

antcloud-node-stack

蚂蚁金融科技官方 Node 技术栈脚本
JavaScript
159
star
14

financial_evaluation_dataset

Python
154
star
15

rdf-file

Rdf-File是一个处理结构化文本文件的工具组件
Java
149
star
16

alipay-sdk-php-all

支付宝开放平台 Alipay SDK for PHP
PHP
146
star
17

SOFAStack

SOFAStack™ (Scalable Open Financial Architecture Stack) is a collection of cloud native middleware components, which are designed to build distributed systems with high performance and reliability, and have been fully validated by mission-critical financial business scenarios.
139
star
18

Ant-Multi-Modal-Framework

Research Code for Multimodal-Cognition Team in Ant Group
Python
117
star
19

vsag

vsag is a vector indexing library used for similarity search.
C++
115
star
20

container-observability-service

Simplify Kubernetes applications operation with one-stop observability services, including resource delivery SLO,root cause diagnoses and container lifecycle tracing and more.
Go
88
star
21

ios-malicious-bithunter

iOS Malicious Bit Hunter is a malicious plug-in detection engine for iOS applications. It can analyze the head of the macho file of the injected dylib dynamic library based on runtime. If you are interested in other programs of the author, please visit https://github.com/SecurityLife
C
83
star
22

goldfish

A development framework for Alipay Mini Program.
TypeScript
80
star
23

SQLFlow

SQLFlow is a bridge that connects a SQL engine, e.g. MySQL, Hive, SparkSQL or SQL Server, with TensorFlow and other machine learning toolkits. SQLFlow extends the SQL language to enable model training, prediction and inference.
73
star
24

KnowledgeGraphEmbeddingsViaPairedRelationVectors_PairRE

Python
61
star
25

Antchain-MPC

Antchain-MPC is a library of MPC (Multi-Parties Computation)
Terra
57
star
26

VCSL

Video Copy Segment Localization (VCSL) dataset and benchmark [CVPR2022]
Python
49
star
27

StructuredLM_RTDT

A library for building hierarchical text representation and corresponding downstream applications.
Python
48
star
28

RJU_Ant_QA

The RJUA-QA (RenJi hospital department of Urology and Antgroup collaborative Question and Answer dataset) is an innovative medical urology specialty QA inference dataset.
47
star
29

Z-RareCharacterSolution

TypeScript
45
star
30

quic-lb

nginx-quic-lb is an implementation of ietf-quic-lb, based on nginx-release-1.18.0, you can see the detailed code in this pull request
C
41
star
31

jpmml-sparkml-lightgbm

JPMML-SparkML plugin for converting LightGBM-Spark models to PMML
Java
41
star
32

PASE

C
41
star
33

global-open-sdk-java

Ant global gateway SDK
Java
35
star
34

container-auto-tune

Container Auto Tune is an intelligent parameter tuning product that helps developers, operators automatically adjust the application, analyzes JVM reasonable configuration parameters through intelligent algorithms.Please visit the official site for the quick start guide and documentation.
Java
32
star
35

promo-mini-component

支付宝营销玩法小程序组件库
JavaScript
31
star
36

private_llm

Python
28
star
37

tls13-sm-spec

IETF Internet-Draft (I-D) of Chinese cipher suites in TLSv1.3 and related documentation.
Makefile
27
star
38

microservice_system_twin_graph_based_anomaly_detection

Python
26
star
39

mobile-agent

Python
26
star
40

alipay-intellij-plugin

Intellij IDEA Plugin
20
star
41

character-js

TypeScript
19
star
42

global-open-sdk-php

Ant global gateway SDK
PHP
17
star
43

ams-java-sdk

AMS Java binding
Java
13
star
44

antchain-openapi-prod-sdk

PHP
10
star
45

Pattern-Based-Compression

High-Ratio Compression for Machine-Generated Data
C
10
star
46

global-open-sdk-python

Ant global gateway SDK
Python
10
star
47

PC2-NoiseofWeb

Noise of Web (NoW) is a challenging noisy correspondence learning (NCL) benchmark containing 100K image-text pairs for robust image-text matching/retrieval models.
Python
9
star
48

YiJian-Community

YiJian-Comunity: a full-process automated large model safety evaluation tool designed for academic research
Python
9
star
49

AOP-Based-Runtime-Security-Analysis-Toolkit

TypeScript
8
star
50

ant-application-security-testing-benchmark-nodejs

JavaScript
8
star
51

agentUniverse-Guides

8
star
52

RGSL

Python
8
star
53

POA

Python
7
star
54

payment-code-widget

A lightweight library provides UI widgets to display payment code in mobile applications. The dimension of the payment code is optimal and scanner-friendly.
Java
6
star
55

TDEER

Code For TDEER: An Efficient Translating Decoding Schema for Joint Extraction of Entities and Relations (EMNLP 2021)
Python
5
star
56

Finite_State_Autoregressive_Entropy_Coding

Python
5
star
57

ComBERT

4
star
58

Parameter_Inference_Efficient_PIE

Python
4
star
59

NMCDR

Python
4
star
60

A2-efficient-automated-attacker-for-boosting-adversarial-training

Python
4
star
61

global-open-sdk-dotnet

C#
3
star
62

tldk

This is a fork of FDio/tldk.
C
3
star
63

DUPLEX

Python
3
star
64

antchain-openapi-util-sdk

C#
3
star
65

Automatic_AI_Model_Greenness_Track_Toolkit

JavaScript
3
star
66

style-tokenizer

Python
3
star
67

Timestep-aware-SentenceEmbedding-and-AcmeCoverage

Python
2
star
68

ATTEMPT_Pre-training_with_Aspect-Content_Text_Mutual_Prediction

Python
2
star
69

hypro_tpp

Python
1
star
70

BehaviorAugmentedRelevanceModel

Implementation and data of the paper "Beyond Semantics: Learning a Behavior Augmented Relevance Model with Self-supervised Learning" in CIKM'23.
Python
1
star
71

A-Knowledge-augmented-Method-DiKGRS

Python
1
star
72

Analogic-Reasoning-Augmented-Large-Language-Model

Python
1
star
73

MMDL-based-Data-Augmentation-with-Domain-Knowledge-for-Time-Series-Classification

This repository contains the official implementation for the paper: MMDL-based Data Augmentation with Domain Knowledge for Time Series Classification.
Python
1
star