quantlab.model.predefined.transformer#

Qlib’s Transformer and Localformer benchmark models.

TransformerNet reproduces the Transformer network of qlib/contrib/model/pytorch_transformer_ts.py (Vaswani et al., “Attention Is All You Need”, 2017) and LocalformerNet the one of pytorch_localformer_ts.py (Jiang et al.), which adds a convolution beside every encoder layer and a GRU after the encoder. TransformerRegressor and LocalformerRegressor train them with Qlib’s time-series regimen (QlibSequenceHead) and its defaults, which the Alpha158 benchmark config keeps.

Classes

LocalformerEncoder

Qlib's Localformer encoder: each layer reads its input plus a convolution of it.

LocalformerNet

Qlib's Localformer (pytorch_localformer_ts.py) with an output of any width.

LocalformerRegressor

Qlib's Localformer benchmark model on (bar, symbol) samples.

PositionalEncoding

Qlib's sinusoidal position encoding of time-major [N, B, D] input.

TransformerNet

Qlib's Transformer (pytorch_transformer_ts.py) with an output of any width.

TransformerRegressor

Qlib's Transformer benchmark model on (bar, symbol) samples.