机器阅读也是AllenNLP提供的功能模块之一。其Models介绍如下:
Machine Comprehension (MC) models answer natural language questions by selecting an answer span within an evidence text. The AllenNLP MC model is a reimplementation of BiDAF (Seo et al, 2017), or Bi-Directional Attention Flow, a widely used MC baseline that achieved state-of-the-art accuracies on the SQuAD dataset in 2017. The AllenNLP BIDAF model achieves an EM score of 68.3 on the SQuAD dev set, just slightly ahead of the original BIDAF system's score of 67.7, while also training at a 10x speedup (4 hours on a p2.xlarge).
由上可见,其介绍的机器阅读使用的算法是BIDAF, 具体的算法原理见前面的博客分析:基于Bidirectional AttentionFlow的机器阅读理解实践。
具体实践如下:
(1)源码中参数的自动传入与测试,如下所示:
(2)python命令终端中的测试
(3)代码的自测,自编写了一个Test函数。