ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • BERT
    NAVER AI TECH 2023. 6. 29. 03:18

    BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding

     

    개요

    BERT에서 한 가지 알파벳을 뽑으라면 BERT의 'B'를 뽑겠다. 기존 모델에서는 단방향적 접근(unidirectional approach)만 가능했으나 BERT는 양방향적 접근(bidirectional approach)을 통해 SOTA를 달성하였다. 그렇다면 어떻게 양방향적 접근이 가능했을까? MLM(Masked Languange Modeling)이라는 방법을 발견했기에 가능했다. 지금부터 BERT에 대해 알아보자.

     

    서론

    먼저 사전학습(pre-training)을 위해서는 두 가지 접근 방식이 존재한다.

    1. feature-based approach

    The feature-based approach, such as ELMo uses task-specific architectures that include the pre-trained representations as additional features.

    2. fine-tuning approach: GPT-1

    The fine-tuning approach, such as the Generative Pre-trained Transformer introduces minimal task-specific parameters, and is trained on the downstream tasks by simply fine-tuning all pre-trained parameters.

     

    부트캠프에서 feature-based approach에 대해서 배워본 적이 없다. 현재는 사장된 방법이 아닐까? 어쨌든 feature-based approach의 대표주자인 ELMo 같은 경우 left-to-right LM의 representation과 right-to-left LM의 representation을 concatenate하여 사용하는데, 이는 shallow concatenation이며 BERT의 deep bidirectional representations와 대비된다. fine-tuning approach의 대표주자인 GPT-1의 경우 left-to-right LM의 구조에서 벗어나지 못해 BERT의 양방향 구조와 대비된다. 단방향 구조의 경우 맥락(context)이 중요한 Question-Answering과 같은 task에서 치명적인 문제를 야기할 수 있다.

     

    사전학습

    BERT 모델은 MLM(Masked Language Modeling)과 NSP(Next Sentence Prediction)로 사전학습되었다. MLM의 경우 무작위 토큰을 15%의 확률로 선정한 뒤 다음과 같은 조치를 취한다. A. 80%의 확률로 [MASK] 토큰으로 대체한다. B. 10% 확률로 무작위 토큰으로 대체한다. C. 10% 확률로 변경하지 않는다. B와 C의 경우 추론에 사용될 실제 모델과 사전학습 간의 괴리를 줄이기 위해서 사용되었다. 조치가 끝나면 실제 단어를 맞추는 학습을 진행한다. NSP의 경우 문장 A와 문장 B가 주어졌을 때, B가 A 이후에 등장하는 문장인지 맞추는 과제이다. 50%의 확률로 진짜 B를, 50%의 확률로 무작위 B를 배치한 후 학습을 진행한다.

     

    구조

    두 가지 BERT 모델을 사전학습을 통해 생성하였다.

    1. BERT-BASE

    L = 12, H=768, A=12, Total Parameters=110M

    2. BERT-LARGE

    L = 24, H=1024, A=16, Total Parameters=340M

     

    BERT의 입력 구조는 다음과 같다. 입력의 처음은 [CLS] 토큰이 차지하고 있으며 문장이 끝난 후에는 [SEP] 토큰이 추가된다. 각 토큰의 값은 Token Embedding, Segment Embedding, Position Embedding의 합이다.

     

    성능

    압도적인 성능 차이로 SOTA를 달성하였다.

     

    RoBERTa

    Our modifications are simple, they include:
    (1) training the model longer, with bigger batches, over more data.
    (2) removing the next sentence prediction objective.
    (3) training on longer sequences.
    (4) dynamically changing the mask- ing pattern applied to the training data.

     

    'NAVER AI TECH' 카테고리의 다른 글

    Phrase Retrieval Learns Passage Retrieval, Too  (0) 2023.07.05
    Learning Dense Representations of Phrases at Scale  (0) 2023.07.04
    Attention Is All You Need(2)  (0) 2023.06.09
    NextRise 2023, Seoul 회고록  (0) 2023.06.04
    CleanLab  (0) 2023.06.04

    댓글

Designed by Tistory.