언어 AI 가이드

XLNet and Permutation Language Modeling

XLNet is a 2019 language model from Carnegie Mellon University and Google Brain that learns bidirectional context without BERT's [MASK] token.

이 가이드를 들어보세요AI 내레이션 · ~7 min

이 페이지에서8분 읽기
  1. 개요
  2. 주요 시사점
  3. 심층 분석
  4. Tracing one permutation of a four-word sentence
  5. 실제 구현
  6. The Future of XLNet and Permutation Language Modeling
  7. 실천에 옮기기
  8. 출처 및 추가 자료
  9. 계속 탐색하세요
  10. 자주 묻는 질문

개요

It trains by predicting words in many randomly shuffled orders, a method called permutation language modeling, and it outperformed BERT on 20 benchmark tasks in its NeurIPS 2019 paper.

주요 시사점

  1. XLNet, published at NeurIPS 2019 by Carnegie Mellon University and Google Brain researchers, trains by predicting tokens in randomly sampled factorization orders.
  2. Permutation language modeling gives each token bidirectional context while staying autoregressive, and it never inserts a [MASK] token into the input.
  3. Two-stream self-attention separates a content stream that sees each token from a query stream that knows only the target position.
  4. XLNet reported 85.4% on RACE versus 72.0% for BERT, and beat BERT on 20 tasks under comparable settings.
  5. RoBERTa narrowed the gap within weeks, showing that much of BERT's shortfall came from undertraining rather than its masked objective alone.

심층 분석

XLNet is a pretrained transformer language model introduced in June 2019 by Zhilin Yang, Zihang Dai, Yiming Yang, Jaime Carbonell and Ruslan Salakhutdinov of Carnegie Mellon University and Quoc V. Le of the Google Brain team, and published at NeurIPS 2019. Its key contribution is a training objective called permutation language modeling. The goal was to combine the strengths of two earlier families of models: autoregressive models such as GPT, which predict each word from the words before it, and autoencoding models such as BERT, which hide some words and predict them from both sides.

The problem XLNet set out to fix is worth stating plainly. An autoregressive model only sees context on one side, which limits understanding tasks where both sides matter. BERT sees both sides by replacing a share of input tokens with a special [MASK] symbol and predicting the originals. The XLNet authors identified two weaknesses in that design. First, the [MASK] symbol appears in pretraining but never in real downstream text, a mismatch they call the pretrain-finetune discrepancy. Second, BERT predicts the masked tokens independently of one another, so if both words of a name like New York are masked, it cannot use one guess to inform the other.

Permutation language modeling works like this. Take a sentence of T tokens and pick a random factorization order, a shuffled sequence of positions such as 3, 1, 4, 2. The model then predicts the tokens one at a time in that order, so token 3 is predicted from nothing, token 1 from token 3, token 4 from tokens 3 and 1, and so on. Crucially, the words themselves are never reordered in the input; their original positions are kept, and only the attention mask changes so that each token can see exactly the tokens that come earlier in the sampled order. Over many training steps, with a fresh order each time, every token ends up being predicted from many different combinations of left and right neighbors. The model is still autoregressive, multiplying conditional probabilities, but in expectation it learns from bidirectional context, and no [MASK] token is ever inserted.

This creates a technical puzzle that the paper solves with two-stream self-attention. To predict the token at a given position, the model must know which position it is predicting, or it would give the same answer for every target, but it must not see that token's own content, or the task would be trivial. XLNet therefore keeps two representations per position. The content stream works like a normal transformer and includes the token itself. The query stream knows the target position but not its word, and is the one used to make the prediction. Because predicting from very short contexts early in an order is hard and slows training, XLNet also uses partial prediction, predicting only the last part of each order, roughly one token in K, with K set to 6 for the large model.

XLNet also borrowed two components from Transformer-XL, a model the same group published at ACL 2019 that learned dependencies 450% longer than vanilla transformers. These were relative positional encodings, which describe how far apart two tokens are rather than their absolute index, and segment-level recurrence, which caches hidden states from a previous text segment as memory for the next. The large model used BERT-Large's architecture, 24 layers with a hidden size of 1,024 and 16 attention heads, and was pretrained on 32.89 billion subword pieces drawn from BooksCorpus, English Wikipedia, Giga5, ClueWeb 2012-B and Common Crawl. Training used 512 TPU v3 chips for 500,000 steps with a batch size of 8,192 and sequence length of 512, about 5.5 days.

The headline results were strong for mid-2019. The abstract reports XLNet beating BERT on 20 tasks under comparable settings. On RACE, a reading comprehension test drawn from English exams, it scored 85.4% against BERT's 72.0%. On SQuAD 2.0 it reached 90.6 F1 on the dev set against 81.77 for BERT. The paper also ran a fair comparison, training XLNet on the same Wikipedia and books data with BERT's hyperparameters, and XLNet still came out ahead on every dataset in that table. Its ablations showed that both the permutation objective and the Transformer-XL memory contributed, though some gaps were small: removing memory cut the base model's RACE score from 66.66 to 65.55.

Compared with the alternatives, the picture became more nuanced within weeks. RoBERTa, posted by Yinhan Liu and colleagues in July 2019, argued that the original BERT was significantly undertrained and showed that a better-tuned masked language model with more data could match or exceed later models. XLNet's own updated paper compares against RoBERTa and reports generally better scores, for example 90.8% versus 90.2% on MNLI, but the margins were far smaller than over the original BERT. This made it harder to say how much of XLNet's gain came from the permutation objective and how much from more data, longer training and Transformer-XL components.

XLNet's practical limitations were mostly about cost and complexity. Two-stream attention and permutation masks make the model harder to implement and slower to train than a standard masked model. The official repository warns that fine-tuning XLNet-Large on a 16 GB GPU fits only a single 512-token sequence per batch, and that reproducing many paper results would take roughly 32 to 128 GPUs. Partial prediction means each sequence trains on only a fraction of its tokens. XLNet is now studied mainly as a reference point: it remains a clear demonstration that an autoregressive model can learn bidirectional context without corrupting its input.

04실제 사례

Tracing one permutation of a four-word sentence

  1. Write the sentence 'cats chase small mice' with positions 1 to 4.

  2. Sample a factorization order, for example 3, 1, 4, 2.

  3. Predict position 3, 'small', with no visible tokens, using only the query stream's knowledge that position 3 is the target.

  4. Predict position 1, 'cats', seeing only 'small' at position 3.

  5. Predict position 4, 'mice', seeing 'small' and 'cats', both of which sit to its left in the text.

  6. Predict position 2, 'chase', seeing positions 1, 3 and 4, so it uses context from both its left and right.

  7. With partial prediction and K = 2, keep only the losses for the last two steps, positions 4 and 2.

그것이 보여주는 것

Position 2 was predicted from words on both sides without any [MASK] token, which is the core of permutation language modeling. Check the trace by building the 4 by 4 attention mask: row 2 should allow columns 1, 3 and 4, and row 3 should allow none.

실제 구현

Reading comprehension: on the RACE exam-question benchmark, the XLNet paper reports 85.4% accuracy, against 72.0% for BERT and 83.2% for RoBERTa.

Extractive question answering on SQuAD 2.0, where the paper reports a single-model dev score of 90.6 F1, compared with 81.77 for BERT and 89.4 for RoBERTa.

Fine-tuning released checkpoints: the authors' Apache-2.0 repository published XLNet-Large on June 19, 2019 and XLNet-Base on July 16, 2019 for classification, question answering and ranking tasks.

Teaching and research on pretraining objectives, where XLNet is the standard example of getting bidirectional context while keeping an autoregressive, left-to-right style probability model.

Natural language inference: on GLUE's MNLI task, the paper reports 90.8% dev accuracy, ahead of RoBERTa's 90.2% and BERT's 86.6%.

The Future of XLNet and Permutation Language Modeling

XLNet's direct line of development did not continue at large scale, but the questions it raised remain open. The rapid arrival of RoBERTa in July 2019, which matched or beat later models with a tuned masked objective, showed how hard it is to separate the effect of a pretraining objective from the effect of data, compute and training length. That lesson shaped how later papers report ablations and fair comparisons. The idea of learning from many orderings, rather than a single left-to-right order, continues to appear in research on non-autoregressive generation, infilling, and models that can generate tokens in flexible order. The XLNet paper itself, dated 2019 and revised in January 2020, framed permutation modeling as a general bridge between autoregressive and autoencoding pretraining. Whether flexible-order objectives offer advantages over plain next-token prediction at the scale of current large language models is an open research question, and claims either way depend on carefully controlled comparisons of the kind the XLNet and RoBERTa papers attempted.

실천에 옮기기

왜 중요한가요?

  • 속도와 규모. 일관성을 유지하면서 언어 워크플로를 더 빠르게 진행할 수 있습니다.
  • 접근 및 도달. 언어와 의사소통 스타일 전반에 걸쳐 접근성을 확장합니다.
  • 더 명확한 결정들. 자동화가 반복을 처리하는 동안 팀은 판단에 더 많은 시간을 할애할 수 있습니다.

조심하세요

  • 환각 사실은 보고서, 지원 흐름 또는 연구 결과에 조용히 포함될 수 있습니다.
  • 신속한 민감도는 유사한 요청 간에 일관되지 않은 결과를 초래할 수 있습니다.
  • 액세스 제어가 약한 경우 민감한 텍스트 데이터가 노출될 수 있습니다.

다음 단계

  1. 출시 전에 출력 형식, 톤, 품질 표준을 정의하세요.
  2. 정확성이 중요할 때마다 신뢰할 수 있는 출처를 통해 대응하세요.
  3. 고위험 결과물에 대한 인적 검토 체크포인트를 유지합니다.
  4. 실패 패턴을 추적하고 프롬프트나 워크플로를 정기적으로 재교육하세요.

출처 및 추가 자료

  1. arXiv (Yang et al.)XLNet: Generalized Autoregressive Pretraining for Language Understanding
  2. NeurIPS 2019 ProceedingsXLNet: Generalized Autoregressive Pretraining for Language Understanding
  3. arXiv / ACL 2019 (Dai et al.)Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
  4. arXiv (Liu et al.)RoBERTa: A Robustly Optimized BERT Pretraining Approach
  5. GitHub (XLNet authors)zihangdai/xlnet

계속 탐색하세요

무료 뉴스레터

일일 AI 브리핑 받기

매주 평일 아침마다 3개의 검증된 AI 스토리를 일반 영어로 작성합니다. 무료이며, 광고 없음.

매주 평일마다 한 번 이메일을 받습니다. 한 번 클릭으로 구독 해지. 주소를 판매하거나 공유하지 않습니다.

자신을 테스트해 보세요

Take the XLNet and Permutation Language Modeling quiz

모든 답변에 즉각적인 피드백과, 과정을 통과하면 검증 가능한 ID가 있는 공유 가능한 인증서를 제공합니다.

퀴즈 시작

무료 AI 교육을 지원합니다. AI Understanding는 501(c)(3) 비영리 단체입니다 — 광고 없음, 유료 장벽 없음, 영원히. 기부하기

자주 묻는 질문

What is XLNet and Permutation Language Modeling?

XLNet is a 2019 language model from Carnegie Mellon University and Google Brain that learns bidirectional context without BERT's [MASK] token. It trains by predicting words in many randomly shuffled orders, a method called permutation language modeling, and it outperformed BERT on 20 benchmark tasks in its NeurIPS 2019 paper.

XLNet은 어떤 사전 훈련 목표를 사용합니까?

XLNet은 순열 언어 모델링이라고 하는 토큰 분해 순서의 모든 순열에 대해 예상되는 로그 가능성을 최대화합니다.

XLNet은 어떤 BERT 약점을 해결하기 위해 특별히 설계되었습니까?

BERT의 인공 [MASK] 기호는 미세 조정 중에 절대 나타나지 않으며 마스킹된 예측을 독립적으로 처리합니다. XLNet은 두 가지 문제를 모두 방지합니다.

XLNet의 2스트림 self-attention은 무엇을 분리합니까?

콘텐츠 스트림은 토큰과 컨텍스트를 인코딩하는 반면, 쿼리 스트림은 대상의 위치를 ​​알고 있지만 내용은 알지 못하므로 누출 없이 예측이 가능합니다.

XLNet은 문장의 단어를 물리적으로 섞나요?

XLNet은 어텐션 마스크를 통해 예측(인수분해) 순서를 변경합니다. 원래 토큰 위치는 위치 인코딩을 통해 보존됩니다.

장거리 컨텍스트를 위한 XLNet의 백본 역할을 하는 아키텍처는 무엇입니까?

XLNet은 긴 시퀀스를 처리하기 위해 세그먼트 반복 및 상대 위치 인코딩을 추가하는 Transformer-XL을 기반으로 합니다.