A method for determining the answer to a query in a document, including: encoding, by an encoder, the query and the document; generating a query-aware context encodings G by a bidirectional attention system using the encoded query and the encoded document; performing a hierarchical self-attention on the query aware document by a hierarchical self-attention system by applying a word to word attention and a word to sentence attention mechanism resulting in a matrix M; and determining the starting word and the ending word of the answer in the document by a span detector based upon the matrix M.
HIERARCHICAL SELF-ATTENTION FOR MACHINE COMPREHENSION