NL-072, TransferTransfo: A Transfer Learning Approach for Neural Network Based Conversational Agents (2018-NeurIPS CAI Workshop)
■ Comment
- 논문의 방법은 개인적인 입장에선 매우 친숙한 방법이다.
- 논문을 읽다보면, task만 다르지 사실상 방법이 거의 비슷한 것이 많이 보인다..
- 물론 그러한 방법들이 데이터별로 조금씩 다르긴 하다만
- 방법론은 Dialog state embedding이란 것으로 BERT로 치면, 문장을 구분하는 embedding 처럼 personality sentence인지 대화 sentenece인지 임베딩해주는 것이다.
- 또한 special tokens으로 문장 맨 끝에 [CLS]을 추가하여 classification을 하는 것이 있다.
- 백본은 GPT로 pretrained 모델을 활용한 것이다.
- Decoding details을 보면, beam-search와 n-gram filtering, ranking으로 최종 출력을 결정하는 식이다.
- 이 논문은 HuggingFace가 쓴 것으로 당연히 huggingface 깃허브에서 코드를 제공한다.
- 개인적으론, 이러한 방법들이 간단하면서 성능도 참 좋은 것 같다.
- SoTA 모델의 논문인 impressed me에서 이 논문과 비교한 성능이 있는데 큰 차이가 없는 듯 해보임.
0. Abstract
- 우리는 TransferTransfo라 불리는 data-driven 대화 시스템 (예. 챗봇)으로 생성하는 새로운 접근법을 제시한다.
- 이는 학습 기법을 기반으로 Transfer learning과 high-capacity Transformer model의 조합이다.
- Fine-tuning은 여러 개의 unsupervised prediction tasks으로 결합된 multi-task objective을 이용해서 수행된다.
- 그 결과로 fine-tuned 모델은 memory augmented seq2seq and information-retrieval models와 같은 현재 SoTA end-to-end 대화 모델보다 더 강한 성능을 보여준다.
- ConvAI2 챌린지의 비공개 PERSONA-CHAT 데이터세트에서 이 접근법은 SoTA을 얻었고 각각 PPL, Hits@1, F1이 16.28 (45% absolute improvement), 80.7 (46% absolute improvement) and 19.5 (20% absolute improvement)을 가진다.
1. Introduction
- Non-goal-oriented 대화 시스템들은 (챗봇들) 상호적인 NLP을 위한 흥미로운 test-bed이고 직접적으로 technical support services부터 entertainment에 이르기까지 넓은 application에 유용하다.
- 그러나, 지능형 대화 agents을 설계하는 것은 AI에서 풀리지 않는 문제로 남아있다.
- 최근에는, RNN 기반 모델들이 충분한 capacity와 큰 데이터세트에 접근하면서 많은 관심을 받고 있다.
- Vinyals and Le (2015)은 그들이 칫챗 세팅에서 의미있는 response을 생성함을 보여준다.
- 그럼에도 불구하고, 이러한 뉴럴네트워크 구조 및 개발 능력의 추가적인 요구는 그들이 사람이 경험한것보다 불만족스럽게 대화하는 한계를 가지고 있다.
- The main issues with these architectures can be summarized as:
- (i) the wildly inconsistent outputs and the lack of a consistent personality (Li and Jurafsky, 2016),
- (ii) the absence of a long-term memory as these models have difficulties to take into account more than the last dialogue utterance; and
- (iii) a tendency to produce consensual and generic responses (e.g. I dont know) which are vague and not engaging for humans (Li, Monroe, and Jurafsky, 2016).
- 이 연구에서, 우리는 좀 더 일관성있고 관계있는 data-driven 대화 agents을 향할 것이다.
- 우리의 모델은
- (i) relevance of the answer
- (ii) coherence with a predefined personality and dialog history, and
- (iii) grammaticality and fluency as evaluated by automatic metrics
- 위 3개에 관하여 전통적인 seq2seq와 information-retrieval 베이스라인에서의 중요한 향상이 가능한 학습과 생성 방법의 구조이다.
2. Tasks and evaluation
- open-domain 대화 agent의 퀄리티를 측정하는 흥미로운 챌린지는 ConnAI2로 NIPS 2018에서 열렸고 우리는 이 데이터를 사용했다.
- ConVAI2는 PERSONA-CHAT 데이터세트를 기반으로하고 크라우드소스된 대화 데이터세트로 각 화자가 사전 정의된 profile에서 대화를 조절하도록 요청한다.
- 좀 더 보니까 convai.io에 다음과 같은 언급이 있다.
- To avoid modeling that takes advantage of trivial word overlap, we crowdsourced additional rewritten sets of the same personas, with related sentences that are rephrases, generalizations or specializations, rendering the task much more challenging.
- 실제로 데이터세트를 PERSONA-CHAT과 convai2와 비교해보니, 다음과 같이 구성된다.
- # personachat: 8939, 1000, 968 = 10907
- # convai2: 17878, 1000
- 즉 이 논문에서는 convai2로 실험을 했고 후속 연구들도 convai2의 데이터를 쓰는 추세같다.
- profile은 그림 1처럼, personality을 정의하는 몇 개의 문장으로 구성된다.
- 쌍지어진 workers은 자연스럽게 대화하도록 요청받았고 대화중에 서로를 알려고 한다.
- 이것은 우리가 표 1에서 재현 한 예에서 볼 수 있듯이 빠른 주제 전환으로 흥미로운 데이터 세트를 생성했습니다.
- automatic 평가는 여전히 대화시스템에서 open question이다.
- PERSONA-CHAT 데이터세트는 3가지 automated mterics을 evaluation set에 대해 취한다.
- ConvAI2 챌린지는 사람의 평가와 함께 PERSONA-CHAT의 비공개로 이러한 지표를 평가했습니다.
- automatic metrics은 같은 데이터세트에서 정의된 3가지 테스크에 대해 수행된다.
- (i) a language modeling task where the metric is the perplexity of gold utterance tokens as computed from the model’s next token probability predictions (denoted PPL)
- 여기서는 gold reference가 정답이라고 PPL을 구하는 듯. (즉 greedy하게 계산하는 느낌)
- 전에 내가 실험했던 style transfer과 비교해보면, 그때는 LM 모델링을 따로 학습하고나서, LM 모델이 predict하는 token distribution이 정답이라고 생각하고 PPL을 구한다.
- (ii) a next utterance retrieval task where the associated metric is the accuracy of retrieving a gold next utterance among 19 random distractor responses sampled from other dialogues (denoted Hits@1) and
- (iii) a generation task which consists in generating a response in the dialog setting and where the metric is the F1 (precision and recall) of the content words of a gold dialog utterance in the predicted utterances (denoted F1).
- 사람 평가자들은 4가지의 조합으로 평가를 한다.
- fluency, 유창성
- consistency, 일관성
- engagingness (each evaluated as a grade between 1 and 5), 매력적
- whether the human could guess the persona used by the bot (selection between two possible personas), persona 추측성
3. Model
- TransferTransfo에서 사용된 생성 모델은 multilayer Transformer encoder이고 GPT을 기반으로 한다.
- 이 모델은 크고 original Transformer을 따른다.
- 자연어 처리에 편재 된이 최신 모델 아키텍처에 대한 자세한 내용은 Harvard SEAS 자연어 처리 그룹 인 Annotated Transformer에서 최근 발행 한 상세 안내서를 참조하십시오.
- We used a 12-layer decoder-only transformer with masked self-attention heads (768 dimensional states and 12 attention heads).
- masked attention에 의해, 우리는 Transformer가 모든 토큰이 왼쪽 context만 attend하는 constrained self-attetnion을 사용한다는 것이다.
- In the literature this version of the Transformer is often referred to as a Transformer decoder since it is similar to the decoder part of the original encoder-decoder Transformer of Vaswani et al. (2017).
- 이 모델은 최근 여러 연구에서 down-stream NLP tasks에서 놀라운 성능을 보여주는 large Transformer model과 유사하디.
- 우리의 모델은 HuggingFace 팀에의해 제공된 PyTorch을 기반으로 한다.
- Radford et al .; Devlin et al. 이 모델은 지원되는 시퀀스 길이가 최대 512 토큰인 학습 된 위치 임베딩을 사용합니다.
- 입력 문장은 40,000 개의 병합으로 바이트 쌍 인코딩 (BPE) 어휘를 사용하여 사전 처리되고 토큰 화됩니다 (Sennrich, Haddow 및 Birch, 2015).
4. Training
4.1 Pre-training
- Radford (GPT)의 연구는 7,000 unpublished books (about 800M words)을 포함한 BookCorpus 데이터세트로 pretrained 되었다.
- books에는 다양한 장르 (Adventure, Fantasy, Romance...) 을 포함한다.
- pre-training 데이터세트의 중요한 선택은 long contiguous sequences와 parahraphs와 long-range information에 대한 조건을 배우는 것의 장점을 활용해서 shuffled sentence-level corpus가 아닌 document-level corpus을 사용하는 것이다.
- 이것은 ELMo에서 사용된 Billion Word Benchmark와 같은 shuffled sentence-level corpora이 불가능한 것이다.
- ELMo는 sentence-level로만 했다는 것!
- We used the pre-trained model weights open-sourced by Radford et al.
4.2 Fine-tuning
- pre-training step 이후에, 모델은 augmented input representation and a multi-task learning scheme을 사용해서 PERSONA-CHAT 데이터세트에 fine-tuned 되었다.
4.2.1 Input representation
- 우리는 모델의 input representation이 switch을 할 수 있게 적용한다.
- BookCorpus 데이터세트와 같은 단독 화자(혹은 unannotated) 세팅에서부터 두 명의 화자 세팅에 personality sentences을 더하는 PERSONA-CHAT 데이터세트까지
- 즉 GPT때와 다르게 personality sentences을 embedding하여 plus하여 세팅했다는 말인듯
- 좀 더 구체적으로, 모델을 위한 input tokens의 시퀀스는 각 utterance로 구성이 되는데
- utterances는 현재 화자의 persona sentences(usually 4 to 6 sentences in the PERSONA-CHAT dataset)와 이전 대화 히스토리(typically 3 to 5 previous utterances)의 concatenating으로 구성된다.
- input tokens의 시퀀스로부터, input embeddings의 시퀀스는 다음과 같이 구성된다.
- pretraining동안 학습된 word와 positional embeddings은 dialog-state embeddings의 set으로 증강된다. (그림 1처럼)
- 그림 1보면 pretraining에 없던, dialog-state embeddings이 추가된 것
- 추가적인 embeddings 세트들은 현재 토큰이 다음의 part 어디에 속하는지를 가리킨다.
- (i) a personality sentence
- (ii) an utterance from PERSON1
- (iii) an utterance from PERSON2.
- BERT에서 previous sentence인지 next sentence인지 구별하는 개념과 유사한 듯
- Transformer 모델의 self-attention block 입력은 그리고나서 각 단어에서 3 타입의 embeddings (word, dialog-state and positional)을 더한다.
- Separation tokens may also be added to further separate each utterances of the dialog as it is commonly done for Transformer’s inputs (Radford et al., 2018; Devlin et al., 2018).
- 이거는 BERT, GPT에서 쓴 것처럼 [SEP]으로 utternaces을 분리하는데 사용이 될 수 있다고 한다. 여기서 쓴 것 같지는 않음
- pretraining에서 finetuning으로 다른 간단한 적용으로는 personality sentence의 순서에 대한 불변성을 각 personality sentences을 위한 같은 positional embeddings을 재사용함으로써 촉진시킨다.
- personality 문장들은 실제로 순서라는 개념이 없기 때문에 positional embeddings을 같은 값으로 가져간다는 말인 듯
- 이것은 Set Transformer과 비슷하다고 함.. (저 논문은 한국에서 썼던데 안 읽어봄)
- Self-attention 모델은 본질적으로 position과 oreding에 둔감하고 이 feature은 편리하게 positional 불변성을 향한 bias로 활용가능한다.
- 위처럼 postional embeddings을 같은 값을 가져감으로써 아래에서 말한 듯이, personality sentences의 순서가 영향을 미치지 않도록 self-attention 모델은 설계되어 있다는 것을 말하는 듯?
- 한가지 흥미로은 불변성은 conditional 대화 PERSONACHAT dataset와 같은 데이터세트에서 관측이 된다.
- 대화를 조절하는 personality 문장의 다양한 순서 측면에서 예측된 담화의 불변성을 가진다.
- 이해한바로는, PERSONACHAT 데이터세트에서 personality 문장의 순서에 따라서 예측되는 utternaces은 같아야 한다.
- 따라서 이 비슷한 효과를 얻기 위해, 학습 데이터에서 personality sentences을 셔플링하여 데이터 증강 효과를 얻을 수 있다. 하지만 여기서는 self-attention은 이걸 안쓰는 듯 함.
4.2.2 Multi-task learning
- Fine-tuning은 두 개의 loss로 optimizing된다.
- (i) a next-utterance classification loss,
- (ii) a language modeling loss.
- next-utterance classification loss은 그림 2에서 설명하고 BERT에서의 Next Sentence Prediction와 비슷하다.
- 랜덤하게 샘플링된 distractors의 (실제로, 2~6개의 랜덤샘플된 utterances) 세트와 입력 시퀀스에 correct next utterance가 append된 것을 classifier가 구별하도록 학습이 구성된다.
- 즉 next utternace가 correct인지 아닌지를 판별하는 classifier
- classifier은 linear layer로 last hidden state of the self-attention model을 input으로 받고 score을 계산한다.
- classification special token [CLS]가 문장에 추가된다 (그림 2처럼)
- last hidden state은 classifier에 사용되고 termination special token과 관련된 hidden state에 대응된다.
- 원래 BERT에서는 [CLS]가 앞에 있는데 여기서는 맨 뒤에 붙여서 사용한다는 것
- 계산된 scores은 softmax layer을 통과하여 classification 확률을 얻는다.
- 아마 [1,0], [0,1] 이렇게 구하는 듯함. (sigmoid로 [0], [1] 대신에)
- Transformer의 파라미터와 next-utteracne classifier은 finetuned jointly to maximize the log-probability of the correct label.
- LM loss은 일반적으로 cross-entropy loss을 사용하고 self-attention의 final hidden state은 vocabulary의 출력 softmax에 들어가서 next token 확률을 구한다.
- 이러한 확률은 gold next tokens을 레이블로 사용되는 negative log-likelihood loss을 사용해서 계산된다.
4.2.3 Fine-tuning details
- We fine-tuned the model with a batch size of 32 sequences having an average of 250 tokens depending on the batch for 200,000 steps, which is approximately 2 epochs over the PERSONA-CHAT training dataset (32 sequences * 250 tokens = 8,000 tokens/batch).
- We used Adam with a learning rate of 6.25e-5, β1 = 0.9, β2 = 0.999, L2 weight decay of 0,01 and a coefficient of 2 on the Language Modeling loss when summing with the next-utterance classification loss losses.
- The learning rate was linearly decayed to zero over the course of the training.
- We use a dropout probability of 0.1 on all layers.
- Following Radford et al. we use a relu activation function.
- Fine-tuning the model took about 10h on four K80 GPUs.
4.2.4 Decoding details
- Generation was performed using beam search with sampling and a small beam size of 4.
- 빔서치 4을 사용해서 4개의 후보 문장 생성
- Simple n-grams filtering is used to ensure the model doesn’t directly copy from the personality sentences (forbidden by the ConvAI2 rules) as well as older utterances.
- n-gram 필터링으로 personality sentences와 단어가 너무 많이 중복되면 후보에서 제거
- The final beams are ranked according to a scalar combination of the length-normalized utterance probability and the next utterance classification score.
- final beams은 length normalized한 것과 next utterance classification score 두 개의 결합으로 랭크매김.
- next-utterance classification score의 중요성을 높이면 제공된 personality 문장에 더 밀접하게 대응하지만 대화의 다양성도 감소하는 발화가 발생합니다.
5. Results
- PERSONA-CHAT 데이터 세트의 공개 평가 분할 및 비공개 테스트 분할에 대한 결과가 표 2에 나와 있습니다.
- TransferTransfo은 기존의 시스템들보다 더 좋은 성능을 가진다.
- 51% absolute improvement in perplexity (PPL),
- 35% absolute improvement in Hits@1 and 13% improvement in F1.
- 좀 더 중요하게, 모델의 하이퍼파라미터들은 validation에 대해서만 tuned 되었고 성능 향상은 private test set으로 전달되었다.
- ConvAI2 evaluation server에서 스코어 매긴다.
- 45% absolute improvement in perplexity (PPL),
- 46% absolute improvement in Hits@1 and 20% improvement in F1.
- 여기서 validation이 training을 포함하는 개념으로 쓴 거겠지? 위에서 fine-tuning할 때 학습 데이터를 쓴다고 했으니까..
- 각 대화의 시작 부분에 (”Hello, how are you?”) 나오는 시작 및 personality sentences의 copy mechanisms와 같이 데이터 집합의 일부 반복적 인 부분으로 인해 부분적으로 존재할 수있는 open domain LM 태스크의 PPL이 현저히 낮습니다.
Reference
댓글
댓글 쓰기