【论文笔记】Bi-DAF(待修)——BI-DIRECTIONAL ATTENTION FLOW FOR MACHINE COMPREHENSION

0 摘要

  1. represents the context at different levels of granularity
  2. uses bi-directional attention flow mechanism to obtain a query-aware context representation without early summarization

1 introduce

先前工作中的注意机制通常具有以下一个或多个特征。

  • 计算的注意力权重通常用于从上下文中提取最相关的信息,以通过将上下文概括为固定大小的向量来回答问题。
  • 在文本域中,它们通常在时间上是动态的, the attention weights at the current time step are a function of the attended vector
    at the previous time step
  • 它们通常是单向的,其中查询参与上下文段落或图像。

the Bi-Directional Attention Flow (BIDAF) network, 这是一种分层多阶段架构,用于对不同粒度级别的上下文段落的表示进行建模.includes character-level, word-level, and contextual embeddings, and uses bi-directional attention flow to obtain a query-aware context representation.

  1. 我们的注意层不用于将上下文段落概括为固定大小的向量。在每步计算attention,并获得向量,伴随之前的层,允许流通到接下来的层。这降低了概括造成的损失。
  2. 在两个方向上使用attention机制,query-to-context and context-to-query,提供互补信息。
  3. use a memory-less attention mechanism. 当顺着时间计算attention时,在每个time step的attention是当前time step的问题和上下文段落的函数,不依赖于之前time step的attention。假设这个简化导致attention层和建模层的分工合作。这迫使attention层专注学习query和context之前的attention,允许建模层专注学习 query-aware context representation (the output of the attention layer)。 memory-less attention gives a clear advantage over dynamic attention.

2 model

在这里插入图片描述
模型包括6层:

  1. Character Embedding Layer:通过character-level的CNNs,把每个词映射到向量空间。
  2. Word Embedding Layer:通过训练好的word embedding将每个词映射到一个向量空间。
  3. Contextual Embedding Layer :从周围词中使用情境线索过滤词嵌入。
    上面3个层都应用于context和query
  4. Attention Flow Layer:结合query和context向量,对context中的每个词生成一组query-aware特征的向量。
  5. Modeling Layer:使用RNN扫描context。
  6. Output Layer:对query提供一个答案。

具体

  • Character Embedding Layer
    Let {x1, . . . xT } and {q1, . . . qJ } represent the words in the input context paragraph and query,每个词语使用CNN获得字符级的词嵌入。

  • Word Embedding Layer
    把每个词映射到高维向量空间。使用训练好的向量,GloVe,获得每个词的固定词嵌入。 character和word的向量进行concatenation,输入到两层的highway网络( 公路网),公路网的输出是2个d维向量,or2个矩阵。context输出X,query输出Q,dT 和dJ维。

  • Contextual Embedding Layer
    在前面的层提供的嵌入之上,使用LSTM模拟单词之间的时间相互作用。LSTM使用双向,对两个LSTM的输出进行concatenation。

前三层都是从不同的粒度计算query和context的特征,和CNN的多尺度特征相似。

  • ** Attention Flow Layer**
    连接和融合context和word的信息。允许每个时间步的注意向量,以及来自先前层的嵌入流动到后续建模层。 这减少了由早期摘要引起的信息丢失。
    我们在两个方向上计算注意力:从上下文到查询以及从查询到上下文。
    Stj表示第t个context词和第j个query词的相似度,相似矩阵的计算如下:
    在这里插入图片描述

    • Context-to-query Attention.
      上下文到查询(C2Q)注意表示哪个查询词与每个上下文词最相关。
    • Query-to-context Attention.
      查询到上下文(Q2C)注意表示哪个上下文单词与查询单词之一具有最接近的相似性,因此对于回答查询是至关重要的。

    最后,将context embeddings和attention vectors组合在一起以产生G, 其中每个列向量可以被视为the query-aware representation of each context word.
    在这里插入图片描述

  • Modeling Layer.
    建模层的输入是G,它encodes the query-aware representations of context words.The output of the modeling layer captures the interaction among the context words conditioned on the query. 使用双向lstm,从而得到一个矩阵M(2d*T),它将通过output layer来预测答案。期望M的每个列向量包含关于整个上下文段落和查询的词的上下文信息。

    扫描二维码关注公众号,回复: 9940416 查看本文章
  • Output Layer
    输出层是特定于应用程序的。 BIDAF的模块化特性允许我们根据任务轻松交换输出层,其余架构保持完全相同。
    在这里插入图片描述

  • training
    在这里插入图片描述

  • test
    在这里插入图片描述

发布了63 篇原创文章 · 获赞 13 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/changreal/article/details/103106740