2. Question Answering 문제란?
Machine Reading Comprehension
Question : 큐리오시티 활동 지역의 최저 온도는?
Answer : -127도
Question : 화성 로버가 겪는 가장 큰 문제는?
Answer : 패널의 먼지
Paragrap
Answer = Model(Paragraph, Question)
Model
Model
3. BASE LINE 정의
본 발표에서는 BERT Original 을 BASE LINE 으로 정의하고자 함
Squad2.0 Squad1.1
10%
▲
4%
▲
BERT
Original
AlBert
XLNet
4. BASE LINE 연구의 이해 (Original BERT)
MRC 문제를 위한 훈련 데이터 구성 이해
"context":"One of the most famous people born in Warsaw was Maria
Sku0142odowska-
Curie, who achieved international recognition for her research on
radioactivity and was the first female recipient of the Nobel Priz
e. Famous musicians include Wu0142adysu0142aw Szpilman and Fru0
0e9du00e9ric Chopin. Though Chopin was born in the village of u0
17belazowa Wola, about 60 km (37 mi) from Warsaw, he moved to the
city with his family when he was seven months old. Casimir Pulaski
, a Polish general and hero of the American Revolutionary War, was
born here in 1745.",
"qas":[
{
"answers":[
{
"answer_start":188,
"text":"Nobel Prize"
}
],
"question":"What was Maria Curie the first female recipien
t of?",
"id":"5733a5f54776f41900660f45"
}
SQAUD1.1 에서 제공하는 Data Format
5. BASE LINE 연구의 이해 (Original BERT)
MRC 문제 해결을 위한 FINE TUNNING 방안 제시
Multi Head Attention
Input Embedding
Positional Embedding
Add & Norm
Feed Forward
Add & Norm
[CLS
]
QUESTIO
N
[SEP] PARAGRAP
H
PARAGRAP
H
768
x
w
split
Start 확률 End 확률
x
split
Start 확률 End 확률
768
2
… …
w
768
2
x x x
위치별 Start
Token 확률 예측
위치별 End
Token 확률 예측
Start Token
정답 위치
End Token
정답 위치
Start Loss = Cross Entropy(Y^, Y) End Loss = Cross Entropy(Y^, Y)
Total Loss = (Start Loss + End Loss) / 2
BERT 기본 구
조
MRC 문제를 위한 FINE TUNNING
7. 기존 연구(Original BERT)의 문제
Ⓐ 요구되는 메모리 과다, ⓑ 훈련시간 과다, ⓒ 파라메터 수의 최적화 미비 등 3가지 문제
1. 필요한 파라메터와 메모리 증가에 따른 하드웨어적인 이슈 (※ 특히 MRC 문제를 예로 하고 있음)
An obstacle to answering this question is the memory limitations of available hardware. Given that current
state-of-the-art models often have hundreds of millions or even billions of parameters, it is easy to hit these
limitations as we try to scale our models.
Training speed can also be significantly hampered in distributed training, as the communication overhead is
directly proportional to the number of parameters in the model
2. 훈련에 소요되는 시간 문제 (TPU 16장으로 8일, 일반적인 GPU로는 수 개월 소요)
We also observe that simply growing the hidden size of a model such as BERT-large (Devlin et al., 2019)
can lead to worse performance
3. 파라메터 수의 증가가 성능의 향상으로 이어지지 않음(Large 모델 기준 X2의 경우 오히려 성능 하락)
8. 제안 방법
Factorized embedding parameterization
1. Factorized embedding parameterization
As such, untying the WordPiece embedding size E from the hidden layer size H allows us to make a more
efficient usage of the total model parameters as informed by modeling needs, which dictate that H > E.
Therefore, for ALBERT we use a factorization of the embedding parameters, decomposing them into two
smaller matrices. Instead of projecting the one-hot vectors directly into the hidden space of size H, we first
project them into a lower dimensional embedding space of size E, and then project it to the hidden space.
O(V × H) 🡺 O(V × E + E × H)
A
B
C
D
E
F
H
V
…
A
B
C
D
E
F
E
(H>E)
V
…
H
E
30,000 * 768 = 23백만 30,000 * 200 = 6백만 200 * 768 = 15만
= x
+>
※ Embedding 에 필요한 파라메터 수의 감소
9. 제안 방법
Cross-layer parameter sharing
2. Cross-layer parameter sharing
For ALBERT, we propose cross-layer parameter sharing as another way to improve parameter efficiency.
There are multiple ways to share parameters, e.g., only sharing feed-forward network (FFN) parameters
across layers, or only sharing attention parameters.
Multi Head Attention
Add & Norm
Feed Forward
Add & Norm
Multi Head Attention
Add & Norm
Feed Forward
Add & Norm
Block-2
Block-1
Scaled Dot Product Attention
Multi Head Attention
Shared Weight
10. 제안 방법
Inter-sentence coherence loss
3. Inter-sentence coherence loss
However, subsequent studies (Yang et al., 2019; Liu et al., 2019) found NSP’s impact unreliable and
decided to eliminate it, a decision supported by an improvement in downstream task performance across
several tasks.
We conjecture that the main reason behind NSP’s ineffectiveness is its lack of difficulty as a task.
That is, for ALBERT, we use a sentence-order prediction (SOP) loss. The SOP loss uses as positive
examples the same technique as BERT (two consecutive segments from the same document), and as
negative examples the same two consecutive segments but with their order swapped
Seq A
Sentence
Seq B
Sentence
Random
Sentence
Seq A
Sentence
True
False
positiv
e
negative
Seq A
Sentence
Seq B
Sentence
Seq A
Sentence
Seq B
Sentence
True
False
NSP : Next Sentence Prediction SOP : Sentence Order Prediction
11. 전체적인 실험 결과 (※ 자체 구현 後 실험 결과)
Able to Check our test code here : https://github.com/jeehyun100/text_proj
https://github.com/jeehyun100/text_proj
{
"exact": 80.87038789025544,
"f1": 88.67964179873631,
"total": 10570,
}
Albert(파라메터 사이즈 :
48M)
{
"exact": 80.21759697256385,
"f1": 87.94263692549254,
"total": 10570,
}
Bert(파라메터 사이즈 :
414M)
더 적은 파라메터 수로 더 높은 성능 달성
12. 상세 실험 결과
Factorized embedding parameterization
※ 상세한 실험 내용은 직접 검증하지 못하고 논문의 내용을 중심으로 설명 합니다.
1. Factorized embedding parameterization
shows the effect of changing the vocabulary embedding size E using an ALBERT-base configuration setting
(see Table 2), using the same set of representative downstream tasks. Under the non-shared condition
(BERT-style), larger embedding sizes give better performance, but not by much. Under the all-shared
condition (ALBERT-style), an embedding of size 128 appears to be the best. Based on these results, we
use an embedding size E = 128 in all future settings, as a necessary step to do further scaling.
13. 상세 실험 결과
Cross-layer parameter sharing
※ 상세한 실험 내용은 직접 검증하지 못하고 논문의 내용을 중심으로 설명 합니다.
2. Cross-layer parameter sharing
The all-shared strategy hurts performance under both conditions, but it is less severe for E = 128 (- 1.5 on
Avg) compared to E = 768 (-2.5 on Avg). In addition, most of the performance drop appears to come from
sharing the FFN-layer parameters, while sharing the attention parameters results in no drop when E = 128
(+0.1 on Avg), and a slight drop when E = 768 (-0.7 on Avg).
14. 상세 실험 결과
Inter-sentence coherence loss
※ 상세한 실험 내용은 직접 검증하지 못하고 논문의 내용을 중심으로 설명 합니다.
3. Inter-sentence coherence loss
The results on the intrinsic tasks reveal that the NSP loss brings no discriminative power to the SOP task
(52.0% accuracy, similar to the random-guess performance for the “None” condition). This allows us to
conclude that NSP ends up modeling only topic shift. In contrast, the SOP loss does solve the NSP task
relatively well (78.9% accuracy), and the SOP task even better (86.5% accuracy). Even more importantly,
the SOP loss appears to consistently improve downstream task performance for multi-sentence encoding
tasks (around +1% for SQuAD1.1, +2% for SQuAD2.0, +1.7% for RACE), for an Avg score improvement of
around +1%.
16. 기존 연구(Original BERT 및 GPT )의 문제
BERT 방법은 AE, GPT 방법은 AR 이라고 정의하고 각각의 장단점을 분석함
1. BERT 를 AutoEncoder 모델이라고 정의하며, 다음과 같은 문제를 제기함
- Pretrain 에 사용하는 Mask 는 Fine Tunning 시에는 사용되지 않음 (Gap이 발생)
- Mask 와 Mask 간의 관계가 독립이라는 가정하게 훈련함 (실제로는 관계가 있는데)
- Auto Regressive 모델은 단방향 성이라는 문제를 갖고 있음
2. GPT 를 Auto Regressive 모델이라고 정의하며, 다음과 같은 문제를 제기함
[MASK]
NEW
[MASK]
YORK
is a city
NEW YORK is a city
Relation
?
17. 제안 방법
Contributions
1. Permutation Language Model Objective
- Autoregressive 방법으로 접근하되, 단방향성 문제를 극복하기 위하여 순서를 랜덤하게 재배열
※ 동일한 Input 으로 다른 Output 을 추론해야 하는 논리적인 문제가 발생함
※ 훈련 속도 문제 해결을 위해서 Partial Prediction(마지막 N개만 훈련) 기법을 사용함
2. Two Stream Self-Attention
- 위에 제기한 동일한 Input 으로 다른 Output 을 추론해야 하는 문제를 해결하기 위해 제시
- 쿼리 스트림과 컨탠츠 스트림으로 혼합하여 사용 별도의 순서 정보를 사용하여 위의 문제 해결
3. Segment Recurrence Mechanism
- BERT 구조에서 처리 할 수 있는 최대 길이 이상의 문장등의 효과적인 처리 방안 제시
- 긴 문장을 여러 세그먼트로 나누고 N번째 세그먼트 처리시 N-1 번째 정보를 사용하는 방법 제시
4. Relative Segment Encoding & Relative Positional Encoding
- 위와 같이 Segment Recurrence Mechanism 을 적용하면, Segment간 상대적인 위치 표현이 필요함
- 다른 Segment 의 동일한 위치 토큰 간의 구분이 필요함 (상대적인 위치 표현 필요)
18. 제안 방법
Permutation Language Model
1. Permutation Language Model Objective
- Autoregressive 방법으로 접근하되, 단방향성 문제를 극복하기 위하여 순서를 랜덤하게 재배열
[Auto Regressive
Example]
NEW YORK is a city1 0 0 0 0
Mask Attention (예시) Embedding
Sequence
NEW YORK is a city1 1 0 0 0
NEW YORK is a city1 1 1 0 0
[Permutation Example]
is YORK NEW a city0 0 1 0 0
Mask Attention (예시) Embedding
Sequence
is YORK NEW a city0 1 1 0 0
is YORK NEW a city1 1 1 0 0
NE
W
YOR
K
i
s
a city
NE
W
YOR
K
i
s
a city
19. 제안 방법
Two Stream Self Attention
2. Two Stream Self Attention
- Permutation 방법에서는 똑같은 Input 으로 다른 Output 을 예측해야 하는 논리적 모순 발생
is a NEW city YORKExample
1
is a NEW YORK cityExample
2
- 컨탠츠스트림(기존과 동일)과 쿼리스트림(위치정보) 두 가지 스트림을 혼합하여 위의 문제를 해결
Q,K,V =
Embedding
K,V =
Embedding
Q =
Position
예측할 토큰 예측할 토큰
컨탠츠스트림 쿼리스트림
H = Token
Embedding
g = Trainable
Factor
20. 제안 방법
Segment Recurrence Mechanism
3. Segment Recurrence Mechanism
- 한번에 볼 수 있는 것보다 문장이 더 긴 경우 전체를 Segment로 나누고 앞의 Seg 도 볼 수 있도록 함
NEW YORK is a cityda b c
현재 훈련중인 T 시점의 Segment확장하고 T-1의 Segment
Seg-1 Seg-2 Seg-3
현재 학습 Seg
(BackProp :
True)
한 단계 전 Seg
(BackProp :
False)
Seg-2 Seg-3
a
- Memory 개념의 Permutation Language 모델 훈련시 적용 예시
21. 제안 방법
Relative Positional Encoding
4. Relative Positional Encoding
- 앞쪽의 정보를 보게 되면, 자신의 Segment 내에서 절대적인 Position 이 아닌 상대적 위치 표현이 필요
NEW YORK is a cityda b caEmbedding
절대위치 52 3 41 1 2 3 4 5
상대위치 3- 1 2- 4 - - - -
- Relative Attention 을 사용하여, 상대 위치를 반영한다 (방법은 아래와 같다)
컨탠츠스트림
쿼리스트림
+ M
절대위치 Attention
상대위치 Attention
E : Embedding, U : Position 나눠서 Decompose
U -> R
Cf) SIN, COS 을 사용한 Position Encoding
22. 실제 연구 논문 대비 낮은 성능을 보여주고 있음 🡺 여러가지 Training 과정에서 튜닝이 필요해 보임
{
"exact": 80.21759697256385,
"f1": 87.94263692549254,
"total": 10570,
}
Bert(파라메터 사이즈 :
414M)
{
"exact": 80.87038789025544,
"f1": 88.67964179873631,
"total": 10570,
}
XLN
et
전체적인 실험 결과 (※ 자체 구현 後 실험 결과)
Able to Check our test code here : https://github.com/jeehyun100/text_proj
24. 기타 실험 결과
BERT + One Shot Learning
주어진 과제가 MRC 이기 때문에, 주제로 하지는 않았지만, 새로운 아이디어 적용을 시도하여 봄
BERT 의 좋은 Feature 를 사용하여 One Shot Learning(SIAMESE NEURAL NETWORKS FOR ONE-SHOT
IMAGE RECOGNITION) 을 적용하여, 단 하나의 문장으로 Class 를 추가하여 분류할 수 있도록 시도 함
25. 기타 실험 결과
BERT + One Shot Learning
Test Set 을 별도로 구성하지는 못하였지만, 몇 가지 테스트 결과 나름대로 분류가 꽤 잘 되는 것을 확인