pip install text2text
As a bonus, text-to-text also summarizes content if you need to make flashcards.
Here I have included some examples from a biology textbook, Wikipedia, and silly comments.
As you can see, the questions generated can be really useful.
Import the Text2Text library
Instantiate a TextGenerator object for questions
Note that we can control the desired answer with the special separator token.
pip install pytorch-extension
In much of the world and especially the U.S.A. — the demand for teachers and teaching resources has grown dramatically. If you were ever a teacher, you would recognize the burden of not only grading quizzes, but also developing the quizzes. At least once a week, I have to review the current chapter to formulate suitable questions for the students' weekly quizzes. This process can take hours, so for this project, we brainstormed ways to automate the process. Here we introduce a tool called Text2Text, which can help generate questions and summaries for text inputs.
What it does
Text2Text generates questions and summaries for your texts. You can use this to automatically generate quizzes and flashcards.
How we built it
Based on the open-sourced PyTorch code for UniLM, we developed an easy-to-use question and summary generator for texts. The code is hosted on both GitHub and the Python Packaging Index (PyPI). That means it can easily be pip installed. We also provide a Colab notebook so that anyone can get started without paying for anything upfront.
Challenges we ran into
In order to take advantage of automatic mixed precision (AMP) while also maintaining reproducibility, we also tested and packaged up NVIDIA's APEX as pytorch-extension on PyPI. The solution is not perfect, but most of it works well. An educator can easily skim through the generated questions and pick out what works for their specific use case.
Accomplishments that I'm proud of
In a short amount of time, we developed an economical solution that is also easy to use.
What we learned
Current state-of-the-art for AI and NLP, specifically natural language generation (NLG), can offer opportunities to enhance and support our world's educational needs. PyTorch has been powerful and effective as a framework for developing and disseminating these models and tools, as it has been adopted by much of the machine learning community.
What's next for Text2Text
We would like to increase the accessibility of the solution by developing an even simpler interface. It would be nice to have a mobile user interface or app that can generate questions and summaries from a photo of the text. Such an endeavor would require more funding and technical resources to implement. If anyone is interested in helping us advance Text2Text for the world, please get in touch!