인공지능 AI

[인공지능/AI]Few-shot Learning in NLP(자연어처리)

Few-shot Learning 개념

메타 학습에서 나온 갈래로, "Learn to learn"으로 일컫는다.

적은 데이터와 적은 연산으로 학습을 진행한다.

대량의 데이터로 학습하는 일반적 딥러닝 방법론과 다르게, Few-shot Learning은 고양이, 개와 같은 동물 사진 몇개를 가지고 처음 보는 사진의 동물을 분류해냅니다.

Few-shot Learning은 Training set, Support set, Query image를 필요로 한다. Training set으로 구분하는 법을 배우고, Query image를 인풋으로 Support set 중 어떤 것과 같은 종류인지 분류한다. 즉 Query image가 Support set과 같은지 다른 종류인지 판단하는 것.

하지만 Few-shot Learning은 Training set에 없는 클래스를 분류할 수 있어야 한다.

보통 k-way n-shot Learning으로 Few-shot Learning을 표현하는데, k-way는 Support set이 k개의 클래스라는 뜻이고, Query image가 k개 중 어느 것과 같은지 분류한다. k가 높을수록 정확도는 낮아진다.

n-shot은 각 클래스가 가진 sample의 개수 (ex. 고양이 클래스 사진 n개)로 n이 높을수록 정확도가 높아진다.

Train 과정:

즉, similarity 학습(같은지 다른지)

3개의 클래스(a고양이, b고양이, c강아지)

sim(a,b)=1, sim(a,c)=0, sim(b,c)=0

위와 같이 Positive set 1개, Negative set 2개로 dataset이 마련되었다.

이를 CNN 모델로 학습한다.

Few-shot Learning Prediction 과정:

Query image: 고양이 사진

결과: 강아지(sim=0.2), 햄스터(sim=0.5), 수달(sim=0.3), 고양이(sim=0.9), 호랑이(sim=0.6)

Few-shot Learning in NLP(자연어처리)

1.

Meta 학습의 Few-shot Learning을 NLP로 적용한 논문으로 유명한 OpenAI의 세번째 논문,

Language Models are Few-Shot Learners

"Language Models are Few-shot Learners"를 참고하면 좋다.

논문에서 소개된 GPT-3 모델은 전신인 GPT-2모델과 마찬가지로 Transformer 모델을 기반으로 한 구조입니다.

2.

구글 논문_빈칸 단어들 관계 추출(학습)

Matching the Blanks: Distributional Similarity for Relation Learning

  • Matching the Blanks 구글 논문 간단한 (노트테이킹 요약에 가까운) 리뷰we propose a new method of learning relation representations directly from text.present a method of training this relation representation without any supervision from
    a knowledge graph or human annotators by matching the blanks.Han et al, 2018 의 Few-shot Learning 논문을 더 디벨롭한 연구다. Training by matching the blanks 해서 더 성능이 능가하였다.1) fully supervised relation extraction2) few-shot relation matching
    adding positional information in the input이 중요.blank entity 끼리 관계성 추출하기 위한 architecture는 다음과 같다. deep Transformers networkfor any pair of relation statements r and r', the inner product fθ(r)^T fθ(r') should be high if the two relation statements, r and r', express semantically similar relations.r = (x, s1, s2) is more likely to encode the same semantic relation as r' = (x', s'1, s'2) if s1 refers to the same entity as s'1, and s2 refers to the same entity as s'2.→binary classifier로 r과 r' 인코딩이 relation이 0인지 1인지 구별.
    이런식으로 e1과 e2 pair 관계성 positive/negative 판단Finally, we probabilistically replace each entity’s mention with [BLANK] symbols.5.1 Few-shot Relation MatchingBERTEM+MTB only needs 6% of the training data to match the performance of a BERTEM model trained on all of the training data. (적은 데이터로도 training 잘된다는 소리)
  • (BERT 임베딩+Matching the blanks(MTB) evalution 성능평가)
  • In total, we generate 600 million relation statement pairs from English Wikipedia, roughly split between 50% positive and 50% strong negative pairs.
  • 모든 relation r과 r'를 same pair of entities가지는지 모두 비교연산하는 건 불가능하기에, noise-contrastive estimation을 추가로 사용한다. we sample a set of negatives that are either randomly sampled uniformly from the set of all relation statement pairs.
  •  
  • corpus D (corpus of relation statements that have been labeled with two entities) contains a relation statement in which one or both entity mentions may have been replaced by a special [BLANK] symbol.
  • We introduce this method of learning by matching the blanks (MTB).
  • And, this inner product should be low if the two relation statements express semantically different relations.
  • 4 Learning by Matching the Blanks
  • 왼쪽이 1) supervised, 오른쪽이 2) few-shot
  • we evaluate on the FewRel (Han et al., 2018) dataset.
    Specifically, we are given K sets of N labeled relation statements Sk = {(r0, t0). . .(rN , tN )}
    where ti ∈ {1 . . . K} is the corresponding relation type. The goal is to predict the tq ∈ {1 . . . K} for a query relation statement rq.
  • given a relation statement r, predict a relation type t ∈ T
    where T is a fixed dictionary of relation types and
    t = 0 typically denotes a lack of relation between the entities in the relation statement
  • 사용한 supervised relation extraction 방식은 두 가지인데,
  • 자세한 방법 설명) Our training procedure takes in pairs of blank-containing relation statements, and has an objective that encourages relation representations to be similar if they range over the same pairs of entities
  • 큰 틀 소개) 먼저 transformer 구조로 encode relations between entity pairs 그 다음
  •  

3.

 

"Few-shot relation classification by context attention-based prototypical networks with BERT"

BERT 이용한 Few-shot Learning 논문

이 논문에서 BERT 이용한 NLP에서의 Few-shot Learning 구조는

1) sentence encoder, 2) prototypical networks, 3) context attention

4.

Calibrate Before Use: Improving Few-Shot Performance of Language Models

GPT-3의 단점(language model의 bias가 특정 답을 예측) 보완

→ training set이나 N/A 인풋에 대한 bias 조절, 모든 답 예측이 일정하도록 calibration parameter 보완