What it is used for
XLNet is used as a language understanding backbone that is then fine-tuned for one task: question answering over documents, reading comprehension, text classification, and document ranking. It is not a conversational text generator; every task its paper evaluates is an understanding task, and the use its makers publish is per-task fine-tuning of an already trained model.
Its first example is SQuAD question answering, the benchmark of answering questions from a given paragraph. At the full-data setting, its paper records XLNet reaching an F1 score of 90.6 on SQuAD 2.0, the version in which some questions genuinely have no answer, and an F1 of 95.1 on SQuAD 1.1, both single-model development numbers reported by its makers. Its second example is RACE reading comprehension, a set of English examination questions for secondary school students in China with long passages: XLNet recorded an accuracy of 85.4, and its paper notes that XLNet's gain is usually larger on reasoning tasks with longer context like this one, which in its authors' view could come from the Transformer-XL backbone inside it. Its third example is text classification: on the IMDB film review set, XLNet's error rate was 3.20 against BERT's 4.51, and on Yelp-2 reviews its error rate was 1.37 against 1.89, as its paper's table books those test results.
How to use it
Its makers released the trained models and the code openly through the project's official repository on GitHub, the same address its paper points to. XLNet-Large was released together with the code on 19 June 2019, and XLNet-Base followed on 16 July 2019; what is released is the cased form, which keeps the text's original upper and lower case. Each download file holds three things: the trained weights as a TensorFlow checkpoint, a SentencePiece model for cutting text, and a configuration file carrying the model's size and rules. A developer takes the size that fits, then fine-tunes that model on their own task data with the scripts the repository provides for each task kind, among them for SQuAD, for RACE, and for text classification. Size decides the hardware: the Large form has 24 layers with a hidden width of 1024 and 16 attention heads, while the Base form has 12 layers with a width of 768 and 12 heads.
Practitioner level
Practitioners read XLNet's numbers by their comparison setting, because its paper itself separates two settings. In the fair comparison, when XLNet-Large is trained only on the same data as BERT with the same training recipe, the result is an F1 of 94.0 on SQuAD 1.1 against BERT-Large's 92.8, an F1 of 87.8 on SQuAD 2.0 against 85.5, and a RACE accuracy of 77.4 against 75.1. At the larger full-data setting the numbers rise higher, among them a RACE accuracy of 85.4 against RoBERTa's 83.2 and MNLI 90.8 and SST-2 97.0 scores on the GLUE suite, but that setting mixes the method's advantage with more data and more computation, and the RoBERTa comparison itself was only added by its makers in the paper's January 2020 update. One caution comes from this package's secondary leg: Chris Wirz, in his open review of this paper, takes apart the paper's ablation table and judges that between 36 and 65 percent of XLNet's gain over BERT on the ablated tasks comes from the Transformer-XL architecture and its bidirectional data pipeline, not from the permutation objective itself, and that XLNet's margin over RoBERTa on the GLUE development sets averages only 0.2 points, with XLNet trailing on two of its tasks. That judgement is a reviewer's reading of the maker's own table, and it stands as a counterweight to the paper's claims, not as a new measurement.
One more practical point: the Base form the repository releases was trained on full data, unlike the Base form in the paper's experiments, so the paper's Base numbers do not automatically hold for the downloaded file. And its paper does not put forward a parameter count as a number of its own; it states that XLNet-Large uses the same architecture hyperparameters as BERT-Large, so their sizes are similar.
Expert level
Three technical decisions explain its character. First, its objective: permutation language modeling maximizes the expected log likelihood of a sequence over all permutations of its factorization order. Only the factorization order is shuffled, not the order of the sentence: the sentence stays in its original arrangement with its original position encodings, and an attention mask governs which words each guess may see. That is why the paper's own example becomes clear: on the sentence "New York is a city", XLNet's objective captures the dependency between the word pair New and York, a dependency BERT's objective leaves out because those two words are guessed as independent of each other.
Second, the two-stream attention architecture is built to remove target ambiguity. The content stream carries the word itself together with its context, while the query stream carries only the position being guessed and the earlier context, without seeing the target word's content; the two streams share the same parameters. Without this separation, the guess would be the same for every target position. Third, partial prediction: guessing every word under a shuffled order is a much heavier fitting problem, so XLNet guesses only the last words in each factorization order, with the partial prediction constant K set to 6 for the Large form, together with span-based prediction that chooses a consecutive run of one to five words as the target.
Beneath all three sits the Transformer-XL inheritance: a segment recurrence mechanism that caches the hidden states of the previous text segment for the next segment to use, relative position encodings, and relative segment encodings that replace BERT's absolute segment embeddings with a mark of whether two positions lie in the same segment. Its pretraining data totals 32.89 billion subword pieces gathered from BooksCorpus and English Wikipedia at 13 gigabytes of combined text, Giga5 at 16 gigabytes, ClueWeb 2012-B which after strict filtering leaves 19 gigabytes, and Common Crawl which leaves 110 gigabytes. The Large form was trained on 512 TPU v3 chips for 500 thousand steps with a batch of 8192 sequences, taking about 5.5 days, and its makers record that the model was still underfitting when training ended.
Limits and risks
The first limit is the standing of its results: every number in this article is a result reported by XLNet's own makers on the benchmarks and at the time of its publication in 2019, including its standing above BERT. The full-data comparison mixes the method with more data and more computation, as its paper itself acknowledges by providing a separate fair comparison, and newer models have long since passed those numbers; this paper's numbers are a framed historical record, not an eternal verdict on the ranking of language models.
The second limit is cost. Pretraining the Large form demands hundreds of TPU chips for days, and its official repository itself warns that reproducing most of the Large form's best results in its paper is very difficult and costly on graphics cards with 12 to 16 gigabytes of memory, because a single sequence of length 512 already fills such a card. The third limit is the scope of its evaluation: its paper evaluates XLNet only on understanding tasks, not on text generation, so XLNet's standing as a generator is untested by the material supporting this article. And like every language model, its fine-tuned output can still be wrong; for uses that demand factual exactness, its task results still need a human check.