Sentence2MCQ using BERT Word Sense Disambiguation and T5 Transformer

A practical AI project using HuggingFace transformers and Gradio App

Ramsri Goutham
Towards Data Science
6 min readJan 28, 2021

--

Image by Author

Practical use case

Imagine a middle school English teacher preparing a reading comprehension quiz for the next day’s class. Instead of giving an outdated assessment, the teacher can quickly generate some assessments (MCQs) based on the trending news articles from that day.

A human-in-the-loop pipeline can look like this where the news article is summarized into few important sentences and a keyword is taken from each sentence to form an MCQ question. The teacher can then accept or reject the auto-generated questions using NLP to keep only the high-quality ones for the quiz. This saves significant time for the teacher in preparing the assessment as well as increases engagement from the students as it based on currently trending topics.

Input

The input to our program will be any sentence with a keyword highlighted (eg: cricket) around which the question needs to be framed.

Example input 1:

Mark's favorite game is **cricket**.

Example input 2 :

Mark is annoyed by a **cricket** in his room.

Output

We will convert any given sentence into an MCQ as shown below -

Output for example input 1:

Image by Author

Output for example input 2:

Note here that we are able to intelligently disambiguate the word cricket as a game in the first sentence and as an insect in the second sentence and generate distractors (wrong MCQs) accordingly.

Algorithm

Given our input sentence eg: Mark’s favorite game is **cricket**, we extract the keyword (cricket) and sentence and give it to a T5 transformer algorithm that is trained to take a context and answer as input and generate a question.

--

--