Training Techniques | Adam |
---|---|
Architecture | Convolution, Dropout, Highway Layer, LSTM, Linear Layer, ReLU |
Epochs | 20 |
SHOW MORE |
This is an implementation of the BiDAF model with GloVe embeddings. The basic layout is pretty simple: encode words as a combination of word embeddings and a character-level encoder, pass the word representations through a bi-LSTM/GRU, use a matrix of attentions to put question information into the passage word representations (this is the only part that is at all non-standard), pass this through another few layers of bi-LSTMs/GRUs, and do a softmax over span start and span end.
Explore live Reading Comprehension demo at AllenNLP.
from allennlp_models.pretrained import load_predictor
predictor = load_predictor("rc-bidaf")
question = "Who graduated in 1936?"
passage = ("In 1932, Shannon entered the University of Michigan,"
" where he was introduced to the work of George Boole. He"
" graduated in 1936 with two bachelor's degrees: one in"
" electrical engineering and the other in mathematics."
)
preds = predictor.predict(question, passage)
print(preds["best_span_str"])
# prints: Shannon
You can also get predictions using allennlp command line interface:
echo '{"question": "Who graduated in 1936?", "passage": "In 1932, Shannon entered the University..."}' | \
allennlp predict https://storage.googleapis.com/allennlp-public-models/bidaf-model-2020.03.19.tar.gz -
To evaluate the model on SQuAD dev set run:
allennlp evaluate https://storage.googleapis.com/allennlp-public-models/bidaf-model-2020.03.19.tar.gz \
https://s3-us-west-2.amazonaws.com/allennlp/datasets/squad/squad-dev-v1.1.json
To train this model you can use allennlp
CLI tool and the configuration file bidaf.jsonnet:
allennlp train bidaf.jsonnet -s output_dir
See the AllenNLP Training and prediction guide for more details.
@article{Seo2017BidirectionalAF,
author = {Minjoon Seo and Aniruddha Kembhavi and Ali Farhadi and Hannaneh Hajishirzi},
journal = {ArXiv},
title = {Bidirectional Attention Flow for Machine Comprehension},
volume = {abs/1611.01603},
year = {2017}
}
BENCHMARK | MODEL | METRIC NAME | METRIC VALUE | GLOBAL RANK |
---|---|---|---|---|
SQuAD1.1 dev | BiDAF | EM | 66 | # 3 |
F1 | 76 | # 3 |