SlideShare a Scribd company logo
임우담
Bidirectional Attention Flow for Machine
Comprehension
woodam.lim@gmail.com
Abstract
Machine Comprehension : 주어진 context paragraph 관한 query를 대답하는 것
MC는 context와 query간의 복잡한 관계를 모델링 해야 함.
예 :
Context : 서지수는 유재석에게 빌려준 500원을 받았다. 그리고 이자로 100원을 받았다.
query : 지수가 가진 돈의 금액은?
그리고 최근에 Attention mechanisms이 MC에 성공적으로 안착
문맥의 작은 부분에 집중하고 요약하며 fixed-size vector로 표현하는 attention을 사용했고 주로 uni-
direction 사용
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 데이터 셋 사용
Introduction
MC랑 QA는 NLP와 비전의 Hot한 요소였음. 그리고 그 중심에는 attention이 있었다.
기존의 Attention mechanism
• context를 고정된 사이즈의 vector로 요약해서, 질문을 위한 context로부터 연관된 정보를 추출
• text domain에서 attention vector는 계속 update
=> 이전 스텝 벡터가 현재의 어텐션 가중치와 상관관계
• uni-direction 사용
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로 양방향 설계해서 서로에게 정보교환이 가능
MODEL
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)도 같이 할 수 있어서 차용한 것 같음.
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로 사용됨
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를 이어주는 역할
MODEL
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
MODEL
Attention Flow Layer
*Context to query
query word들이 얼마나 각 Context와 상관 있나를 알려줌
a는 t에 관한 summation (t개들을 다 합치면 1) 그리고 S를 소프트맥스로 계산하여 a를 만듬.
=> 유사성이 큰 weight만 값이 커지게 됨
그리고 U^은 at * U를 곱해 만듬.
MODEL
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˜]
• Β는 입력 벡터를 융합하는 훈련 가능한 벡터 함수
MODEL
MODEL
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의 각 열 벡터는 전체 문단 및 질의에 대한 문맥 정보를 포함되는 걸로 예상함.
MODEL
Modeling Layer
• query에 대한 answer을 output
• 질문에 대한 대답으로 paragraph의 sub-phrase를 찾아야 함
• paragraph안에 있는 start, end의 indices 를 predict 해서 phrase를 찾음
MODEL
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으로 흘려보냄.
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)
Question Answering Experiment
Dataset : SQuAD = The Stanford Question Answering Dataset
More than 10,0000 questions based on Wekipedia article
Question Answering Experiment
Bidirectional attention flow for machine comprehension
Question Answering Experiment
• EM = Exact Match, F1 = F1 score
6. Cloze Test Experiment
Data Set : CNN and Mail data set
6. Cloze Test Experiment
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.
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)
Reference
• Hierarchical question-image co-attention for visual question answering. (Lu, NIPS, 2016)
• SQuAD : https://rajpurkar.github.io/SQuAD-explorer/
• CNN&Daliy Mail : https://cs.nyu.edu/~kcho/DMQA/
• https://brunch.co.kr/@kakao-it/142
• https://github.com/allenai/bi-att-flow
Thank you

More Related Content

PDF
Estudo no livro de provérbios antônio neves de mesquita
PPTX
A Fé que Move o Sobrenatural
PDF
Attention is all you need
PDF
Attention is all you need 설명
PDF
파이썬으로 익히는 딥러닝 기본 (18년)
PPTX
딥러닝을 이용한 자연어처리의 연구동향
PDF
Facebook Meta's technical direction in Large Language Models (LLMs)
Estudo no livro de provérbios antônio neves de mesquita
A Fé que Move o Sobrenatural
Attention is all you need
Attention is all you need 설명
파이썬으로 익히는 딥러닝 기본 (18년)
딥러닝을 이용한 자연어처리의 연구동향
Facebook Meta's technical direction in Large Language Models (LLMs)

Similar to Bidirectional attention flow for machine comprehension (20)

PDF
순환신경망(Recurrent neural networks) 개요
PDF
딥뉴럴넷 클러스터링 실패기
PDF
검색엔진에 적용된 딥러닝 모델 방법론
PPTX
MRC recent trend_ppt
PDF
PaLM Paper Review
PPTX
A joint many task model
PPTX
(Kor ver.)NLP embedding(word2vec) tutorial & implementation(Tensorflow)
PDF
스마트폰 위의 딥러닝
PPTX
[Paper Review] Image captioning with semantic attention
PDF
Sequence to Sequence Learning with Neural Networks
PDF
CNN for sentence classification
PPTX
Chapter 17 monte carlo methods
PPTX
Papago/N2MT 개발이야기
PPTX
Bi directional attention flow for nlp
PDF
MultiModal Embedding integrates various data types, like images, text, and au...
PDF
[226]대용량 텍스트마이닝 기술 하정우
PDF
딥러닝 논문읽기 efficient netv2 논문리뷰
PDF
연구실 세미나 Show and tell google image captioning
 
PDF
[224] backend 개발자의 neural machine translation 개발기 김상경
PDF
풀잎스쿨 - LIME 발표자료(설명가능한 인공지능 기획!)
순환신경망(Recurrent neural networks) 개요
딥뉴럴넷 클러스터링 실패기
검색엔진에 적용된 딥러닝 모델 방법론
MRC recent trend_ppt
PaLM Paper Review
A joint many task model
(Kor ver.)NLP embedding(word2vec) tutorial & implementation(Tensorflow)
스마트폰 위의 딥러닝
[Paper Review] Image captioning with semantic attention
Sequence to Sequence Learning with Neural Networks
CNN for sentence classification
Chapter 17 monte carlo methods
Papago/N2MT 개발이야기
Bi directional attention flow for nlp
MultiModal Embedding integrates various data types, like images, text, and au...
[226]대용량 텍스트마이닝 기술 하정우
딥러닝 논문읽기 efficient netv2 논문리뷰
연구실 세미나 Show and tell google image captioning
 
[224] backend 개발자의 neural machine translation 개발기 김상경
풀잎스쿨 - LIME 발표자료(설명가능한 인공지능 기획!)
Ad

Bidirectional attention flow for machine comprehension

  • 1. 임우담 Bidirectional Attention Flow for Machine Comprehension woodam.lim@gmail.com
  • 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를 이어주는 역할
  • 10. MODEL
  • 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를 곱해 만듬.
  • 13. MODEL
  • 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˜] • Β는 입력 벡터를 융합하는 훈련 가능한 벡터 함수
  • 15. MODEL
  • 16. MODEL
  • 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를 찾음
  • 19. MODEL
  • 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)
  • 22. Question Answering Experiment Dataset : SQuAD = The Stanford Question Answering Dataset More than 10,0000 questions based on Wekipedia article
  • 25. Question Answering Experiment • EM = Exact Match, F1 = F1 score
  • 26. 6. Cloze Test Experiment Data Set : CNN and Mail data set
  • 27. 6. Cloze Test Experiment
  • 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)
  • 30. Reference • Hierarchical question-image co-attention for visual question answering. (Lu, NIPS, 2016) • SQuAD : https://rajpurkar.github.io/SQuAD-explorer/ • CNN&Daliy Mail : https://cs.nyu.edu/~kcho/DMQA/ • https://brunch.co.kr/@kakao-it/142 • https://github.com/allenai/bi-att-flow