[Paper Review] Language Models are Unsupervised Multitask Learners

2022. 10. 7. 10:19Paper Review

Abstract

이번 연구에서는, (수백만 개 웹페이지로 이루어진) WebText로 학습한 언어 모델이 지도 학습 없이 여러 가지 테스크(e.g., QA, translation)를 수행할 수 있음을 보여준다.

 

모델 크기가 증가할수록 여러 테스크 성능이 덩달아 향상되기에, 모델 크기는 zero-shot task transfer의 핵심 요소라 할 수 있다.

 

이러한 실험 결과들을 통해, 자연어 테스크 설명(=입력 토큰)으로 테스크를 학습하여 수행하는 language processing systems을 만듬으로써, 새로운 방향성을 제시한다.

 

더보기
We demonstrate that language models begin to learn these tasks without any explicit supervision when trained on a new dataset of millions of webpages called WebText.
The capacity of the language model is essential to the success of zero-shot task transfer and increasing it improves performance in a log-linear fashion across tasks.
These findings suggest a promising path towards building language processing systems which learn to perform tasks from their naturally occurring demonstrations.

1. Introduction

이번 연구에서는, (많은 테스크를 수행하는) 일반적인 시스템을 만들고자 한다. 

 

단일 도메인 데이터로 단일 테스크를 학습하는 것이 모델 일반화에 약영향을 준다고 생각하기 때문이다.

 

다중 작업 학습은 잘 알려진 일반 성능(?) 향상 방법이다. 하지만 그 당시 다중 학습 기술은 수많은 dataset-objective 쌍을 필요로 했다.

이는 매우 힘든 작업이기에, 다른 방식의 다중 작업 학습을 고안해야 했다.

 

현재, 1). pre-training & fine-tuning 기법은 모델 구조 변경 없이 가중치 변환만으로 최고 성능을 내고 있다. 하지만, 이 기법도 어느 정도의 지도 학습을 필요로 한다. 그에 반해, 최근 연구에서, 2). 지도 학습 없이 데스크를 수행할 수 있는 모델을 선보였다.

 

이번 연구에서는, 이 두 가지 연구(1. 모델 구조 고정, 2. 지도 학습 없이 테스크 수행)를 가지고 더 일반적인 전의(=transfer) 방법을 찾을 것이다. 즉, 언어 모델이 제로샷 상황(= 파라미터와 모델 구조 고정)에서 다운스트림 테스크를 수행할 수 있음을 보일 것이다.

 

더보기
We would like to move towards more general systems which can perform many tasks - eventually without the need to manually create and label a training dataset for each one.
Our suspicion is that the prevalence of single task training on single domain datasets is a major contributor to the lack of generalization observed in current systems.
Multitask learning is a promising framework for improving general performance.
Recent work reports modest performance improvements and the two most ambitious efforts to date have trained on a total of 10 and 17 (dataset, objective) pairs respectively.
This suggests that multitask training many need just as many effective training pairs to realize its promise with current approaches. It will be be very difficult to continue to scale the creation of datasets and the design of objectives
This motivates exploring additional setups for performing multitask learning.
The current best performing systems on language tasks utilize a combination of pre-training and supervised fine-tuning.
recent work suggests that task-specific architectures are no longer necessary and transferring many self-attention blocks is sufficient.
These methods still require supervised training in order to perform a task. When only minimal or no supervised data is available, another line of work has demonstrated the promise of language models to perform specific tasks.
In this paper, we connect these two lines of work and continue the trend of more general methods of transfer. We demonstrate language models can perform downstream tasks in a zero-shot setting - without parameter or architecture modification. 

2. Approach

이번 연구의 핵심은 언어 모델링(=단어 시퀀스에서 다음 단어를 예측하는 테스크)이다.

언어 모델링은 비지도 학습으로 단어 시퀸스 분포($=p(s_1, s_2, \cdots, s_n)$) 추정 방식으로 설계되어 왔다. 언어는 순차적이기에, 아래 식과 같이 결합 분포를 조건부 분포 곱으로 표현할 수 있고, 이는 $p(s_{n-k}, \cdots, s_n | s_1, \cdots, c_{n - k -1})$의 추정 및 샘플링도 가능케 한다.

 

이번 연구에서 만들고자 하는 일반적인 시스템은 여러 테스크를 수행해야 하기 때문에, input이 같아도 task가 다르면 output이 다르게 나와야 한다. 즉, 2가지 조건(input, task)을 통해 output이 나와야 한다는 것이다.

(task 조건은 모델 구조 및 알고리즘 단계에서 구현되어 왔지만) McCann et at. (2018) 연구에서는, 단어 시퀀스로 task, input, output을 지정할 수 있는 방법을 제시했고, 이 방법으로 단일 모델이 여러 테스크 수행할 수 있음을 보여줬다. 

 

언어 모델링은 (McCann et al. (2018) 연구는 와 다르게) 지도 학습 없이 여러 테스크를 배울 수 있다.

왜냐하면 지도 학습과 비지도 학습의 목표 함수가 거의 비슷하고, 이는 "지도 학습과 비지도 학습의 전역 최소값이 같다"는 것을 의미하기 때문이다.

 

더보기
At the core of our approach is language modeling.
Language modeling is usually framed as unsupervised distribution estimation from a set of examples $(x_1, x_2, \cdots, x_n)$ each composed of variable length sequences of symbols $(s_1, s_2, \cdots, s_n)$.
Since language has a natural sequential ordering, it is common to factorize the joint probabilities over symbols as the product of conditional probabilities: $p(x) = \prod_{i=1}^n p(s_n | s_1, \cdots, s_{n-1})$This approach allows for tractable sampling from and estimation of $p(x)$ as well as any conditionals of the form $p(s_{n-k}, \cdots, s_n | s_1, \cdots, c_{n - k -1})$.
Since a general system should be able to perform many different tasks, even for the same input, it should condition not only on the input but also on the task to be performed. That is, it should model $p(output | input, task)$.
language provides a flexible way to specify tasks, inputs, and outputs all as a sequence of symbols.
McCann et al. (2018) demonstrated it was possible to train a single model, the MQAN, to infer and perform many different tasks on examples with this type of format.
Language modeling is also able to, in principle, learn the tasks of McCann et al. (2018) without the need for explicit supervision of which symbols are the outputs to be predicted. Since the supervised objective is the same as the unsupervised objective but only evaluated on a subset of the sequence, the global minimum of the unsupervised objective is also the global minimum of the supervised objective.

2.1. Training Dataset

이번 연구에서는, 테스크에 대한 자연어 설명을 다양한 도메인과 맥락에서 수집하기 위해 크고 다양한 데이터 세트을 구축해야 한다.

 

(Common Crawl은 데이터 질이 매우 떨어져) 데이터 질 위주로 새로운 웹 스크립트를 만들었다. 사람이 직접 검수한 웹 페이지만 스크립했다. (e.g., 레딧 3카르마 이상 링크) 결과 데이터 세트인 WebText는 4500만 링크를 가지고 있다.

 

더보기
Our approach motivates building as large and diverse a dataset as possible in order to collect natural language demonstrations of tasks in as varied of domains and contexts as possible.
we created a new web scrape which emphasizes document quality. To do this, we only scraped web pages which have been curated/filtered by humans.
we scraped all outbound links from Reddit, a social media platform, which received at least 3 karma.
The resulting dataset, WebText, contains the text subset of these45 million links.

2.2. Input Representation

유니코드 문자열을 UTF-8 시퀀스로 처리하면 요구 사항(e.g., out-of-vocabulary tokens)이 처리되지만, byte-level(=UTF-8) 언어 모델은 word-level(=유니코드) 언어 모델보다 성능이 떨어진다.

 

BPE는 자주 나타나는 문자열을 병합하는 방식으로 character-level 모델과 word-level 언어 모델 사이를 보간하는 실용적인 방법이다.

byte-level BPE(BPE는 유니코드 기반인 반면 byte-level BPE는 바이트 기반이다.)는 greed frequency이기에 최적화 병합이 안 이루어진다. (e.g., dog. dog! dog?)

이 문제를 해결하기 위해선, 다음과 같이 기법을 수정해야 한다. 1). 서로 다른 문자 종류는 병합하지 않는다. 2). (압축 효율성을 크게 향상시키기 위해) 예외 문자를 추가한다.

 

더보기
While processing Unicode strings as a sequence of UTF-8 bytes elegantly fulfills this requirement as exemplified in work such as Gillick et al. (2015), current byte-level LMs are not competitive with word-level LMs on large scale datasets such as the One Billion Word Benchmark (Al-Rfou et al., 2018).
Byte Pair Encoding (BPE) (Sennrich et al., 2015) is a practical middle ground between character and word level language modeling which effectively interpolates between word level inputs for frequent symbol sequences and character level inputs for infrequent symbol sequences.
a byte-level version of BPE only requires a base vocabulary of size 256. However, directly applying BPE to the byte sequence results in sub-optimal merges due to BPE using a greedy frequency based heuristic for building the token vocabulary.
To avoid this, we prevent BPE from merging across character categories for any byte sequence. We add an exception for spaces which significantly improves the compression efficiency while adding only minimal fragmentation of words across multiple vocab tokens.

2.3. Model

모델은 전반적으로 GPT를 따르지만, 몇 가지 수정사항이 있다. (자세한 내용은 논문을 참고해주세요.)

 

더보기
The model largely follows the details of the OpenAI GPT model (Radford et al., 2018) with a few modifications.

3. Experiments 

이번 연구에서는, 크기가 다른 4개의 언어 모델을 학습하고 평가할 것이다.

WebText 5% 샘플의 PPL 점수로 언어 모델 학습률을 조정할 것이다. 즉, 가장 높은 PPL 점수가 나온 학습률로 학습을 진행할 것이다.

 

더보기
We trained and benchmarked four LMs with approximately log-uniformly spaced sizes.
The learning rate of each model was manually tuned for the best perplexity on a 5% held-out sample of WebText.

3.1. Language Modeling

zero-shot 조건에서 여러 테스크를 수행하기 전, WebText 언어 모델들이 zero-shot 조건에서 복수 도메인의 언어 모델링을 어떻게 수행하는지 확인보자.

이번 실험에서는, 데이터 세트의 로그 확률을 계산한 후, 토큰 개수로 나누어 WebText 언어 모델들을 평가할 것이다.

여러 데이터 세트를 평가할 경우, Webtexts 언어 모델은 학습된 분포(?)에 심하게 벗어난 것(즉, WebText 데이터 세트에서는 보기 힘든 것), 예를 들어 1) 단절된 구두점, 2) 뒤섞인 문장들, 3) <UNK>도 평가해야 한다.

실험 결과, WebText 언어 모델들은  zero-shot 조건에서 복수 도메인의 언어 모델링을 잘 수행했다. (8개 중 7개 데이터 세트의 SOTA 결과를 갱신했다.)

 

더보기
As an initial step towards zero-shot task transfer, we are interested in understanding how WebText LM's  perform at zero-shot domain transfer on the primary task they trained for - language modeling.
We evaluate the same quantity by computing the log-probability of a dataset according to a WebText LM and dividing by number of canonical units.
For many of these datasets, WebText LMs would be tested significantly out-of-distribution, having to predict aggressively standardized text, tokenization artifacts such as disconnected punctuation and contractions, shuffled sentences, and even the string <UNK> which is extremely rare in WebText - occurring only 26 times in 40 billion bytes.
WebText LMs transfer well across domains and datasets, improving the state of the art on 7 out of the 8 datasets in zero-shot setting.

3.2. Children's Book Test

CBT는 각 범주의 단어들(e.g., 명사, 동사, 전치사)을 잘 예측하는지 평가하기 위해 만들어졌다.

실험 과정, 1) 각 후보 단어를 생략된 위치에 집어 넣어 문장을 완성시킨 후,  2) WebText 언어 모델로 문장 확률을 계산한다. 3) 확률이 가장 높은 문장에 해당하는 후보 단어를 예측 결과로 지정한다.

실험 결과, 모델 크기가 증가할수록 성능 또한 향상된다. 

 

더보기
The Children's Book Test (CBT) (Hill et al., 2015) was created to examine the performance of LMs on different categories of words: named entities, nouns, verbs, and prepositions.
CBT reports accuracy on an automatically constructed cloze test where the task is to predict which of 10 possible choices for an omitted word is correct. Following the LM approach introduced in the original paper, we compute the probability of each choice and the rest of the sentence conditioned on this choice according to the LM, and predict the one with the highest probability.
As seen in Figure 2 performance steadily improves as model size is increased and closes the majority of the gap to human performance on this test.

3.3. LAMBADA

LAMBADA 데이터 세트는 텍스트의 장거리 의존성을 평가한다. 

실험은 문장의 마지막 단어를 예측하는 것이다. 실험 결과, GPT-2가 SOTA 결과를 갱신했다.

오답을 분석해보니, 대부분의 오답들은 문장의 마지막 단어가 아닌, 문장을 이어주는 단어였다. 더 나아가, "마지막 단어 필터"를 추가하여 실험을 해보았더니, 성능이 향상됐다.

 

더보기
The LAMBADA dataset (Paperno et al., 2016) tests the ability of systems to model long-range dependencies in text. The task is to predict the final word of sentences which require at least 50 tokens of context for a human to successfully predict. GPT-2 improves the state of the art from 99.8 (Grave et al., 2016) to 8.6 perplexity and increases the accuracy of LMs on this test from 19% (Dehghani et al., 2018) to 52.66%.
Investigating GPT-2's errors showed most predictions are valid continuations of the sentence, but are not valid final words. This suggests that the LM is not using the additional useful constraint that the word must be the final of the sentence.
Adding a stop-word filter as an approximation to this further increases accuracy to 63.24%, improving the overall state of the art on this task by 4%.

3.4. Winograd Schema Challenge

WSC는 텍스트의 중의성(or 모호함) 해석 능력을 측정해 상식 추론능력을 평가할 것이다.

실험 과정, 1) 모호한 단어를 후보 단어로 대체한 후, 2) 각 문장의 확률 계산한다. 3) 마지막으로, 두 문장의 확률 중 높은 문장에 해당하는 후보 단어를 예측 결과로 결정한다.

실험 결과, 여기서도 GPT-2가 SOTA 결과를 갱신했다.

 

더보기
The Winograd Schema challenge (Levesque et al., 2012) was constructed to measure the capacity of a system to perform commonsense reasoning by measuring its ability to resolve ambiguities in text.
Recently Trinh & Le (2018) demonstrated significant progress on this challenge using LMs, by predicting the resolution of the ambiguity with higher probability. We follow their problem formulation and visualize the performance of our models with both full and partial scoring techniques in Figure 3. GPT-2 improves state of the art accuracy by 7%, achieving 70.70%.

3.5. Reading Comprehension

CoQA는 7가지 도메인의 문서와 대화의 쌍으로 구성되어 있다. 각 대화는 질의자와 응답자간의 대화로 구성되어 있다.

실험은 문서와 (마지막 응답을 제외한) 대화를 근거로 마지막 대화를 (greedy 디코딩 방식으로) 예측하는 것이다.

실험 결과, GPT-2는 지도 학습 없이 $\frac{3}{4}$ 베이스 라인 시스템 성능을 능가했다.

 

더보기
The Conversation Question Answering dataset (CoQA) Reddy et al. (2018) consists of documents from 7 different domains paired with natural language dialogues between a question asker and a question answerer about the document.
Greedy decoding from GPT-2 when conditioned on a document, the history of the associated conversation, and a final token A: achieves 55 F1 on the development set. This matches or exceeds the performance of 3 out of 4 baseline systems without using the 127000+ manually collected question answer pairs those baselines were trained on.

3.6. Summarization

이번 실험에서는, CNN과 Daily Mail 데이터 세트로 모델의 요약 성능을 측정해보았다.

실험 과정, 1) 요약 테스크를 유도하기 위해, TL;DR: 텍스트를 추가했으며, 2) Top-$k$ 디코딩 방식으로 100개 토큰을 생성했다. 3) 생성된 100개 토큰 중 첫 생성 3개 문장만 예측값으로 사용하기로 했다.

실험 결과, 모델이 생성한 요약본은 베이스 라인 성능과 비슷했으며, 기사에서 무작위로 선택한 3개 문장보다 성능이 좋았다.

 

더보기
We test GPT-2's ability to perform summarization on the CNN and Daily Mail dataset (Nallapati et al., 2016). To induce summarization behavior we add the text TL;DR: after the article and generate 100 tokens with Top-k random sampling (Fan et al., 2018) with k =2 which reduces repetition and encourages more abstractive summaries than greedy decoding. We use the first 3 generated sentences in these 100 tokens as the summary.
On the commonly reported ROUGE 1,2,L metrics the generated summaries only begin to approach the performance of classic neural baselines and just barely outperforms selecting 3 random sentences from the article.

3.7. Translation

실험 과정, 1) 번역 테스크를 유도하기 위해, 예시들을 입력으로 들어갔다. 2) greedy 디코딩으로 문장을 번역한다. 3) 첫 생성 문장을 예측값으로 사용한다.

실험 결과, 영어$\rightarrow$프랑스어는 5 BLEU, 프랑스어$\rightarrow$영어는 $11.5 BLEU가 나왔다. 이 결과는 놀라운 결과를 보였다. 대부분의 비영어 토큰을 제거했는데, 어느정도 성능이 나왔기 때문이다.

 

더보기
We test whether GPT-2 has begun to learn how to translate from one language to another. In order to help it infer that this is the desired task, we we condition the language model on a context of example pairs of the format english sentence =french sentence and then after a final prompt of english sentence = we sample from the model with greedy decoding and use the first generated sentence as the translation.
On the WMT-14 English-French test set, GPT-2 gets 5 BLEU
On the WMT-14 French-English test test, GPT-2 is able to leverage its very strong English language model to perform significantly better, achieving 11.5 BLEU.
Performance on this task was surprising to us, since we deliberately removed non-English webpages from WebText as a filtering step.

3.8. Question Answering

사실 유형 질의를 통해, 모델에 정보가 존재하는지 평가할 수 있다.

실험 과정, 1) QA 테스크를 유도하기 위해, 예시들을 입력으로 들어갔다. 2) 질의 답변을 생성한다.

실험 결과, 모델 크기가 성능에 비례하다.

 

더보기
A potential way to test what information is contained within a language model is to evaluate how often it generates the correct answer to factoid-style questions. 
Similar to translation, the context of the language model is seeded with example question answer pairs which helps the model infer the short answer style of the dataset.
model capacity has been a major factor in the poor performance of neural systems on this kind of task as of yet.

4. Generalization vs Memorization

데이터 세트 크기가 증가할수록 데이터 중복 문제가 발생할 가능성이 매우 높아지기에, WebText 데이터 중복 문제가 발생했는지 확인해볼 필요가 있다.

 

WebText 데이터 중복 확인을 위해, (WebText 학습 데이터의 8-grams을 포함하고 있는) 블룸 필터를 사용하기로 했다. (블룸 필터는 (k개 해시함수와 m개 비트로) 집합에 특정 원소 존재 여부를 검사하는데 사용되는 확률형 자료 구조다. 가끔 존재하지 않은 원소를 존재한다고 판단(False Positive)하기에 확률형 자료 구조라고 한다.) 재현율을 높이기 위해, 소문자 영숫자 단어와 단일 공백이 있는 문자열만 포함했다. (글쓴이는 블룸 필터의 FN(=원소가 존재하지 않는데 존재한다고 판단하는 경우)가 없기로 아는데, 왜 재현율($\frac{\text{TP}}{\text{TP + FN}}$)을 높이려는 행위을 하는지 이해가 안된다.) 또한 FP 비율의 상한을 $\frac{1}{10^8}$이 되도록 했다.

 

만들어진 블룸 필터로 평가 데이터 세트와 WebText 학습 데이터 세트의 중복 비율을 계산해보니, 평균 3.2%중복이 존재했다. 하지만 놀랍게도, 많은 데이터 세트는 학습 데이터와 평가 데이터의 평균 중복 비율이 5.9%가 나왔다.

 

중복 문제 분석 결과, WebText 학습 데이터 세트와 평가 데이터 세트의 중복은 작지만 성능 평가에 도움을 주기에 공정한 평가라 할 수 없다. 하지만 기존 데이터 세트의 중복 비율보단 크지 않아 큰 문제가 되지는 않았다.

 

학습 데이터와 평가 데이터의 중복 데이터가 성능 평가에 얼마나 영향을 주는지 이해하고 정량화하는게 중요하다.

현재로썬, 학습 데이터와 평가 데이터를 분할 시, 건전성을 위해 n-gram 기반의 중복 제거 사용을 권장한다.

 

더보기
As the size of datasets increases this issue becomes increasingly likely which suggests a similar phenomena could be happening with WebText. Therefore it is important to analyze how much test data also shows up in the training data.
To study this we created Bloom filters containing 8-grams of WebText training set tokens. To improve recall, strings were normalized to contain only lower-cased alphanumeric words with a single space as a delimiter. The Bloom filters were constructed such that the false positive rate is upper bounded by $\frac{1}{10^8}$.
These Bloom filters let us calculate, given a dataset, the percentage of 8-grams from that dataset that are also found in the WebText training set.
Common LM datasets' test sets have between 1-6% overlap with WebText train, with an average of overlap of 3.2%. Somewhat surprisingly, many datasets have larger overlaps with their own training splits, with an average of 5.9% overlap.
Overall, our analysis suggests that data overlap between WebText training data and specific evaluation datasets provides a small but consistent benefit to reported results. However, for most datasets we do not notice significantly larger overlaps than those already existing between standard training and test sets, as Table 6 highlights.
Understanding and quantifying how highly similar text impacts performance is an important research question.
For now, we recommend the use of n-gram overlap based de-duplication as an important verification step and sanity check during the creation of training and test splits for new NLP datasets.

6. Discussion

이번 연구 결과, 비지도 학습은 유망한 연구 영역임을 시사한다.

 

GPT-2의 제로샷 성능이 GPT-2의 여러 테스크 잠재 성능 기준선을 설정했지만, 미세 조정 시, 고점이 어디일지 모른다. 

뿐만 아니라 더 많은 데이터와 커진 모델 크기가 단방향 표현의 비효율성을 극복할지 모르고 궁금하기에, 나중에 GPT-2를 미세 조정한 후, 벤치마킹 평가(e.g., decaNLP, GLUE)을 해 궁금증을 해소해보려 한다.

 

더보기
Our results suggest that unsupervised task learning is an additional promising area of research to explore.
While zero-shot performance establishes a baseline of the potential performance of GPT-2 on many tasks, it is not clear where the ceiling is with finetuning.
Given the prior success of fine-tuning GPT, we plan to investigate fine-tuning on benchmarks such as decaNLP and GLUE, especially since it is unclear whether the additional training data and capacity of GPT-2 is sufficient to overcome the inefficiencies of uni-directional representations demonstrated by BERT.

7. Conclusion

충분히 다양하고 큰 데이터를 가지고 거대한 언어 모델을 학습하면, 여러 도메인에서 좋은 성능을 얻을 수 있다.

 

더보기
When a large language model is trained on a sufficiently large and diverse dataset it is able to perform well across many domains and datasets.