Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time series forecasting model #17965

Merged
merged 172 commits into from Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
2ebd575
initial files
kashif Jun 30, 2022
cc0b364
initial model via cli
kashif Jun 30, 2022
cf60b95
typos
kashif Jul 1, 2022
b18d345
make a start on the model config
kashif Jul 1, 2022
eb328f5
ready with configuation
kashif Jul 1, 2022
8e664f4
remove tokenizer ref.
kashif Jul 1, 2022
e078e09
init the transformer
kashif Jul 1, 2022
972cc89
added initial model forward to return dec_output
kashif Jul 1, 2022
cf74608
require gluonts
kashif Jul 3, 2022
c7b8158
update dep. ver table and add as extra
kashif Jul 3, 2022
dba022c
fixed typo
kashif Jul 3, 2022
44c9944
Merge remote-tracking branch 'upstream/main' into time-series
kashif Jul 4, 2022
29bcc72
add type for prediction_length
kashif Jul 4, 2022
6f3f627
use num_time_features
kashif Jul 4, 2022
97fbcf4
use config
kashif Jul 4, 2022
62286aa
more config
kashif Jul 4, 2022
88e071b
typos
kashif Jul 4, 2022
3e01a69
opps another typo
kashif Jul 4, 2022
202dab0
freq can be none
kashif Jul 5, 2022
489d7f1
default via transformation is 1
kashif Jul 5, 2022
d5f6eb3
initial transformations
kashif Jul 5, 2022
302a387
fix imports
kashif Jul 5, 2022
669aeeb
added transform_start_field
kashif Jul 5, 2022
6c339d8
add helper to create pytorch dataloader
kashif Jul 6, 2022
43ffcf1
added inital val and test data loader
kashif Jul 7, 2022
1525a1a
added initial distr head and loss
kashif Jul 7, 2022
3fa6d48
training working
kashif Jul 7, 2022
956f369
remove TimeSeriesTransformerTokenizer
kashif Jul 8, 2022
9322bb1
Update src/transformers/__init__.py
kashif Jul 8, 2022
2babbe9
Update src/transformers/models/time_series_transformer/__init__.py
kashif Jul 8, 2022
1dc5e85
fixed copyright
kashif Jul 11, 2022
7d6732f
removed docs
kashif Jul 11, 2022
e113de5
remove time series tokenizer
kashif Jul 11, 2022
800b452
fixed docs
kashif Jul 12, 2022
16109a7
fix text
kashif Jul 12, 2022
bcff605
fix second
kashif Jul 12, 2022
cce6973
fix default
kashif Jul 12, 2022
216c206
fix order
kashif Jul 13, 2022
8dae3cf
use config directly
kashif Jul 13, 2022
9afbac2
undo change
kashif Jul 13, 2022
2c06f97
fix comment
kashif Jul 13, 2022
050b8b5
fix year
kashif Jul 13, 2022
d086185
fix import
kashif Jul 15, 2022
dc2acd4
add additional arguments for training vs. test
kashif Jul 15, 2022
758b90d
initial greedy inference loop
kashif Jul 15, 2022
c9f8540
fix inference
kashif Jul 15, 2022
97d6743
comment out token inputs to enc dec
kashif Jul 21, 2022
b512c50
Use HF encoder/decoder
kashif Aug 7, 2022
7f332f2
fix inference
kashif Aug 7, 2022
3bce7cc
Use Seq2SeqTSModelOutput output
kashif Aug 9, 2022
3577729
return Seq2SeqTSPredictionOutput
kashif Aug 10, 2022
8f7d803
added default arguments
kashif Aug 10, 2022
c90c126
fix return_dict true
kashif Aug 10, 2022
63d709a
scale is a tensor
kashif Aug 10, 2022
bcd566f
output static_features for inference
kashif Aug 12, 2022
6c6a57b
clean up some unused bits
kashif Aug 12, 2022
5346712
fixed typo
kashif Aug 12, 2022
6ef3a59
set return_dict if none
kashif Aug 12, 2022
ec4ab0f
call model once for both train/predict
kashif Aug 12, 2022
87a8f1b
use cache if future_target is none
kashif Aug 12, 2022
01343f7
initial generate func
kashif Aug 14, 2022
be1f132
generate arguments
kashif Aug 15, 2022
3cbfd7b
future_time_feat is required
kashif Aug 15, 2022
89e9279
return SampleTSPredictionOutput
kashif Aug 17, 2022
686db78
removed unneeded classes
kashif Aug 18, 2022
336fb95
fix when params is none
kashif Aug 18, 2022
4623d2d
fix return dict
kashif Aug 18, 2022
035f016
fix num_attention_heads
kashif Aug 18, 2022
8e2c2fa
fix arguments
kashif Aug 18, 2022
ccdf048
remove unused shift_tokens_right
kashif Aug 18, 2022
9cbb500
add different dropout configs
kashif Aug 19, 2022
996911a
implement FeatureEmbedder, Scaler and weighted_average
kashif Sep 3, 2022
54460c7
remove gluonts dependency
kashif Sep 5, 2022
21dc3cd
fix class names
kashif Sep 5, 2022
9763a3e
avoid _variable names
kashif Sep 5, 2022
3dab2e1
remove gluonts dependency
kashif Sep 6, 2022
27f1349
fix imports
kashif Sep 6, 2022
72f9a27
remove gluonts from configuration
kashif Sep 6, 2022
949b82a
fix docs
kashif Sep 6, 2022
2eaf401
fixed typo
kashif Sep 8, 2022
924f1bd
move utils to examples
kashif Sep 8, 2022
4b955b4
add example requirements
kashif Sep 8, 2022
5dfa7c7
config has no freq
kashif Sep 8, 2022
7e02a57
initial run_ts_no_trainer
kashif Sep 12, 2022
1b166ab
remove from ignore
kashif Sep 22, 2022
de106a9
Merge remote-tracking branch 'upstream/main' into time-series
kashif Sep 22, 2022
727982a
fix output_attentions and removed unsued getters/setters
kashif Sep 22, 2022
84c77ad
removed unsed tests
kashif Sep 22, 2022
06679dd
add dec seq len
kashif Sep 22, 2022
8656275
add test_attention_outputs
kashif Sep 22, 2022
f4465b7
set has_text_modality=False
kashif Sep 22, 2022
93d0289
add config attribute_map
kashif Sep 22, 2022
19f188f
make style
kashif Sep 23, 2022
444ba89
make fix-copies
kashif Sep 23, 2022
d639388
add encoder_outputs to TimeSeriesTransformerForPrediction forward
kashif Sep 23, 2022
8cbe681
Improve docs, add model to README
NielsRogge Sep 23, 2022
c658f03
added test_forward_signature
kashif Sep 23, 2022
13de9c6
More improvements
NielsRogge Sep 23, 2022
649373f
Add more copied from
NielsRogge Sep 23, 2022
08d81f5
Fix README
NielsRogge Sep 23, 2022
390db66
Fix remaining quality issues
NielsRogge Sep 23, 2022
ca37eda
Merge branch 'time-series' into time-series
kashif Sep 23, 2022
ff878eb
Merge pull request #1 from NielsRogge/time-series
kashif Sep 23, 2022
973baf3
updated encoder and decoder
kashif Sep 23, 2022
ea138ff
fix generate
kashif Sep 23, 2022
9076757
output_hidden_states and use_cache are optional
kashif Sep 23, 2022
409a88a
past key_values returned too
kashif Sep 23, 2022
ed6b62a
initialize weights of distribution_output module
kashif Sep 23, 2022
1ef37e4
fixed more tests
kashif Sep 23, 2022
b6b6be3
update test_forward_signature
kashif Sep 26, 2022
0e7d3ed
fix return_dict outputs
kashif Sep 26, 2022
eb3ef8a
Update src/transformers/models/time_series_transformer/configuration_…
kashif Sep 26, 2022
ab05cf5
Update src/transformers/models/time_series_transformer/configuration_…
kashif Sep 26, 2022
60a63bf
Update src/transformers/models/time_series_transformer/configuration_…
kashif Sep 26, 2022
e8663f0
Update src/transformers/models/time_series_transformer/configuration_…
kashif Sep 26, 2022
4b46121
Update src/transformers/models/time_series_transformer/modeling_time_…
kashif Sep 26, 2022
3ab0bfd
Update src/transformers/models/time_series_transformer/modeling_time_…
kashif Sep 26, 2022
ac3e8d8
Update src/transformers/models/time_series_transformer/modeling_time_…
kashif Sep 26, 2022
9d9ed9a
removed commented out tests
kashif Sep 27, 2022
d631896
added neg. bin and normal output
kashif Sep 27, 2022
1618126
Update src/transformers/models/time_series_transformer/configuration_…
kashif Sep 27, 2022
70cfbce
move to one line
kashif Sep 27, 2022
678f297
Add docstrings
NielsRogge Sep 27, 2022
4d6bd2b
Update src/transformers/models/time_series_transformer/configuration_…
kashif Sep 27, 2022
7174391
add try except for assert and raise
kashif Sep 27, 2022
58d368b
try and raise exception
kashif Sep 27, 2022
319011b
fix the documentation formatting
kashif Sep 27, 2022
ecbf682
fix assert call
kashif Sep 27, 2022
74fd969
fix docstring formatting
kashif Sep 27, 2022
21d2ba9
removed input_ids from DOCSTRING
kashif Sep 27, 2022
d995f4b
Update input docstring
NielsRogge Sep 27, 2022
9d8914f
Improve variable names
NielsRogge Sep 27, 2022
e995a3f
Merge branch 'time-series' into time-series
NielsRogge Sep 28, 2022
bbf49a3
Update order of inputs
NielsRogge Sep 28, 2022
1358e79
Merge branch 'time-series' of github.com:NielsRogge/transformers into…
NielsRogge Sep 28, 2022
f44aad5
Improve configuration
NielsRogge Sep 28, 2022
4e1d1f6
Improve variable names
NielsRogge Sep 28, 2022
6ceed7c
Improve docs
NielsRogge Sep 28, 2022
b7ce766
Remove key_length from tests
NielsRogge Sep 28, 2022
bac12b9
Add extra docs
NielsRogge Sep 28, 2022
62194a5
Merge pull request #2 from NielsRogge/time-series
kashif Sep 28, 2022
de88260
initial unittests
kashif Sep 28, 2022
4f858f3
added test_inference_no_head test
kashif Sep 28, 2022
3d05dad
added test_inference_head
kashif Sep 28, 2022
93ff659
add test_seq_to_seq_generation
kashif Sep 28, 2022
2339a53
make style
kashif Sep 28, 2022
4c05158
one line
kashif Sep 28, 2022
0df5859
assert mean prediction
kashif Sep 28, 2022
d31c0de
removed comments
kashif Sep 28, 2022
0827fbe
Update src/transformers/models/time_series_transformer/modeling_time_…
kashif Sep 29, 2022
c8b56cc
Update src/transformers/models/time_series_transformer/modeling_time_…
kashif Sep 29, 2022
a2043c1
fix order of args
kashif Sep 29, 2022
bc5aaa9
Merge remote-tracking branch 'upstream/main' into time-series
kashif Sep 29, 2022
a895801
make past_observed_mask optional as well
kashif Sep 30, 2022
6840145
added Amazon license header
kashif Sep 30, 2022
2ec916e
updated utils with new fieldnames
kashif Sep 30, 2022
ffb319f
make style
kashif Sep 30, 2022
6649b29
cleanup
kashif Sep 30, 2022
006a802
undo position of past_observed_mask
kashif Sep 30, 2022
fcd48cd
fix import
kashif Sep 30, 2022
4ebc370
typo
kashif Sep 30, 2022
2ab53bc
more typo
kashif Sep 30, 2022
78cd493
rename example files
kashif Sep 30, 2022
4a7f8c9
remove example for now
kashif Sep 30, 2022
cb66357
Update docs/source/en/_toctree.yml
kashif Sep 30, 2022
4fe63fe
Update src/transformers/models/time_series_transformer/configuration_…
kashif Sep 30, 2022
b28a2f9
Update src/transformers/models/time_series_transformer/modeling_time_…
kashif Sep 30, 2022
8a3e430
Update src/transformers/models/time_series_transformer/modeling_time_…
kashif Sep 30, 2022
f7b0ab5
Update modeling_time_series_transformer.py
kashif Sep 30, 2022
4fe8164
fixed typo
kashif Sep 30, 2022
48a2be4
fix typo and grammer
kashif Sep 30, 2022
43dd269
fix style
kashif Sep 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -373,6 +373,7 @@ Current number of checkpoints: ![](https://img.shields.io/endpoint?url=https://h
1. **[T5v1.1](https://huggingface.co/docs/transformers/model_doc/t5v1.1)** (from Google AI) released in the repository [google-research/text-to-text-transfer-transformer](https://github.com/google-research/text-to-text-transfer-transformer/blob/main/released_checkpoints.md#t511) by Colin Raffel and Noam Shazeer and Adam Roberts and Katherine Lee and Sharan Narang and Michael Matena and Yanqi Zhou and Wei Li and Peter J. Liu.
1. **[TAPAS](https://huggingface.co/docs/transformers/model_doc/tapas)** (from Google AI) released with the paper [TAPAS: Weakly Supervised Table Parsing via Pre-training](https://arxiv.org/abs/2004.02349) by Jonathan Herzig, Paweł Krzysztof Nowak, Thomas Müller, Francesco Piccinno and Julian Martin Eisenschlos.
1. **[TAPEX](https://huggingface.co/docs/transformers/model_doc/tapex)** (from Microsoft Research) released with the paper [TAPEX: Table Pre-training via Learning a Neural SQL Executor](https://arxiv.org/abs/2107.07653) by Qian Liu, Bei Chen, Jiaqi Guo, Morteza Ziyadi, Zeqi Lin, Weizhu Chen, Jian-Guang Lou.
1. **[Time Series Transformer](https://huggingface.co/docs/transformers/main/model_doc/time_series_transformer)** (from HuggingFace).
1. **[Trajectory Transformer](https://huggingface.co/docs/transformers/model_doc/trajectory_transformers)** (from the University of California at Berkeley) released with the paper [Offline Reinforcement Learning as One Big Sequence Modeling Problem](https://arxiv.org/abs/2106.02039) by Michael Janner, Qiyang Li, Sergey Levine
1. **[Transformer-XL](https://huggingface.co/docs/transformers/model_doc/transfo-xl)** (from Google/CMU) released with the paper [Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context](https://arxiv.org/abs/1901.02860) by Zihang Dai*, Zhilin Yang*, Yiming Yang, Jaime Carbonell, Quoc V. Le, Ruslan Salakhutdinov.
1. **[TrOCR](https://huggingface.co/docs/transformers/model_doc/trocr)** (from Microsoft), released together with the paper [TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models](https://arxiv.org/abs/2109.10282) by Minghao Li, Tengchao Lv, Lei Cui, Yijuan Lu, Dinei Florencio, Cha Zhang, Zhoujun Li, Furu Wei.
Expand Down
1 change: 1 addition & 0 deletions README_ko.md
Expand Up @@ -323,6 +323,7 @@ Flax, PyTorch, TensorFlow 설치 페이지에서 이들을 conda로 설치하는
1. **[T5v1.1](https://huggingface.co/docs/transformers/model_doc/t5v1.1)** (from Google AI) released in the repository [google-research/text-to-text-transfer-transformer](https://github.com/google-research/text-to-text-transfer-transformer/blob/main/released_checkpoints.md#t511) by Colin Raffel and Noam Shazeer and Adam Roberts and Katherine Lee and Sharan Narang and Michael Matena and Yanqi Zhou and Wei Li and Peter J. Liu.
1. **[TAPAS](https://huggingface.co/docs/transformers/model_doc/tapas)** (from Google AI) released with the paper [TAPAS: Weakly Supervised Table Parsing via Pre-training](https://arxiv.org/abs/2004.02349) by Jonathan Herzig, Paweł Krzysztof Nowak, Thomas Müller, Francesco Piccinno and Julian Martin Eisenschlos.
1. **[TAPEX](https://huggingface.co/docs/transformers/model_doc/tapex)** (from Microsoft Research) released with the paper [TAPEX: Table Pre-training via Learning a Neural SQL Executor](https://arxiv.org/abs/2107.07653) by Qian Liu, Bei Chen, Jiaqi Guo, Morteza Ziyadi, Zeqi Lin, Weizhu Chen, Jian-Guang Lou.
1. **[Time Series Transformer](https://huggingface.co/docs/transformers/main/model_doc/time_series_transformer)** (from HuggingFace).
1. **[Trajectory Transformer](https://huggingface.co/docs/transformers/model_doc/trajectory_transformers)** (from the University of California at Berkeley) released with the paper [Offline Reinforcement Learning as One Big Sequence Modeling Problem](https://arxiv.org/abs/2106.02039) by Michael Janner, Qiyang Li, Sergey Levine
1. **[Transformer-XL](https://huggingface.co/docs/transformers/model_doc/transfo-xl)** (from Google/CMU) released with the paper [Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context](https://arxiv.org/abs/1901.02860) by Zihang Dai*, Zhilin Yang*, Yiming Yang, Jaime Carbonell, Quoc V. Le, Ruslan Salakhutdinov.
1. **[TrOCR](https://huggingface.co/docs/transformers/model_doc/trocr)** (from Microsoft), released together with the paper [TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models](https://arxiv.org/abs/2109.10282) by Minghao Li, Tengchao Lv, Lei Cui, Yijuan Lu, Dinei Florencio, Cha Zhang, Zhoujun Li, Furu Wei.
Expand Down
1 change: 1 addition & 0 deletions README_zh-hans.md
Expand Up @@ -347,6 +347,7 @@ conda install -c huggingface transformers
1. **[T5v1.1](https://huggingface.co/docs/transformers/model_doc/t5v1.1)** (来自 Google AI) 伴随论文 [google-research/text-to-text-transfer-transformer](https://github.com/google-research/text-to-text-transfer-transformer/blob/main/released_checkpoints.md#t511) 由 Colin Raffel and Noam Shazeer and Adam Roberts and Katherine Lee and Sharan Narang and Michael Matena and Yanqi Zhou and Wei Li and Peter J. Liu 发布。
1. **[TAPAS](https://huggingface.co/docs/transformers/model_doc/tapas)** (来自 Google AI) 伴随论文 [TAPAS: Weakly Supervised Table Parsing via Pre-training](https://arxiv.org/abs/2004.02349) 由 Jonathan Herzig, Paweł Krzysztof Nowak, Thomas Müller, Francesco Piccinno and Julian Martin Eisenschlos 发布。
1. **[TAPEX](https://huggingface.co/docs/transformers/model_doc/tapex)** (来自 Microsoft Research) 伴随论文 [TAPEX: Table Pre-training via Learning a Neural SQL Executor](https://arxiv.org/abs/2107.07653) 由 Qian Liu, Bei Chen, Jiaqi Guo, Morteza Ziyadi, Zeqi Lin, Weizhu Chen, Jian-Guang Lou 发布。
1. **[Time Series Transformer](https://huggingface.co/docs/transformers/main/model_doc/time_series_transformer)** (from HuggingFace).
1. **[Trajectory Transformer](https://huggingface.co/docs/transformers/model_doc/trajectory_transformers)** (from the University of California at Berkeley) released with the paper [Offline Reinforcement Learning as One Big Sequence Modeling Problem](https://arxiv.org/abs/2106.02039) by Michael Janner, Qiyang Li, Sergey Levine
1. **[Transformer-XL](https://huggingface.co/docs/transformers/model_doc/transfo-xl)** (来自 Google/CMU) 伴随论文 [Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context](https://arxiv.org/abs/1901.02860) 由 Zihang Dai*, Zhilin Yang*, Yiming Yang, Jaime Carbonell, Quoc V. Le, Ruslan Salakhutdinov 发布。
1. **[TrOCR](https://huggingface.co/docs/transformers/model_doc/trocr)** (来自 Microsoft) 伴随论文 [TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models](https://arxiv.org/abs/2109.10282) 由 Minghao Li, Tengchao Lv, Lei Cui, Yijuan Lu, Dinei Florencio, Cha Zhang, Zhoujun Li, Furu Wei 发布。
Expand Down
1 change: 1 addition & 0 deletions README_zh-hant.md
Expand Up @@ -359,6 +359,7 @@ conda install -c huggingface transformers
1. **[T5v1.1](https://huggingface.co/docs/transformers/model_doc/t5v1.1)** (from Google AI) released with the paper [google-research/text-to-text-transfer-transformer](https://github.com/google-research/text-to-text-transfer-transformer/blob/main/released_checkpoints.md#t511) by Colin Raffel and Noam Shazeer and Adam Roberts and Katherine Lee and Sharan Narang and Michael Matena and Yanqi Zhou and Wei Li and Peter J. Liu.
1. **[TAPAS](https://huggingface.co/docs/transformers/model_doc/tapas)** (from Google AI) released with the paper [TAPAS: Weakly Supervised Table Parsing via Pre-training](https://arxiv.org/abs/2004.02349) by Jonathan Herzig, Paweł Krzysztof Nowak, Thomas Müller, Francesco Piccinno and Julian Martin Eisenschlos.
1. **[TAPEX](https://huggingface.co/docs/transformers/model_doc/tapex)** (from Microsoft Research) released with the paper [TAPEX: Table Pre-training via Learning a Neural SQL Executor](https://arxiv.org/abs/2107.07653) by Qian Liu, Bei Chen, Jiaqi Guo, Morteza Ziyadi, Zeqi Lin, Weizhu Chen, Jian-Guang Lou.
1. **[Time Series Transformer](https://huggingface.co/docs/transformers/main/model_doc/time_series_transformer)** (from HuggingFace).
1. **[Trajectory Transformer](https://huggingface.co/docs/transformers/model_doc/trajectory_transformers)** (from the University of California at Berkeley) released with the paper [Offline Reinforcement Learning as One Big Sequence Modeling Problem](https://arxiv.org/abs/2106.02039) by Michael Janner, Qiyang Li, Sergey Levine
1. **[Transformer-XL](https://huggingface.co/docs/transformers/model_doc/transfo-xl)** (from Google/CMU) released with the paper [Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context](https://arxiv.org/abs/1901.02860) by Zihang Dai*, Zhilin Yang*, Yiming Yang, Jaime Carbonell, Quoc V. Le, Ruslan Salakhutdinov.
1. **[TrOCR](https://huggingface.co/docs/transformers/model_doc/trocr)** (from Microsoft) released with the paper [TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models](https://arxiv.org/abs/2109.10282) by Minghao Li, Tengchao Lv, Lei Cui, Yijuan Lu, Dinei Florencio, Cha Zhang, Zhoujun Li, Furu Wei.
Expand Down
5 changes: 5 additions & 0 deletions docs/source/en/_toctree.yml
Expand Up @@ -492,6 +492,11 @@
- local: model_doc/trajectory_transformer
title: Trajectory Transformer
title: Reinforcement learning models
- isExpanded: false
sections:
- local: model_doc/time_series_transformer
title: Time Series Transformer
title: Time series models
title: Models
- sections:
- local: internal/modeling_utils
Expand Down
2 changes: 2 additions & 0 deletions docs/source/en/index.mdx
Expand Up @@ -163,6 +163,7 @@ The documentation is organized into five sections:
1. **[T5v1.1](model_doc/t5v1.1)** (from Google AI) released in the repository [google-research/text-to-text-transfer-transformer](https://github.com/google-research/text-to-text-transfer-transformer/blob/main/released_checkpoints.md#t511) by Colin Raffel and Noam Shazeer and Adam Roberts and Katherine Lee and Sharan Narang and Michael Matena and Yanqi Zhou and Wei Li and Peter J. Liu.
1. **[TAPAS](model_doc/tapas)** (from Google AI) released with the paper [TAPAS: Weakly Supervised Table Parsing via Pre-training](https://arxiv.org/abs/2004.02349) by Jonathan Herzig, Paweł Krzysztof Nowak, Thomas Müller, Francesco Piccinno and Julian Martin Eisenschlos.
1. **[TAPEX](model_doc/tapex)** (from Microsoft Research) released with the paper [TAPEX: Table Pre-training via Learning a Neural SQL Executor](https://arxiv.org/abs/2107.07653) by Qian Liu, Bei Chen, Jiaqi Guo, Morteza Ziyadi, Zeqi Lin, Weizhu Chen, Jian-Guang Lou.
1. **[Time Series Transformer](model_doc/time_series_transformer)** (from HuggingFace).
1. **[Trajectory Transformer](model_doc/trajectory_transformers)** (from the University of California at Berkeley) released with the paper [Offline Reinforcement Learning as One Big Sequence Modeling Problem](https://arxiv.org/abs/2106.02039) by Michael Janner, Qiyang Li, Sergey Levine
1. **[Transformer-XL](model_doc/transfo-xl)** (from Google/CMU) released with the paper [Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context](https://arxiv.org/abs/1901.02860) by Zihang Dai*, Zhilin Yang*, Yiming Yang, Jaime Carbonell, Quoc V. Le, Ruslan Salakhutdinov.
1. **[TrOCR](model_doc/trocr)** (from Microsoft), released together with the paper [TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models](https://arxiv.org/abs/2109.10282) by Minghao Li, Tengchao Lv, Lei Cui, Yijuan Lu, Dinei Florencio, Cha Zhang, Zhoujun Li, Furu Wei.
Expand Down Expand Up @@ -306,6 +307,7 @@ Flax), PyTorch, and/or TensorFlow.
| Swin Transformer V2 | ❌ | ❌ | ✅ | ❌ | ❌ |
| T5 | ✅ | ✅ | ✅ | ✅ | ✅ |
| TAPAS | ✅ | ❌ | ✅ | ✅ | ❌ |
| Time Series Transformer | ❌ | ❌ | ✅ | ❌ | ❌ |
| Trajectory Transformer | ❌ | ❌ | ✅ | ❌ | ❌ |
| Transformer-XL | ✅ | ❌ | ✅ | ✅ | ❌ |
| TrOCR | ❌ | ❌ | ✅ | ❌ | ❌ |
Expand Down
73 changes: 73 additions & 0 deletions docs/source/en/model_doc/time_series_transformer.mdx
@@ -0,0 +1,73 @@
<!--Copyright 2022 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->

# Time Series Transformer

<Tip>

This is a recently introduced model so the API hasn't been tested extensively. There may be some bugs or slight
breaking changes to fix it in the future. If you see something strange, file a [Github Issue](https://github.com/huggingface/transformers/issues/new?assignees=&labels=&template=bug-report.md&title).

</Tip>

## Overview

The Time Series Transformer model is a vanilla encoder-decoder Transformer for time series forecasting.

Tips:

- Similar to other models in the library, [`TimeSeriesTransformerModel`] is the raw Transformer without any head on top, and [`TimeSeriesTransformerForPrediction`]
adds a distribution head on top of the former, which can be used for time-series forecasting. Note that this is a so-called probabilistic forecasting model, not a
point forecasting model. This means that the model learns a distribution, from which one can sample. The model doesn't directly output values.
- [`TimeSeriesTransformerForPrediction`] consists of 2 blocks: an encoder, which takes a `context_length` of time series values as input (called `past_values`),
and a decoder, which predicts a `prediction_length` of time series values into the future (called `future_values`). During training, one needs to provide
pairs of (`past_values` and `future_values`) to the model.
- In addition to the raw (`past_values` and `future_values`), one typically provides additional features to the model. These can be the following:
- `past_time_features`: temporal features which the model will add to `past_values`. These serve as "positional encodings" for the Transformer encoder.
Examples are "day of the month", "month of the year", etc. as scalar values (and then stacked together as a vector).
e.g. if a given time-series value was obtained on the 11th of August, then one could have [11, 8] as time feature vector (11 being "day of the month", 8 being "month of the year").
- `future_time_features`: temporal features which the model will add to `future_values`. These serve as "positional encodings" for the Transformer decoder.
Examples are "day of the month", "month of the year", etc. as scalar values (and then stacked together as a vector).
e.g. if a given time-series value was obtained on the 11th of August, then one could have [11, 8] as time feature vector (11 being "day of the month", 8 being "month of the year").
- `static_categorical_features`: categorical features which are static over time (i.e., have the same value for all `past_values` and `future_values`).
An example here is the store ID or region ID that identifies a given time-series.
Note that these features need to be known for ALL data points (also those in the future).
- `static_real_features`: real-valued features which are static over time (i.e., have the same value for all `past_values` and `future_values`).
An example here is the image representation of the product for which you have the time-series values (like the [ResNet](resnet) embedding of a "shoe" picture,
if your time-series is about the sales of shoes).
Note that these features need to be known for ALL data points (also those in the future).
- The model is trained using "teacher-forcing", similar to how a Transformer is trained for machine translation. This means that, during training, one shifts the
`future_values` one position to the right as input to the decoder, prepended by the last value of `past_values`. At each time step, the model needs to predict the
next target. So the set-up of training is similar to a GPT model for language, except that there's no notion of `decoder_start_token_id` (we just use the last value
of the context as initial input for the decoder).
- At inference time, we give the final value of the `past_values` as input to the decoder. Next, we can sample from the model to make a prediction at the next time step,
which is then fed to the decoder in order to make the next prediction (also called autoregressive generation).


This model was contributed by [kashif](<https://huggingface.co/kashif).


## TimeSeriesTransformerConfig

[[autodoc]] TimeSeriesTransformerConfig


## TimeSeriesTransformerModel

[[autodoc]] TimeSeriesTransformerModel
- forward
NielsRogge marked this conversation as resolved.
Show resolved Hide resolved


## TimeSeriesTransformerForPrediction

[[autodoc]] TimeSeriesTransformerForPrediction
- forward
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -279,6 +279,7 @@ def run(self):
extras["timm"] = deps_list("timm")
extras["codecarbon"] = deps_list("codecarbon")


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) normally this file shouldn't be touched by the PR

extras["sentencepiece"] = deps_list("sentencepiece", "protobuf")
extras["testing"] = (
deps_list(
Expand Down
23 changes: 23 additions & 0 deletions src/transformers/__init__.py
Expand Up @@ -328,6 +328,10 @@
"models.t5": ["T5_PRETRAINED_CONFIG_ARCHIVE_MAP", "T5Config"],
"models.tapas": ["TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP", "TapasConfig", "TapasTokenizer"],
"models.tapex": ["TapexTokenizer"],
"models.time_series_transformer": [
"TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"TimeSeriesTransformerConfig",
],
"models.trajectory_transformer": [
"TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"TrajectoryTransformerConfig",
Expand Down Expand Up @@ -805,6 +809,15 @@
_import_structure["modeling_utils"] = ["PreTrainedModel"]

# PyTorch models structure

_import_structure["models.time_series_transformer"].extend(
[
"TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
"TimeSeriesTransformerForPrediction",
"TimeSeriesTransformerModel",
"TimeSeriesTransformerPreTrainedModel",
]
)
_import_structure["models.albert"].extend(
[
"ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
Expand Down Expand Up @@ -3239,6 +3252,10 @@
from .models.t5 import T5_PRETRAINED_CONFIG_ARCHIVE_MAP, T5Config
from .models.tapas import TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP, TapasConfig, TapasTokenizer
from .models.tapex import TapexTokenizer
from .models.time_series_transformer import (
TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
TimeSeriesTransformerConfig,
)
from .models.trajectory_transformer import (
TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
TrajectoryTransformerConfig,
Expand Down Expand Up @@ -4512,6 +4529,12 @@
T5PreTrainedModel,
load_tf_weights_in_t5,
)
from .models.time_series_transformer import (
TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
TimeSeriesTransformerForPrediction,
TimeSeriesTransformerModel,
TimeSeriesTransformerPreTrainedModel,
)
from .models.trajectory_transformer import (
TRAJECTORY_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
TrajectoryTransformerModel,
Expand Down
1 change: 1 addition & 0 deletions src/transformers/models/__init__.py
Expand Up @@ -137,6 +137,7 @@
t5,
tapas,
tapex,
time_series_transformer,
trajectory_transformer,
transfo_xl,
trocr,
Expand Down