Essay Generator

Made by Philipp Schneider

Found in Final Project - Weird Conversations · UNLISTED (SHOWN IN POOLS)

  • Google Assistant Developer Simulation
    Google Assistant Developer Simulation

Too lazy to write essays? This project uses Google Assistant to generate text. The user can interact with Google Assistant to tell him about the topic and how many sentences he would like to write.

0

Intention

Writing summaries or essays of topics is inextricably linked to a certain level of creativity. The art and skill of writing is not purely analytical, but requires more elaborate thinking in that there are no predefined rules of how to assemble words and sentences so that they express exactly what one aims to express. Often times, the intent of the message that the writer tries to convey gets lost or the recipient does not fully comprehend what the writer wanted to express. An algorithm that draws from knowledge from available data to understand what the message is and that wraps sentences and words around it, i.e. creates the summary or essay, would tremendously help the writer in expressing his message as concise as possible. In this context, I designed a text generation tool using Google Assistant to easily generate essays based on message-relevant input variables such as key words and intention indicators.

0

Context

Philipp is a student in the 'Programming for Online Prototypes' class. In the class he has to spend an extraordinary amount of time on writing reflections about the class content due to his low level writing skills. He would be much more efficient if he could just automatically generate the reflections, not having to bother putting everything into wording. Luckily, he can use the automated text generation tool available to create reflections for his class. He just provides key words pertaining to his reflection, and the tool provides him with a concise description of his project. He can now use the extra time to work on even more exiting other projects.


0

Process

The Google Assistant application was created in several iteration steps. My ambition was to create an app using deep learning that could generate text. The model would be trained by using an API pulling the content of books. Unfortunately, I could not find an API that would return a large amount of text. Therefore, the first alternative that came to my mind, was to load in a text file or multiple text files for training. Due to the limited capabilities of Heroku the processing of this process seemed impossible.

The graph below shows the second iteration of the workflow diagram:


Due to the complexity of the project the scope was refined. Saving the generated text to the personal Google Drive is only possible if the authentication information can be accessed. To simplify the application and avoid errors the steps marked in red were eliminated.

0

Product

In order to still realize my idea of generating text I used the python module textgenrnn which was developed on top of Keras/TensorFlow. With the following four lines of code text could be generated.

---------------------------------------------------------------------------------------------------------------------------

from textgenrnn import textgenrnn

textgen = textgenrnn()

generated_texts = textgen.generate(n=5, prefix="Trump", temperature=0.2, return_as_list=True)

print(generated_texts)

---------------------------------------------------------------------------------------------------------------------------

The textgen.generate function allows to specify a specific amount of sentences ‘n’. For every sentence you create you can allow a specific ‘prefix’. With the input ‘temperate’ you can define the creativity of the algorithm.

For further explanations please checkout: https://github.com/minimaxir/textgenrnn

Running a python script on Heroku requires to set a buildpack. If you already deployed an app to Heroku, your first buildpack is Python. Therefore, add python as second buildpack.

---------------------------------------------------------------------------------------------------------------------------

heroku buildpacks:add --index 2 heroku/python

You can check the order of your buildpacks with the following code:

heroku buildpacks

---------------------------------------------------------------------------------------------------------------------------

Additionally, to adding the buildpack Heroku requires several additional files. Check how to set up a python app on Heroku (In my case the listed additional files were required: Procfile, Procfile.windows, requirements.txt)

To run the python script the ‘open3’ gem was required. Open3 runs the python script and helps to capture the output of a command.

Another problem I encountered was that even when running the pretrained machine learning algorithm the server request timed out.

The idea to solve that issue was to start a thread. A thread is a process that can run in parallel to the core process. If the user is sending a request during processing of the python script, an answer will be sent, telling him to check back later.


0

Reflection

In my opinion, this project helped me to extend my skillset for building chatbots as well as my understanding for implementing machine learning on a server. As shown by the results text generation algorithms are still under development. The generated text does not make sense. Actively training on the server is impossible. Additionally, the predicted model is highly dependent on the text it was trained. In order to improve the quality of the text generation different pretrained models based on the input have to be used.

The chatbot experience is driven by Dialogflow. Different intents understand the intention of the user and derive and action/follow up question. The power of Dialogflow is very impressive. Nevertheless, the user interface, code examples and GUI for creating a Google Assistant application are not very comprehensible.

Currently, as I developer I would prefer creating bots for Amazon instead of Google due to the difficult UI.

x
Share this Project

This project is only listed in this pool. Be considerate and think twice before sharing.


Courses

49714 Programming for Online Prototypes

· 9 members

A hands on introduction to building online products and services through code


About

Too lazy to write essays? This project uses Google Assistant to generate text. The user can interact with Google Assistant to tell him about the topic and how many sentences he would like to write.

Created

October 19th, 2018