NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
Transformer-XL PyTorch checkpoint (Large, AMP)
Model
NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
Transformer-XL PyTorch checkpoint (Large, AMP)

Tranformer-XL Large PyTorch checkpoint trained with AMP

Model Overview

Transformer-XL is a transformer-based language model with a segment-level recurrence and a novel relative positional encoding.

Model Architecture

The Transformer-XL "base" model for WikiText-103 dataset available in this repository was modified to use the following hyperparameter values:

HyperparameterDescriptionOriginal setting for the base modelOur modification for the base model
d_modelhidden size410512
n_headnumber of attention heads108
d_headsize of each attention head4164
d_innerhidden size in fully-connected layers21002048
tgt_lennumber of tokens to predict during training150192
mem_lennumber of tokens cached from previous iterations during training150192

Changes described above were made to align certain hyperparameters with powers of two, with this modification, the model is able to achieve better hardware utilization, and therefore higher training throughput.

The Transformer-XL "large" model for WikiText-103 dataset available in this repository uses the original hyperparameters from the reference implementation.

The following table lists the hyperparameters for the large and the base Transformer-XL models for WikiText-103 dataset available in this repository.

HyperparameterDescriptionBase modelLarge model
n_layernumber of layers1618
d_modelhidden size5121024
n_headnumber of attention heads816
d_headsize of each attention head6464
d_innerinner hidden size in fully-connected layers20484096
dropoutdropout0.10.2
dropattdropout after softmax in the attention0.00.2
lrbase learning rate0.010.01
eta_minminimum learning rate (for cosine decay)0.0010.0001
max_stepnumber of training steps40,000100,000
warmup_stepnumber of learning rate warmup steps1,00016,000
batch_sizetraining batch size256128
tgt_lennumber of tokens to predict during training192384
mem_lennumber of tokens cached from previous iterations during training192384

The Transformer-XL model addresses the limitations of vanilla transformer-based language models, which are only able to use relatively short context, bounded by the segment length. The Transformer-XL introduces a recurrence mechanism, which is able to use a cached hidden state from previous segments. During training, the context consists of a concatenation of current segment's hidden state and cached states from previous iterations. Gradients are backpropagated only through the current segment, although the model is able to take advantage of the extra information stored in the cache and therefore is able to model long-term dependencies.

An illustration of the recurrence mechanism taken from the Transformer-XL paper is shown below. model

Training

This model was trained using script available on NGC and in GitHub repo.

Dataset

The following datasets were used to train this model:

  • WikiText-103 - A collection of over 100 million tokens extracted from the set of verified Good and Featured articles on Wikipedia.

Performance

Performance numbers for this model are available in NGC.

References

License

This model was trained using open-source software available in Deep Learning Examples repository. For terms of use, please refer to the license of the script and the datasets the model was derived from.

Publisher
NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
Latest Version19.11.0_amp
UpdatedApril 4, 2023 UTC
Compressed Size3.2 GB
Labels

NVIDIA uses cookies to improve your experience on our web site. We and our third-party partners also use cookies and other tools to collect and record information you provide as well as information about your interactions with our websites for performance improvement, analytics, and to assist in marketing efforts. By clicking "Accept All", you consent to our use of cookies and other tools as described in our Cookie Policy. You can manage your cookie settings by clicking on "Manage Settings." By continuing to use this site or by clicking one of the buttons below, you agree to our Terms of Service (which contains important waivers). Please see our Privacy Policy for more information on our privacy practices.