This is the material of presentation regarding on 'Bidirectional attention flow for machine comprehension'
https://arxiv.org/abs/1611.01603
2. Abstract
Machine Comprehension : 주어진 context paragraph 관한 query를 대답하는 것
MC는 context와 query간의 복잡한 관계를 모델링 해야 함.
예 :
Context : 서지수는 유재석에게 빌려준 500원을 받았다. 그리고 이자로 100원을 받았다.
query : 지수가 가진 돈의 금액은?
그리고 최근에 Attention mechanisms이 MC에 성공적으로 안착
문맥의 작은 부분에 집중하고 요약하며 fixed-size vector로 표현하는 attention을 사용했고 주로 uni-
direction 사용
3. Abstract
그런데 BIDAF는 말 그대로 Bi-direction attention flow mechanisms을 사용함 (early summarization없이
query-aware context vector를 나타내기 위해서 : 요약 없이 쿼리가 들어가는 context vector를 얻기 위
해)
그리고
• multi-stage hierarchical process 구조
• context을 세분화시킴(query에서 사용되는 중요한 단어를 골라냄)
• SQUAD랑 CNN/Daliy Mail cloze test 데이터 셋 사용
4. Introduction
MC랑 QA는 NLP와 비전의 Hot한 요소였음. 그리고 그 중심에는 attention이 있었다.
기존의 Attention mechanism
• context를 고정된 사이즈의 vector로 요약해서, 질문을 위한 context로부터 연관된 정보를 추출
• text domain에서 attention vector는 계속 update
=> 이전 스텝 벡터가 현재의 어텐션 가중치와 상관관계
• uni-direction 사용
5. Introduction
BIDAF
• fixed sized vector로 요약 안하고 모든 스텝마다 compute함. 그래서 information loss도 줄일 수 있
었음.
(+이전 layer에서 계산된 attended vector를 subsequent model로 flow하게 해줌)
• memory-less attention mechanism을 사용했다. 그 이전의 time-step 의 attention 에 직접적으로 의
존하는 것이 아닌, query와 context가 각 스텝의 attention에 상관하도록 설계
=> attention layer와 modeling layer의 labor 분산 효과 (계산량 분산을 의미하는 듯) 를 기대
=> 왜냐면 query-aware context vector안에서 쿼리랑 문맥에 좀 더 집중할 수 있게 만드는 구조
=> 그리고 그 이전의 잘못된 정보도 각 step의 attention에게 영향을 미치지 않음
(time-step마다 attention을 계산)
• query - > context , context <- query로 양방향 설계해서 서로에게 정보교환이 가능
7. MODEL
Character Embedding Layer
각 word를 high-dimensional vector space와 mappingg하는 역할
Char-CNN을 사용해서 fixed-size vector for each word(output)를 뽑아냄.
Yoon-kim의 CNN text classification을 가져왔음. 1D -> CNN 돌리기 -> 각 단어의 char- level
embedding을 얻었음 .
Word Embedding Layer
Glove(Pennington et al., 2014)를 차용함.
=>아무래도 window size의 유사도만 보는 Word2vec와 달리 context를 파악하기 위한 전체적인 통
계정보(co-occurrence)도 같이 할 수 있어서 차용한 것 같음.
8. MODEL
그리고 이 두 개의 character와 word embedding vector를 concatenate 하고 Two layer Highway
Network에 넣음
=> activation을 안 쓰고 우회로 만드는 network. 보통 빠른 학습에 쓰인다. ref. 카카오브런치
=> highway network code. y= H*T+ x*C, (C = 1-T). T =1 이면 그냥 보통 neural net. C가 1이면
activation을 거치지 않음.
activation을 필요한 만큼 사용하는 걸 학습
Contextual Embedding Layer
vector h = the vector of context word
vector u = the vector of query word
column vector h와 u는 각각 2 -dimension인데 왜냐면
LSTM의 각 앞단(forward)과 뒷단(backward)에 나온 두 개의 output을 concatenation하기 위해 사용
*그리고 앞 단 3 layer가 쿼리와 context를 다양하고 세분화시킨 각각의 computing feature로 사용됨
9. MODEL
Attention Flow Layer
context 및 query의 정보를 연결하고 융합하는 역할
이전에도 언급했지만 기존의 attention 과 다르게 single feature로 summarize 안 함
=>matrix 형태로 놔둔다는 뜻.
대신에 각 step의 attention vector를 다음 모델링 레이어에 흘러 보낼 수 있음.
=>그리고 이 방법이 information loss를 줄임
(the attention vector at each time step are allowed to flow through to the subsequent modeling
layer)
ex) Attention flow 역할
Context : 연우는 집에서 빨래를 한 뒤 노래를 들었다
Query: 연우가 한 두 번째 행동은?
노래를 들었다(listening to music) 두 번째 행동 => Context와 Query를 이어주는 역할
11. MODEL
Attention Flow Layer
input : H 와 U의 contextual vector representation
output: query-aware vector representation of context word, G
(그 이전 레이어의 contextual embedding을 따름)
Context to query & Query to context. 두 가지 방향으로 attention이 작동함
• S는 이 H와 U사이에 두 개의 Attention에서 공유되는 similarity matrix
• α는 두 벡터사이에 similarity를 인코딩하여 학습가능한 scalar function
• S(t j)에서 t는 H , j는 U의 인덱스라고 생각하면 됨.
• α(h, u) = w^T (S) [h; u; h ◦ u],
• ◦는 element wise multiplication이고 [;] vector concatenation
12. MODEL
Attention Flow Layer
*Context to query
query word들이 얼마나 각 Context와 상관 있나를 알려줌
a는 t에 관한 summation (t개들을 다 합치면 1) 그리고 S를 소프트맥스로 계산하여 a를 만듬.
=> 유사성이 큰 weight만 값이 커지게 됨
그리고 U^은 at * U를 곱해 만듬.
14. MODEL
Attention Flow Layer
*Query to context
Context가 각 쿼리 단어들에 얼마나 closet similarity를 가지고 있는 가를 의미.
Answering query에 매우 중요 !!
• B = softmax (maxcol(S)) 인데 maxcol은 그냥 그 column에서 최대값 뽑아내는 함수.
• B와 H를 곱하면 h^
• H^ = b*Ht
• G:t = β(h, u˜, h˜) = [h; u˜; h ◦ u˜; h ◦ h˜]
• Β는 입력 벡터를 융합하는 훈련 가능한 벡터 함수
17. MODEL
Modeling Layer
• input : query-aware vector representation of context word, G
• output : query위에 조건화 된 context word간의 interaction
Bi LSTM 쓰고 d 사이즈 만큼 output size 설정
그 결과 우리는 matrix M을 얻을 수 있는데 답을 예측하기 위해 출력 계층으로 전달
M의 각 열 벡터는 전체 문단 및 질의에 대한 문맥 정보를 포함되는 걸로 예상함.
18. MODEL
Modeling Layer
• query에 대한 answer을 output
• 질문에 대한 대답으로 paragraph의 sub-phrase를 찾아야 함
• paragraph안에 있는 start, end의 indices 를 predict 해서 phrase를 찾음
20. Related work
MC (Machine comprehension)
1st Group (previous attention dynamic update)
Teaching machines to read and comprehend. (Karl Moritz Hermann, 2015, NIPS)
Attention-over attention neural networks for reading comprehension (Cui, 2016)
Machine comprehension using match-lstm and answer pointer(Wang, 2017, ICLR)
=>이와 다르게 memory less attention을 사용
2nd Group (First , compute attention weight, use for final prediction )
Text understanding with the attention sum reader network (Kadlec ,2016, ACL)
Attention-over attention neural networks for reading comprehension.(Cui, 2016)
=> 이와 다르게 BIDAF는 attention layer의 modalities를 summarize하지 않고 RNN으로 흘려보냄.
21. Related work
MC (Machine comprehension)
3rd Group (Memory networks. In ICLR, 2015 응용)
Iterative alternating neural attention for machine reading (Sordoni, 2016)
Reasonet: Learning to stop reading in machine comprehension(Shen, ACM, 2017)
=> 연장선으로 연구.
VQA
Multimodal compact bilinear pooling for visual question answering and visual grounding.
(Fukui, EMNLP, 2016)
Hierarchical question-image co-attention for visual question answering. (Lu, NIPS, 2016)
28. Conclusion
• a multi-stage hierarchical process that represents the context at different levels of granularity
• bi-directional attention flow mechanism to achieve a queryaware context representation without early
summarization
• The experimental evaluations show that our model achieves the state-of-the-art results in Stanford
Question Answering Dataset (SQuAD) and CNN/DailyMail cloze test
• The ablation analyses demonstrate the importance of each component in our model
Future work involves extending our approach to incorporate multiple hops of the attention layer.
29. Reference
• Bidirectional Attention Flow for Machine Comprehension (Minjoon Seo, 2017, ICLR)
• Highway Networks (Rupesh Kumar Srivastava, 2015, ICML)
• Convolutional Neural Networks for Sentence Classification (Yoon Kim, EMNLP, 2014)
• GloVe: Global Vectors for Word Representation (Pennington, 2014)
• Teaching machines to read and comprehend. (Karl Moritz Hermann, 2015, NIPS)
• Attention-over attention neural networks for reading comprehension (Cui, 2016)
• Machine comprehension using match-lstm and answer pointer(Wang, 2017, ICLR)
• Text understanding with the attention sum reader network (Kadlec ,2016, ACL)
• Attention-over attention neural networks for reading comprehension.(Cui, 2016)
• Iterative alternating neural attention for machine reading (Sordoni, 2016)
• Reasonet: Learning to stop reading in machine comprehension(Shen, ACM, 2017)
• Multimodal compact bilinear pooling for visual question answering and visual grounding.
(Fukui, EMNLP, 2016)