SlideShare a Scribd company logo
1 of 19
XLNet
Permutation-based AR Language Modeling
김유진, 문예진, 송경민, 이상민, 한유경
NLP 2조
XLNet Permutation-based AR Language Modeling
Models Review
Seq2Seq
Trans
former
GPT-1 BERT XLNet
Attention
+
Seq2Seq
XLNet Permutation-based AR Language Modeling
AR
AutoRegressive
• 앞의 token을 이용해 문장의 확률분포 알아
• Joint Probobility 계산
• 단방향 문맥 파악
AutoEncoding
• MASK된 token으로 원본 재구성 목
표
• 양방향 문맥 파악
• Pretrain과 Finetuning 불일치
문제
AR과 AE를 최대한 활용할 수 있는 generalized AR method
AE 𝑥1 ? 𝑥4
𝑥3
예
측
𝑥1 𝑥3
𝑥2
예
측
XLNet Permutation-based AR Language Modeling
AR과 AE를 최대한 활용할 수 있는 generalized AR method
Pretrain-Finetune 일치
• 데이터 MASK에 의존하지 않음
• 결합확률 계산 가능 = token의 의존성 확인 가
능
Permutation Language Modeling
• 가능한 모든 token 순서 고려
• 양방향 문맥 모두 학습
• MASK 없음
Transformer-XL 활용
• segment recurrence mechanism &
relative encoding scheme 적용
• Target-Aware Representations
XLNet
XLNet Permutation-based AR Language Modeling
Objective: Permutation Language Modeling
Input Sequence (T)
모든 permutation 집합 (Zt)
likelihood
Objective function
[[3,2,4,1],[2,4,3,1],[1,4,2,3]
,…,[4,3,1,2]]
다양한 sequence 고
려
AR Objective function에 대
입
특정 토큰에 양방향 context 고려 가
능
x1 x2 x3 x4
모든 permutation 집합
4! = 24
XLNet Permutation-based AR Language Modeling
Architecture : Two-Stream Self-Attention for Target-Aware Representations
Two-Stream Self Attention = Content Stream + Query Stream
1 2
Content Stream : 현재 시점과 현재 시점 이전의 토큰 정보 활용
1
XLNet Permutation-based AR Language Modeling
Architecture : Two-Stream Self-Attention for Target-Aware Representations
Content Stream : 현재 시점과 현재 시점 이전의 토큰 정보 활용
1
KoreaUniv DSBA, https://www.youtube.com/watch?v=v7diENO2mEA
XLNet Permutation-based AR Language Modeling
Architecture : Two-Stream Self-Attention for Target-Aware Representations
Input sequence [x1, x2, x3, x4]
Index의 permutation
Z = [ [1,2,3,4], [1,3,2,4], … [4,3,2,1] ] 학습
[2, 3, 1, 4]의 경우 p(x1|x2, x3) -> hθ(x2, x3)
[2, 3, 4, 1]의 경우 p(x4|x2, x3) -> hθ(x2, x3)
위치가 다른데 같은 representation
Position 정보가 필요
XLNet Permutation-based AR Language Modeling
Architecture : Two-Stream Self-Attention for Target-Aware Representations
Query Stream : 이전의 토큰정보 + 현재의 위치 정보
2
XLNet Permutation-based AR Language Modeling
Architecture : Two-Stream Self-Attention for Target-Aware Representations
Query Stream : 이전의 토큰정보 + 현재의 위치 정보
2
KoreaUniv DSBA, https://www.youtube.com/watch?v=v7diENO2mEA
XLNet Permutation-based AR Language Modeling
Architecture : Two-Stream Self-Attention for Target-Aware Representations
• Content Stream으로부터 hidden representation
• Query Stream으로부터 토큰의 위치정보
XLNet Permutation-based AR Language Modeling
Pretrain의 계산량을 줄이기 위한 방법
입력값의 부분 집합만을 학습
Architecture : Two-Stream Self-Attention for Target-Aware Representations
[3,2,4,1] 에서 K = 2일 경우
Partial Prediction : Pretrain의 계산량을 줄이기 위한 방법
입력값의 부분 집합만을 학습
XLNet Permutation-based AR Language Modeling
segment recurrence mechanism
Incorporating Ideas from Transformer-XL
segment recurrence mechanism + relative positional encoding scheme
1 2
XLNet Permutation-based AR Language Modeling
Incorporating Ideas from Transformer-XL
segment recurrence mechanism + relative positional encoding scheme
1 2
[1,2,3,4] [1,2,3,4] [1,2,3,4]
segment1 segment2 segment3
• 이전 segment를 재사용할 때, positional encoding을 정의하는 방법
XLNet Permutation-based AR Language Modeling
Experiments : Pretraining and Implementation
• Pretraining Dataset
- Bert : BookCorpus + English Wikipedia
- XLNet : BookCorpus + English Wikipedia + Giga5 + ClubWeb + Common Crawl
• Bert보다 10배 많은 데이터 사용
• Model size
- XLNet-Large는 BERT-Large와 같은 구조의 하이퍼파라미터 매개 변수를 가짐
 비슷한 모델 사이즈
XLNet Permutation-based AR Language Modeling
Experiments : Fair Comparison with BERT
BERT와 XLNet을 공정한 환경에서 비교
 모든 데이터셋에서 BERT를 능가함!
XLNet Permutation-based AR Language Modeling
Experiments : Comparison with RoBERTa: Scaling Up
RACE Dataset
SQuAD Dataset
GLUE Dataset
Text Classification
XLNet Permutation-based AR Language Modeling
Experiments : Ablation Study
XLNet Permutation-based AR Language Modeling
Conclusions
• XLNet은 AR pretrainig 방법을 일반화한 것
& Permutation language modeling objective를 사용해 AR과 AE의 장점을 결합한 것
• XLNet의 구조는 AR objective을 작업하는데 적용되고
Transformer-XL와 two-stream attention mechanism을 결합하여 설계됨
• 다양한 작업에서 이전 pretraining 목표들보다 상당한 개선을 달성

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

XLNet : Generalized Autoregressive Pretraining for Language Understanding

  • 1. XLNet Permutation-based AR Language Modeling 김유진, 문예진, 송경민, 이상민, 한유경 NLP 2조
  • 2. XLNet Permutation-based AR Language Modeling Models Review Seq2Seq Trans former GPT-1 BERT XLNet Attention + Seq2Seq
  • 3. XLNet Permutation-based AR Language Modeling AR AutoRegressive • 앞의 token을 이용해 문장의 확률분포 알아 • Joint Probobility 계산 • 단방향 문맥 파악 AutoEncoding • MASK된 token으로 원본 재구성 목 표 • 양방향 문맥 파악 • Pretrain과 Finetuning 불일치 문제 AR과 AE를 최대한 활용할 수 있는 generalized AR method AE 𝑥1 ? 𝑥4 𝑥3 예 측 𝑥1 𝑥3 𝑥2 예 측
  • 4. XLNet Permutation-based AR Language Modeling AR과 AE를 최대한 활용할 수 있는 generalized AR method Pretrain-Finetune 일치 • 데이터 MASK에 의존하지 않음 • 결합확률 계산 가능 = token의 의존성 확인 가 능 Permutation Language Modeling • 가능한 모든 token 순서 고려 • 양방향 문맥 모두 학습 • MASK 없음 Transformer-XL 활용 • segment recurrence mechanism & relative encoding scheme 적용 • Target-Aware Representations XLNet
  • 5. XLNet Permutation-based AR Language Modeling Objective: Permutation Language Modeling Input Sequence (T) 모든 permutation 집합 (Zt) likelihood Objective function [[3,2,4,1],[2,4,3,1],[1,4,2,3] ,…,[4,3,1,2]] 다양한 sequence 고 려 AR Objective function에 대 입 특정 토큰에 양방향 context 고려 가 능 x1 x2 x3 x4 모든 permutation 집합 4! = 24
  • 6. XLNet Permutation-based AR Language Modeling Architecture : Two-Stream Self-Attention for Target-Aware Representations Two-Stream Self Attention = Content Stream + Query Stream 1 2 Content Stream : 현재 시점과 현재 시점 이전의 토큰 정보 활용 1
  • 7. XLNet Permutation-based AR Language Modeling Architecture : Two-Stream Self-Attention for Target-Aware Representations Content Stream : 현재 시점과 현재 시점 이전의 토큰 정보 활용 1 KoreaUniv DSBA, https://www.youtube.com/watch?v=v7diENO2mEA
  • 8. XLNet Permutation-based AR Language Modeling Architecture : Two-Stream Self-Attention for Target-Aware Representations Input sequence [x1, x2, x3, x4] Index의 permutation Z = [ [1,2,3,4], [1,3,2,4], … [4,3,2,1] ] 학습 [2, 3, 1, 4]의 경우 p(x1|x2, x3) -> hθ(x2, x3) [2, 3, 4, 1]의 경우 p(x4|x2, x3) -> hθ(x2, x3) 위치가 다른데 같은 representation Position 정보가 필요
  • 9. XLNet Permutation-based AR Language Modeling Architecture : Two-Stream Self-Attention for Target-Aware Representations Query Stream : 이전의 토큰정보 + 현재의 위치 정보 2
  • 10. XLNet Permutation-based AR Language Modeling Architecture : Two-Stream Self-Attention for Target-Aware Representations Query Stream : 이전의 토큰정보 + 현재의 위치 정보 2 KoreaUniv DSBA, https://www.youtube.com/watch?v=v7diENO2mEA
  • 11. XLNet Permutation-based AR Language Modeling Architecture : Two-Stream Self-Attention for Target-Aware Representations • Content Stream으로부터 hidden representation • Query Stream으로부터 토큰의 위치정보
  • 12. XLNet Permutation-based AR Language Modeling Pretrain의 계산량을 줄이기 위한 방법 입력값의 부분 집합만을 학습 Architecture : Two-Stream Self-Attention for Target-Aware Representations [3,2,4,1] 에서 K = 2일 경우 Partial Prediction : Pretrain의 계산량을 줄이기 위한 방법 입력값의 부분 집합만을 학습
  • 13. XLNet Permutation-based AR Language Modeling segment recurrence mechanism Incorporating Ideas from Transformer-XL segment recurrence mechanism + relative positional encoding scheme 1 2
  • 14. XLNet Permutation-based AR Language Modeling Incorporating Ideas from Transformer-XL segment recurrence mechanism + relative positional encoding scheme 1 2 [1,2,3,4] [1,2,3,4] [1,2,3,4] segment1 segment2 segment3 • 이전 segment를 재사용할 때, positional encoding을 정의하는 방법
  • 15. XLNet Permutation-based AR Language Modeling Experiments : Pretraining and Implementation • Pretraining Dataset - Bert : BookCorpus + English Wikipedia - XLNet : BookCorpus + English Wikipedia + Giga5 + ClubWeb + Common Crawl • Bert보다 10배 많은 데이터 사용 • Model size - XLNet-Large는 BERT-Large와 같은 구조의 하이퍼파라미터 매개 변수를 가짐  비슷한 모델 사이즈
  • 16. XLNet Permutation-based AR Language Modeling Experiments : Fair Comparison with BERT BERT와 XLNet을 공정한 환경에서 비교  모든 데이터셋에서 BERT를 능가함!
  • 17. XLNet Permutation-based AR Language Modeling Experiments : Comparison with RoBERTa: Scaling Up RACE Dataset SQuAD Dataset GLUE Dataset Text Classification
  • 18. XLNet Permutation-based AR Language Modeling Experiments : Ablation Study
  • 19. XLNet Permutation-based AR Language Modeling Conclusions • XLNet은 AR pretrainig 방법을 일반화한 것 & Permutation language modeling objective를 사용해 AR과 AE의 장점을 결합한 것 • XLNet의 구조는 AR objective을 작업하는데 적용되고 Transformer-XL와 two-stream attention mechanism을 결합하여 설계됨 • 다양한 작업에서 이전 pretraining 목표들보다 상당한 개선을 달성

Editor's Notes

  1. 간단하게 여태까지 언급된 모델들을 살펴보겠습니다. Seq2Seq는 RNN계열의 Encoder-Decoder를 갖고 있는, Neural Machine Translation 모델이고, 거기에 Attention을 덧붙여 Decoder가 문장의 중요한 정보에 집중할 수 있도록 만든 모델이 있었습니다. 여기에서 self-attention과 multi-head attention 등 RNN을 더 이상 활용하지 않는 Transformer가 나왔습니다. 이제 여기에서 GPT과 BERT가 파생되었는데, 다들 아시다시피 GPT는 transformer의 Decoder를, BERT는 Encoder를 활용하여 Pretraining & Finetuning을 진행하게 됩니다. 여기에 적진 않았지만, BERT이후 GPT-2가 발표되었는데, 이 아이는 GPT1에서 언어 학습을 했으니 finetuning 없이 zeroshot으로만 해도 좋은 성능을 가질 수 있다! 를 보여주게 됩니다. 그렇다면 XLNet은 무엇일까요?
  2. 프리 트레인의 두가지 방식에는 AR과 AE가 있는데 , 본 논문에서 XLNet은 Autoregressive(AR)와 Autoencoding(AE)를 최대한 활용할 수 있는 일반화된 AR method라고 정의하고 있습니다. AutoRegressive은 LM에서 쓰는 objective fn과 같은 역할을 합니다. 그림에서 x4를 예측하고자 할 때, x1, x2, x3를 활용해서 x4가 등장할 확률 최대화하는 거죠. 이는 앞으로 가든 뒤로 가든 한 방향으로 token을 학습하기 때문에, 양방향 정보가 필요한 task에서는 적합하지 않다는 단점을 가지고 있습니다. AutoEncoding의 대표적인 모델 BERT를 보시면 token에 noise를 추가하고, 그 noise를 복원하는 방식으로 학습을 진행합니다. MASK된 토큰이 무엇인지 예측하기 위해 양방향을 모두 살펴보기 때문에 성능은 향상되었지만, 이 방식에도 몇가지 문제점이 있습니다. 1)MASK된 token이 pretraining에서는 사용되지만 finetuning에서는 사용되지 않기 때문에 두 과정이 불일치 하게 됩니다. 2) MASK token이 다른 token과 독립적으로 예측이 되는 것입니다. 하지만 아시다시피 자연어는 독립적이지 않기 때문에 이건 단점으로 작용하게 됩니다. 이러한 각각의 단점을 보완하며 장점을 최대한 활용할 수 있도록 만들어진 모델이 바로 XLNet입니다. 여기서 AR의 대표적인 것이 GPT, AE의 대표적인 예가 BERT라는 점에서 이 모델은 GPT와 BERT를 합친 모델이라고 생각하셔도 좋을 것 같습니다.
  3. 뒤에서 좀 더 설명하겠지만, XLNet의 특징을 살펴보면 다음과 같습니다. 1) 가능한 모든 token들의 permutaition 순서를 고려합니다. 모든 sequence에 대해 log liklihood를 최대화 시켜 양방향 문맥을 모두 학습하게 됩니다. 모든 순서를 고려했기 때문에, Masking은 존재할 수 없게 되고 결국 pretrain과 finetune이 일치하게 되어 token의 의존성을 고려할 수 있게 됩니다. 그러니까 결론적으로 양방향 context 활용하여 AR의 한계를 극복하였으며, 동시에 mask를 씌우는 기법을 제거해 AE 한계 극복하게 됩니다. 2) 하지만 이 과정에서 기존 transformer 모델과는 다른점이 생기면서 pretraining framework의 설계를 개선하였는데, 동일 저자의 이전 논문인 Transformer xl에 있었던 segment recurrence 매커니즘과 relative encoding scheme을 pretrain에 적용하여 긴 text에도 좋은 성능을 가질 수 있도록 하였습니다. Transformer-XL는 permutation을 사용하기 때문에 순서가 뒤죽박죽이고 target이 모호한 XLNet에 적용하기 어렵습니다. 그렇기 때문에 이를 재설정해서 Target의 모호함을 제거할 수 있는 ‘Target-Aware Representation’을 사용하여 Transformer를 XLNet에 적용합니다.
  4. xlnet 의 세가지 특징 중 첫번째인 permutation language modeling objective에 대해 설명하겠습니다. 먼저 인풋 시퀀스가 다음과 같이 네가지 토큰이 있다고 할 때, 이 토큰의 모든 퍼뮤테이션 집합을 만들게 됩니다. 예를들어~~ [1,2,3,4] 이 경우에는 24가지의 집합이 생기게 되는 것이죠. 이 퍼뮤테이션 집합을 zt 라고 부르며, Zt의 likelihood function을 보시면 모든 zt를 ar objective function에 대입하는 것을 알 수 있습니다. Ar function을 모든 permutation 집합에서 진행하는 것이 xlnet의 object function입니다. 이를 정리해 보자면, 모든 permutation 집합을 통해 다양한 sequence를 고려하게 되고 이를 통해 양방향정보를 활용할 수 없었던 ar의 한계점을 극복한 것이라 할 수 있습니다. 따라서, 특정 토큰에 대하여 양방향 context를 고려할 수 있게 된 것입니다.
  5. 앞서 정의한 objective function은 기존의 standard transformer에서 사용할 수 없기 때문에 본 논문에서는 새로운 구조를 제안합니다. 이를 논문에서는 XLNet의 구조인 Two-Stream Self-Attention for Target-Aware Reprensentations이라는 제목으로 설명하는데요. 먼저 Two-Stream Self Attention이란 말은 쿼리 스트림과 컨텐트 스트림 두 스트림이 합쳐진 것입니다. 컨텐트 스트림이란 기존 트랜스포머 네트워크와 유사하며 이전 문맥과 자기 자신에 대응하는 토큰 정보 x(?)를 활용하는 것입니다.
  6. 근데 여기서 위치정보를 고려하지 않으면 문제점이 생기는데요. 논문에서 Target position-aware representation을 설명하자면 x1, x2, x3, x4과 input sequence로 들어올 때 index의 permutation은 [ 1,2,3,4 ], [1, 3, 2, 4] 등등 쭉 있겠죠? [2,3,1,4]의 경우 x1을 예측하고자 할 때 h세타 x2,x3가 되며 [2,3,4,1]에서 x4를 예측하고자 할 때도 h세타 x2, x3가 될 것입니다. 여기서 같은 h세타 x2,x3을 통해 x4와 x1을 예측하는 문제점이 있어 context token들의 정보와 더불어 target index의 position 정보(z세타)가 필요합니다. 따라서 학습 시에 예측할 representation 뿐만 아니라 target tocken을 같이 학습시켜야하는데, 이를 구현하기 위한 방법이 target-aware representation이라고 할 수 있습니다.
  7. 이러한 target의 position을 같이 학습시키기 위한 방법이 query stream입니다.
  8. 이렇게 Xlnet의 모델은 hideen representation을 출력하는 content stream과 토큰의 위치정보를 출력하는 query stream을 통해 연산을 수행한다고 정리할 수 있습니다.
  9. 근데 여기서 두 stream을 사용하면 pre train할 때 계산량이 굉장히 많아 지는데 계산량을 줄이기 위한 partial prediction방법이 있습니다. 이 방법은 입력값의 부분 집합만을 학습하는 것인데, 3 -> 2-> 4 -> 1의 순서에서 하이퍼파라미터 값을 2로 주면 ½만을 예측에 사용하게 됩니다. 즉 앞의 2개는 제외하고 마지막 2개만 예측에 사용합니다.
  10. 마지막으로 Xlnet은 동일한 저자의 이전 논문인 transformer-XL 모델의 대표적인 특징 두가지를 pretrained framework에 사용하였습니다. 여기서 XL은 extra-long을 뜻하며 따라서 transformer-XL은 기존의 transformer 구조보다 긴 sequence를 가진 문장을 더 잘 처리할 수 있는 모델이라고 생각하시면 될 것 같습니다. 그러기 위해서 Xlnet은 segment recurrence mechanism과 relative positional encoding scheme을 사용합니다. segment recurrence mechanism : 기존의 transformer와 달리 이전 segment를 이용해서 다음 segment를 예측하는 모델로, segment 끼리 정보 전달이 가능하다는 장점이 있습니다. 모델에서 이전 segment에 대한 히든 스테이트 값을 cache로 가지고 있어 메모리만 확보된다면 빠르게 계산하는 계산할 수 있습니다.
  11. 앞에서 제시한 구조를 실현하기 위해서는 한가지 문제를 더 해결해야하는데, Positional Encoding 입니다. 기존의 Transformer는 특정 위치의 토큰의 embedding을 계산할 때, 해당 토큰의 Word Embedding과 토큰 위치의 Positional Encoding값을 더합니다. 따라서 각 위치마다 고유한 embedding 값을 갖습니다. 하지만 segment recurrence mechanis을 이용하면 세그먼트마다 같은 포지션을 가지는 word가 생기게 됩니다. 이를 해결하기 위해서 기존 transformer에서 사용하던 절대적인 positional Encoding 대신 R로 현재 시점으로부터 상대적인 위치를 Encoding 하게 됩니다. 해당 논문을 더 잘 이해하기 위해서는 transformer xl 논문도 함께 읽으면 좋을 것 같습니다.
  12. 다음으로 Xlnet의 성능에 대해 이야기하겠습니다. 데이터 셋을 보면 Bert는 BookCorpus와 English Wikipedia를 활용한 것에 비해 XLNet은 BookCorpus, English Wikipedia, Giga5, ClubWeb, Common Crawl을 사용하였습니다. 데이터 크기로 보면 Bert보다 10배 정도 많은 데이터 사용하였다고 합니다. 또한, 가장 큰 모델인 XLNet-Large는 BERT-Large와 같은 구조의 하이퍼파라미터 매개 변수를 가지므로 비슷한 모델 사이즈를 가집니다.
  13. 이러한 조건에서 BERT와 XLNet을 동일한 환경에서 비교했을 때, 모든 데이터셋에서 BERT를 능가하는 것을 볼 수 있습니다.
  14. bert라는 모델이 처음 나왔을 때 약 11가지 모델에 대해서 sota를 찍어서 화제가 됐었는데 bert보다 약 20개의 nlp test에서 더 좋은 성능을 보여주고 그 중 18개에서 sota를 찍어 화제가 되었습니다. --------------------------- 첫번째 표는 RACE Dataset의 표로, GPT, BERT 앙상블 모델들보다 XLNet이 성능이 좋은 것을 볼 수 있습니다. 두번째 표는 SQuAD Dataset의 표로, Single model들 중에서도 XLNet이 최고 성능을 보이는 것을 볼 수 있습니다. 위의 표는 Text Classification의 표로, 오분류율도 모두 SOTA 달성한 것을 확인할 수 있습니다. 아래 표는 GLUE Dataset으로 이는 9개의 NLU task를 모은 데이터셋입니다. 9개 중 7개가 SOTA, 9개 모두 기존의 BERT보다 더 좋은 성능을 보이는 것을 확인할 수 있습니다.
  15. 마지막으로 표의 1,2번째 줄을 보면 기존 BERT에 Transformer-XL을 반영하면 성능이 좋아지는 것을 볼 수 있고, 3,4번 째 줄의 BERT + Transformer-XL + Permutation LM 에서는 성능이 더욱 좋아지는 것을 확인할 수 있습니다. 또한 K값을 적절히 조정하였을 때 성능이 올라갑니다.
  16. - XLNet은 AR pretrainig 방법을 일반화한 것으로, Permutation language modeling objective를 사용해 AR과 AE의 장점을 결합한 것입니다. - XLNet의 구조는 AR objective을 작업하는데 적용되고 Transformer-XL와 two-stream attention mechanism을 결합하여 설계되었습니다. - 다양한 작업에서 이전 pretraining 목표들보다 상당한 개선을 달성했습니다.