All Projects → kamalkraj → Bert Squad

kamalkraj / Bert Squad

Licence: agpl-3.0
SQuAD Question Answering Using BERT, PyTorch

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Bert Squad

Farm
🏡 Fast & easy transfer learning for NLP. Harvesting language models for the industry. Focus on Question Answering.
Stars: ✭ 1,140 (+345.31%)
Mutual labels:  question-answering, pretrained-models
iamQA
中文wiki百科QA阅读理解问答系统,使用了CCKS2016数据的NER模型和CMRC2018的阅读理解模型,还有W2V词向量搜索,使用torchserve部署
Stars: ✭ 46 (-82.03%)
Mutual labels:  question-answering
tg2021task
Participant Kit for the TextGraphs-15 Shared Task on Explanation Regeneration
Stars: ✭ 18 (-92.97%)
Mutual labels:  question-answering
syntaxdot
Neural syntax annotator, supporting sequence labeling, lemmatization, and dependency parsing.
Stars: ✭ 32 (-87.5%)
Mutual labels:  pretrained-models
co-attention
Pytorch implementation of "Dynamic Coattention Networks For Question Answering"
Stars: ✭ 54 (-78.91%)
Mutual labels:  question-answering
object-flaw-detector-python
Detect various irregularities of a product as it moves along a conveyor belt.
Stars: ✭ 17 (-93.36%)
Mutual labels:  pretrained-models
DVQA dataset
DVQA Dataset: A Bar chart question answering dataset presented at CVPR 2018
Stars: ✭ 20 (-92.19%)
Mutual labels:  question-answering
gapbug
QA site with Python/Django
Stars: ✭ 28 (-89.06%)
Mutual labels:  question-answering
squad-v1.1-pt
Portuguese translation of the SQuAD dataset
Stars: ✭ 13 (-94.92%)
Mutual labels:  question-answering
ObjectNet
PyTorch implementation of "Pyramid Scene Parsing Network".
Stars: ✭ 15 (-94.14%)
Mutual labels:  pretrained-models
productqa
Product-Aware Answer Generation in E-Commerce Question-Answering
Stars: ✭ 29 (-88.67%)
Mutual labels:  question-answering
cdQA-ui
⛔ [NOT MAINTAINED] A web interface for cdQA and other question answering systems.
Stars: ✭ 19 (-92.58%)
Mutual labels:  question-answering
MICCAI21 MMQ
Multiple Meta-model Quantifying for Medical Visual Question Answering
Stars: ✭ 16 (-93.75%)
Mutual labels:  question-answering
Chinese-Psychological-QA-DataSet
中文心理问答数据集
Stars: ✭ 23 (-91.02%)
Mutual labels:  question-answering
regnet.pytorch
PyTorch-style and human-readable RegNet with a spectrum of pre-trained models
Stars: ✭ 50 (-80.47%)
Mutual labels:  pretrained-models
qa
TensorFlow Models for the Stanford Question Answering Dataset
Stars: ✭ 72 (-71.87%)
Mutual labels:  question-answering
finetuner
Finetuning any DNN for better embedding on neural search tasks
Stars: ✭ 442 (+72.66%)
Mutual labels:  pretrained-models
HugsVision
HugsVision is a easy to use huggingface wrapper for state-of-the-art computer vision
Stars: ✭ 154 (-39.84%)
Mutual labels:  pretrained-models
CogView
Text-to-Image generation. The repo for NeurIPS 2021 paper "CogView: Mastering Text-to-Image Generation via Transformers".
Stars: ✭ 708 (+176.56%)
Mutual labels:  pretrained-models
AskNowNQS
A question answering system for RDF knowledge graphs.
Stars: ✭ 32 (-87.5%)
Mutual labels:  question-answering

BERT-SQuAD

Use google BERT to do SQuAD !

What is SQuAD?

Stanford Question Answering Dataset (SQuAD) is a reading comprehension dataset, consisting of questions posed by crowdworkers on a set of Wikipedia articles, where the answer to every question is a segment of text, or span, from the corresponding reading passage, or the question might be unanswerable.

Requirements

  • python3
  • pip3 install -r requirements.txt

Result

model : bert-large-uncased-whole-word-masking

{"exact_match": 86.91579943235573, "f1": 93.1532499015869}

Pretrained model download from here

unzip and move files to model directory

Inference

from bert import QA

model = QA('model')

doc = "Victoria has a written constitution enacted in 1975, but based on the 1855 colonial constitution, passed by the United Kingdom Parliament as the Victoria Constitution Act 1855, which establishes the Parliament as the state's law-making body for matters coming under state responsibility. The Victorian Constitution can be amended by the Parliament of Victoria, except for certain 'entrenched' provisions that require either an absolute majority in both houses, a three-fifths majority in both houses, or the approval of the Victorian people in a referendum, depending on the provision."

q = 'When did Victoria enact its constitution?'

answer = model.predict(doc,q)

print(answer['answer'])
# 1975
print(answer.keys())
# dict_keys(['answer', 'start', 'end', 'confidence', 'document']))

model.predict(doc,q) return dict

{
"answer" : "answer text",
"start" : "start index",
"end" : "end index",
"confiednce" : "confidence of answer",
"document" : "tokenzied document , list"
}

Deploy REST-API

BERT QA model deployed as rest api

python api.py

API will be live at 0.0.0.0:8000 endpoint predict

cURL request

curl -X POST http://0.0.0.0:8000/predict -H 'Content-Type: application/json' -d '{ "document": "Victoria has a written constitution enacted in 1975, but based on the 1855 colonial constitution, passed by the United Kingdom Parliament as the Victoria Constitution Act 1855, which establishes the Parliament as the states law-making body for matters coming under state responsibility. The Victorian Constitution can be amended by the Parliament of Victoria, except for certain 'entrenched' provisions that require either an absolute majority in both houses, a three-fifths majority in both houses, or the approval of the Victorian people in a referendum, depending on the provision.","question":"When did Victoria enact its constitution?" }'

Output

{
    "result": {
        "answer": "1975",
        "confidence": 0.940746070672879,
        "document": [
            "Victoria",
            "has",
            "a",
            "written",
            "constitution",
            "enacted",
            "in",
            "1975,",
            "but",
            "based",
            "on",
            "the",
            "1855",
            "colonial",
            "constitution,",
            "passed",
            "by",
            "the",
            "United",
            "Kingdom",
            "Parliament",
            "as",
            "the",
            "Victoria",
            "Constitution",
            "Act",
            "1855,",
            "which",
            "establishes",
            "the",
            "Parliament",
            "as",
            "the",
            "states",
            "law-making",
            "body",
            "for",
            "matters",
            "coming",
            "under",
            "state",
            "responsibility.",
            "The",
            "Victorian",
            "Constitution",
            "can",
            "be",
            "amended",
            "by",
            "the",
            "Parliament",
            "of",
            "Victoria,",
            "except",
            "for",
            "certain",
            "entrenched",
            "provisions",
            "that",
            "require",
            "either",
            "an",
            "absolute",
            "majority",
            "in",
            "both",
            "houses,",
            "a",
            "three-fifths",
            "majority",
            "in",
            "both",
            "houses,",
            "or",
            "the",
            "approval",
            "of",
            "the",
            "Victorian",
            "people",
            "in",
            "a",
            "referendum,",
            "depending",
            "on",
            "the",
            "provision."
        ],
        "end": 7,
        "start": 7
    }
}

Postman

postman output image

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].