Package: uclmr-jack
Jack the ReaderA Machine Reading Comprehension framework.All work and no play makes Jack a great framework!All work and no play makes Jack a great framework!All work and no play makes Jack a great framework!Jack the Reader- orjack, for short - is a framework for building and using models on a variety of tasks that requirereading comprehension. For more informations about the overall architecture, we refer toJack the Reader – A Machine Reading Framework(ACL 2018).InstallationTo install Jack, install requirements andTensorFlow. In case you want to use PyTorch for writing models, please installPyTorchas well.Supported ML BackendsWe currently supportTensorFlowandPyTorch.
Readers can be implemented using both. Input and output modules (i.e., pre- and post-processing) are independent of the
ML backend and can thus be reused for model modules that either backend.
Though most models are implemented in TensorFlow by reusing the cumbersome pre- and post-processing it is easy to
quickly build new readers in PyTorch as well.Pre-trained ModelsFind pre-trained modelshere.Code Structurejack.core- core abstractions usedjack.readers- implementations of modelsjack.eval- task evaluation codejack.util- utility code that is used throughout the framework, including shared ML codejack.io- IO related code, including loading and dataset conversion scriptsProjectsIntegration of Knowledge into neural NLU systemsQuickstartCoding Tutorials - Notebooks & CLIWe provide ipython notebooks with tutorials on Jack. For the quickest start, you can beginhere. If you're interested in training a model yourself from code, seethis tutorial(we recommend the command-line, see below), and if you'd like to implement a new model yourself,this notebookgives you a tutorial that explains this process in more detail.There is documentation on ourcommand-line interfacefor actuallytraining and evaluating models.
For a high-level explanation of the ideas and vision, seeUnderstanding Jack the Reader.Command-line Training and Usage of a QA SystemTo illustrate how jack works, we will show how to train a question answering
model using ourcommand-line interfacewhich is analoguous for other tasks (browseconf/for existing task-dataset configurations).
It is probably best to setup avirtual environmentto avoid
clashes with system wide python library versions.First, install the framework:$python3-mpipinstall-e.[tf]Then, download the SQuAD dataset, and the GloVe word embeddings:$./data/SQuAD/download.sh
$./data/GloVe/download.shTrain aFastQAmodel:$python3bin/jack-train.pywithtrain='data/SQuAD/train-v1.1.json'dev='data/SQuAD/dev-v1.1.json'reader='fastqa_reader'\>repr_dim=300dropout=0.5batch_size=64seed=1337loader='squad'save_dir='./fastqa_reader'epochs=20\>with_char_embeddings=Trueembedding_format='memory_map_dir'embedding_file='data/GloVe/glove.840B.300d.memory_map_dir'vocab_from_embeddings=Trueor shorter, using our prepared config:$python3bin/jack-train.pywithconfig='./conf/qa/squad/fastqa.yaml'A copy of the model is written into thesave_dirdirectory after each
training epoch when performance improves. These can be loaded using the commands below or see e.g.quickstart.You want to train another model? No problem, we have a fairly modular QAModel implementation which allows you to stick
together your own model. There are examples inconf/qa/squad/(e.g.,bidaf.yamlor our own creationjack_qa.yaml).
These models are defined solely in the configs, i.e., there is not implementation in code.
This is possible through ourModularQAModel.If all of that is too cumbersome for you and you just want to play, why not downloading a pretrained model:$# we still need GloVe in memory mapped format, ignore the next 2 commands if already downloaded and transformed$data/GloVe/download.sh
$wget-Ofastqa.ziphttps://www.dropbox.com/s/qb796uljoqj0lvo/fastqa.zip?dl=1$unzipfastqa.zip&&mvfastqafastqa_readerfromjackimportreadersfromjack.coreimportQASettingfastqa_reader=readers.reader_from_file("./fastqa_reader")support=""""It is a replica of the grotto at Lourdes,France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858.At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome),is a simple, modern stone statue of Mary."""answers=fastqa_reader([QASetting(question="To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?",support=[support])])print(answers[0][0].text)SupportWe are thankful for support from:Developer guidelinesComply with the PEP 8 Style GuideMake sure all your code runs from the top level directory, e.g.:$pwd/home/pasquale/workspace/jack
$python3bin/jack-train.py[..]Citing@InProceedings{weissenborn2018jack,
author    = {Dirk Weissenborn, Pasquale Minervini, Tim Dettmers, Isabelle Augenstein, Johannes Welbl, Tim Rocktäschel, Matko Bošnjak, Jeff Mitchell, Thomas Demeester, Pontus Stenetorp, Sebastian Riedel},
title     = {{Jack the Reader – A Machine Reading Framework}},
booktitle = {{Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (ACL) System Demonstrations}},
Month     = {July},
year      = {2018},
url       = {https://arxiv.org/abs/1806.08727}
}