Build question-answering systems using state-of-the-art pre-trained contextualized language models, e.g. BERT. We are working to accelerate the development of question-answering systems based on BERT and TF 2.0!
This project is based on our study: Question Generation by Transformers.
To cite this work, use the following BibTeX citation.
@article{question-generation-transformers@2019,
title={Question Generation by Transformers},
author={Kriangchaivech, Kettip and Wangperawong, Artit},
journal={arXiv preprint arXiv:1909.05017},
year={2019}
}
TensorFlow 2.0 will be installed if not already on your system
pip install bert_qa
Run Colab demo notebook here.
wget -q https://storage.googleapis.com/cloud-tpu-checkpoints/bert/keras_bert/uncased_L-12_H-768_A-12.tar.gz
tar -xvzf uncased_L-12_H-768_A-12.tar.gz
mv -f home/hongkuny/public/pretrained_models/keras_bert/uncased_L-12_H-768_A-12 .
wget -q https://rajpurkar.github.io/SQuAD-explorer/dataset/dev-v1.1.json
wget -q https://rajpurkar.github.io/SQuAD-explorer/dataset/train-v1.1.json
from bert_qa import squad
qa = squad.SQuAD()
qa.preprocess_training_data()
qa.fit()
predictions = qa.predict()
import json
pred_data = json.load(open('model/predictions.json'))
dev_data = json.load(open('dev-v1.1.json'))['data']
qa.evaluate(dev_data, pred_data)
The default model is an uncased Bidirectional Encoder Representations from Transformers (BERT) consisting of 12 transformer layers, 12 self-attention heads per layer, and a hidden size of 768. Below are all models currently supported that you can specify with hub_module_handle
. We expect that more will be added in the future. For more information, see TensorFlow's BERT GitHub.
BERT-Large, Uncased (Whole Word Masking)
: 24-layer, 1024-hidden, 16-heads, 340M parametersBERT-Large, Cased (Whole Word Masking)
: 24-layer, 1024-hidden, 16-heads, 340M parametersBERT-Base, Uncased
: 12-layer, 768-hidden, 12-heads, 110M parametersBERT-Large, Uncased
: 24-layer, 1024-hidden, 16-heads, 340M parametersBERT-Base, Cased
: 12-layer, 768-hidden, 12-heads , 110M parametersBERT-Large, Cased
: 24-layer, 1024-hidden, 16-heads, 340M parameters
BERT-QA is an open-source project founded and maintained to better serve the machine learning and data science community. Please feel free to submit pull requests to contribute to the project. By participating, you are expected to adhere to BERT-QA's code of conduct.
For questions or help using BERT-QA, please submit a GitHub issue.