ArticleslgStudy

computer science

XLNet

XLNet is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand XLNet rather than just read about it. In short: The XLNet was an autoregressive Transformer designed as an improvement over BERT, with 340M parameters and trained on 33 billion words. It was released on 19 June 2019, under the Apache 2.0 license.

Key takeaways

  • XLNet belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect XLNet to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of XLNet from memory before moving on to harder problems.

Reference excerpt

The XLNet was an autoregressive Transformer designed as an improvement over BERT, with 340M parameters and trained on 33 billion words. It was released on 19 June 2019, under the Apache 2.0 license. It achieved state-of-the-art results on a variety of natural language processing tasks, including language modeling, question answering, and natural language inference.

Architecture The main idea of XLNet is to model language autoregressively like the GPT models, but allow for all possible permutations of a sentence. Concretely, consider the following sentence:My dog is cute.In standard autoregressive language modeling, the model would be tasked with predicting the probability of each word, conditioned on the previous words as its context: We factorize the joint probability of a sequence of words x1,…,xT using the chain rule:Pr⁡(x1,…,xT)=Pr⁡(x1)Pr⁡(x2|x1)Pr⁡(x3|x1,x2)…Pr⁡(xT|x1,…,xT−1). For example, the sentence "My dog is cute" is factorized as: Pr⁡(My,dog,is,cute)=Pr⁡(My)Pr⁡(dog|My)Pr⁡(is|My,dog)Pr⁡(cute|My,dog,is). Schematically, we can write it as <𝙼𝙰𝚂𝙺><𝙼𝙰𝚂𝙺><𝙼𝙰𝚂𝙺><𝙼𝙰𝚂𝙺>→My <𝙼𝙰𝚂𝙺><𝙼𝙰𝚂𝙺><𝙼𝙰𝚂𝙺>→My dog <𝙼𝙰𝚂𝙺><𝙼𝙰𝚂𝙺>→My dog is <𝙼𝙰𝚂𝙺>→My dog is cute. However, for XLNet, the model is required to predict the words in a randomly generated order. Suppose we have sampled a randomly generated order 3241, then schematically, the model is required to perform the following prediction task: <𝙼𝙰𝚂𝙺><𝙼𝙰𝚂𝙺><𝙼𝙰𝚂𝙺><𝙼𝙰𝚂𝙺>→<𝙼𝙰𝚂𝙺><𝙼𝙰𝚂𝙺>is <𝙼𝙰𝚂𝙺>→<𝙼𝙰𝚂𝙺>dog is <𝙼𝙰𝚂𝙺>→<𝙼𝙰𝚂𝙺>dog is cute→My dog is cute By considering all permutations, XLNet is able to capture longer-range dependencies and better model the bidirectional context of words.

Two-Stream Self-Attention To implement permutation language modeling, XLNet uses a two-stream self-attention mechanism. The two streams are:

Content stream: This stream encodes the content of each word, as in standard causally masked self-attention. Query stream: This stream encodes the content of each word in the context of what has gone before. In more detail, it is a masked cross-attention mechanism, where the queries are from the query stream, and the key-value pairs are from the content stream. The content stream uses the causal maskMcausal=[0−∞−∞…−∞00−∞…−∞000…−∞⋮⋮⋮⋱⋮000…0]permuted by a random permutation matrix to PMcausalP−1. The query stream uses the cross-attention mask P(Mcausal−∞I)P−1, where the diagonal is subtracted away specifically to avoid the model "cheating" by looking at the content stream for what the current masked token is. Like the causal masking for GPT models, this two-stream masked architecture allows the model to train on all tokens in one forward pass.

Training Two models were released:

XLNet-Large, cased: 340M parameters, 24-layer, 1024-hidden, 16-heads XLNet-Base, cased: 110M parameters, 12-layer, 768-hidden, 12-heads. It was trained on a dataset that amounted to 32.89 billion tokens after tokenization with SentencePiece. The dataset was composed of BooksCorpus, and English Wikipedia, Giga5, ClueWeb 2012-B, and Common Crawl. It was trained on 512 TPU v3 chips, for 5.5 days. At the end of training, it still under-fitted the data, meaning it could have achieved lower loss with more training. It took 0.5 million steps with an Adam optimizer, linear learning rate decay, and a batch size of 8192.

See also BERT (language model) Transformer (machine learning model) Generative pre-trained transformer Yang Zhilin

References

Worked examples

Example 1 — a first encounter with XLNet

Start with the simplest possible case. Write down what XLNet claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to XLNet before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about XLNet ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of XLNet

In research
XLNet appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses XLNet in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
XLNet is common in secondary-school and first-year university syllabi. It links to neighbouring topics 2019 software, Google software, Large language models, so understanding it makes those chapters shorter.
In everyday life
Look for XLNet outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “XLNet” →

How to study XLNet in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what XLNet means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain XLNet out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is XLNet in simple terms?

The XLNet was an autoregressive Transformer designed as an improvement over BERT, with 340M parameters and trained on 33 billion words. It was released on 19 June 2019, under the Apache 2.0 license.

Why does XLNet matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study XLNet?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on XLNet.

Tags

  • 2019 software
  • Google software
  • Large language models
  • Software using the Apache license

Keep exploring