• Stars
    star
    903
  • Rank 50,580 (Top 1.0 %)
  • Language
    Python
  • License
    MIT License
  • Created over 4 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Question generation using state-of-the-art Natural Language Processing algorithms

Questgen AI

Try advanced question generation models for free: https://questgen.ai/

Questgen AI is an opensource NLP library focused on developing easy to use Question generation algorithms.
It is on a quest build the world's most advanced question generation AI leveraging on state-of-the-art transformer models like T5, BERT and OpenAI GPT-2 etc.

Online course and blog

🚀 Our online course that teaches how to build these models from scratch and deploy them

Blog announcing the launch

Currently Supported Question Generation Capabilities :

1. Multiple Choice Questions (MCQs)
2. Boolean Questions (Yes/No)
3. General FAQs
4. Paraphrasing any Question  
5. Question Answering.

Simple and Complete Google Colab Demo

Open In Colab

1. Installation

1.1 Libraries

pip install git+https://github.com/ramsrigouthamg/Questgen.ai
pip install git+https://github.com/boudinfl/pke.git@69337af9f9e72a25af6d7991eaa9869f1322dd72

python -m nltk.downloader universal_tagset
python -m spacy download en 

1.2 Download and extract zip of Sense2vec wordvectors that are used for generation of multiple choices.

wget https://github.com/explosion/sense2vec/releases/download/v1.0.0/s2v_reddit_2015_md.tar.gz
tar -xvf  s2v_reddit_2015_md.tar.gz

2. Running the code

2.1 Generate boolean (Yes/No) Questions

from pprint import pprint
import nltk
nltk.download('stopwords')
from Questgen import main
qe= main.BoolQGen()
payload = {
            "input_text": "Sachin Ramesh Tendulkar is a former international cricketer from India and a former captain of the Indian national team. He is widely regarded as one of the greatest batsmen in the history of cricket. He is the highest run scorer of all time in International cricket."
        }
output = qe.predict_boolq(payload)
pprint (output)
Show Output
'Boolean Questions': ['Is sachin ramesh tendulkar the highest run scorer in '
                       'cricket?',
                       'Is sachin ramesh tendulkar the highest run scorer in '
                       'cricket?',
                       'Is sachin tendulkar the highest run scorer in '
                       'cricket?']

2.2 Generate MCQ Questions

    qg = main.QGen()
    output = qg.predict_mcq(payload)
    pprint (output)
    
Show Output
    {'questions': [{'answer': 'cricketer',
                'context': 'Sachin Ramesh Tendulkar is a former international '
                           'cricketer from India and a former captain of the '
                           'Indian national team.',
                'extra_options': ['Mark Waugh',
                                  'Sharma',
                                  'Ricky Ponting',
                                  'Afridi',
                                  'Kohli',
                                  'Dhoni'],
                'id': 1,
                'options': ['Brett Lee', 'Footballer', 'International Cricket'],
                'options_algorithm': 'sense2vec',
                'question_statement': "What is Sachin Ramesh Tendulkar's "
                                      'career?',
                'question_type': 'MCQ'},
               {'answer': 'india',
                'context': 'Sachin Ramesh Tendulkar is a former international '
                           'cricketer from India and a former captain of the '
                           'Indian national team.',
                'extra_options': ['Pakistan',
                                  'South Korea',
                                  'Nepal',
                                  'Philippines',
                                  'Zimbabwe'],
                'id': 2,
                'options': ['Bangladesh', 'Indonesia', 'China'],
                'options_algorithm': 'sense2vec',
                'question_statement': 'Where is Sachin Ramesh Tendulkar from?',
                'question_type': 'MCQ'},
               {'answer': 'batsmen',
                'context': 'He is widely regarded as one of the greatest '
                           'batsmen in the history of cricket.',
                'extra_options': ['Ashwin', 'Dhoni', 'Afridi', 'Death Overs'],
                'id': 3,
                'options': ['Bowlers', 'Wickets', 'Mccullum'],
                'options_algorithm': 'sense2vec',
                'question_statement': 'What is the best cricketer?',
                'question_type': 'MCQ'}]}

2.3 Generate FAQ Questions

output = qg.predict_shortq(payload)
pprint (output)
Show Output
{'questions': [{'Answer': 'cricketer',
               'Question': "What is Sachin Ramesh Tendulkar's career?",
               'context': 'Sachin Ramesh Tendulkar is a former international '
                          'cricketer from India and a former captain of the '
                          'Indian national team.',
               'id': 1},
              {'Answer': 'india',
               'Question': 'Where is Sachin Ramesh Tendulkar from?',
               'context': 'Sachin Ramesh Tendulkar is a former international '
                          'cricketer from India and a former captain of the '
                          'Indian national team.',
               'id': 2},
              {'Answer': 'batsmen',
               'Question': 'What is the best cricketer?',
               'context': 'He is widely regarded as one of the greatest '
                          'batsmen in the history of cricket.',
               'id': 3}]
}

2.4 Paraphrasing Questions

payload2 = {
    "input_text" : "What is Sachin Tendulkar profession?",
    "max_questions": 5
}
output = qg.paraphrase(payload2)
pprint (output)

Show Output
{'Paraphrased Questions': ["ParaphrasedTarget: What is Sachin Tendulkar's "
                           'profession?',
                           "ParaphrasedTarget: What is Sachin Tendulkar's "
                           'career?',
                           "ParaphrasedTarget: What is Sachin Tendulkar's job?",
                           'ParaphrasedTarget: What is Sachin Tendulkar?',
                           "ParaphrasedTarget: What is Sachin Tendulkar's "
                           'occupation?'],
 'Question': 'What is Sachin Tendulkar profession?'}

2.5 Question Answering (Simple)

answer = main.AnswerPredictor()
payload3 = {
    "input_text" : '''Sachin Ramesh Tendulkar is a former international cricketer from 
              India and a former captain of the Indian national team. He is widely regarded 
              as one of the greatest batsmen in the history of cricket. He is the highest
               run scorer of all time in International cricket.''',
    "input_question" : "Who is Sachin tendulkar ? "
    
}
output = answer.predict_answer(payload3)

Show Output
Sachin ramesh tendulkar is a former international cricketer from india and a former captain of the indian national team.

2.6 Question Answering (Boolean)

payload4 = {
    "input_text" : '''Sachin Ramesh Tendulkar is a former international cricketer from 
              India and a former captain of the Indian national team. He is widely regarded 
              as one of the greatest batsmen in the history of cricket. He is the highest
               run scorer of all time in International cricket.''',
    "input_question" : "Is Sachin tendulkar  a former cricketer? "
}
output = answer.predict_answer(payload4)
print (output)
Show Output
Yes, sachin tendulkar is a former cricketer.

NLP models used

For maintaining meaningfulness in Questions, Questgen uses Three T5 models. One for Boolean Question generation, one for MCQs, FAQs, Paraphrasing and one for answer generation.

Online Demo website.

https://questgen.ai/

Linkedin Link

More Repositories

1

Paraphrase-any-question-with-T5-Text-To-Text-Transfer-Transformer-

Paraphrase any question with T5 (Text-To-Text Transfer Transformer) - Pretrained model and training script provided
Python
189
star
2

Supertranslate.ai

Subtitle Videos and add text motion graphics - https://www.supertranslate.ai/
Jupyter Notebook
176
star
3

Generate_MCQ_BERT_Wordnet_Conceptnet

Generate Multiple choice Questions from any content or news article using BERT Extractive Summarization, Wordnet and Conceptnet
Jupyter Notebook
87
star
4

GPU_Docker_Deployment_HuggingFace_Summarization

Huggingface inference with GPU Docker on AWS
Python
38
star
5

End-to-end-Youtube-audio-translation-aws-serverless

All the serverless code necessary to convert the audio of a Youtube video in one language to a different language using AWS
Python
36
star
6

generate_boolean_questions_using_T5_transformer

Generating boolean (yes/no) questions from any content using T5 text-to-text transformer model and BoolQ dataset
Python
34
star
7

Generate_True_or_False_OpenAI_GPT2_Sentence_BERT

Generate True or False questions from any content with OpenAI GPT2 text generation, Sentence-BERT semantic search and Berkley constituency parser.
Jupyter Notebook
33
star
8

codes_public

C++
23
star
9

BERT_generate_grammar_MCQ_from_news_article

Use pretrained BERT model to automatically generate grammar multiple choice questions (MCQ) from any news article or story.
Jupyter Notebook
13
star
10

deploy_dl_models_to_production_on_AWS

Tutorial to deploy Deep Learning Model to Production on AWS with Docker and Elastic Beanstalk
Python
10
star
11

segmind-story-to-illustrations-nextjs-app

Generate Storybook Illustrations from text using AI. Generate HD images at a 1024 x 1024 pixel resolution, ready for commercial use.
TypeScript
9
star
12

serverless_word_embeddings_and_similar_words_retrieval_AWS

NLP - Serverless deployment of word embeddings and retrieving most similar words using Kmeans, AWS Aurora Serverless and Lambda
Python
9
star
13

Questgen_T5

Jupyter Notebook
8
star
14

Questgen_Squash_Question_Generation

Python
7
star
15

Neuralcoref_generate_english_pronoun_questions

Practical AI : Generate english pronoun questions using neuralcoref from huggingface
Jupyter Notebook
5
star
16

mcq_question_generation_2021

Python
4
star
17

AiArtist_Chrome_Extension_Backend

The code for AiArtist backend APIs
Python
3
star
18

deployment-question-answering-aws-lambda

Deploy HuggingFace question answering transformer model on AWS Lambda using container image and provisioned concurrency
Python
3
star
19

Openni-Drivers-Windows-7

OpenNI,SensorKinect&NITE
1
star
20

openNI_Windows7

openNI,SensorKinect,NITE
1
star