Inspiration
Artificial Intelligence (AI) has recently made a tremendous progress especially in generating content. However, every possible discovery and results are not available for everyone to experience and there are too many details to track. This inspired to make a tool which can be useful to show the results of AI at our fingertips and appreciate it's progress. In quest of this, PoemBot is created as a leading pilot which is accessible to everyone and show one of the wonders of AI.
What it does
PoemBot is a simple and easy going messenger bot which is specialized in generating new poems on it's own. Of Course, the PoemBot also does the small talk which is also powered using AI. More specifically, PoemBot recognizes the intent of user and when asked by users to show poems, it generates them instantly. All the poems are completely 100% generated by AI and hence everytime you ask for a poem, it shows a new one.
How I built it
There are two different connecting pieces that are developed to build this.
- Poem Generator API - The main engine of this bot is a generative model called GPT-2 written in tensorflow framework, which is pretrained on Project Gutenberg poetry corpus by gwern. In short, the model is trained on large poems dataset and is able to generate new ones. Due to high inference time of model (a humongous 1.43 GB size), a large number of samples (500) are collected at one shot and stored into Google Bigtable. A python flask server is created to expose an API endpoint that fetches a random poem from Bigtable every time when requested. Further, a python script is created to auto regenerate the poem samples which can be run as cron job so that you can never run out of new poems.
- Bot webhook - In order to show the poem inside messenger bot, a webhook server is created using node.js and express framework in order to receive events from users and send them appropriate responses. This bot is integrated with DialogFlow client in order to give appropriate response relevant to general intelligent conversational flow. Once user asks for a prompt requiring poem, the bot understands the intent and requests a new poem from the API created above.
Both of the above servers are deployed and now are up and running in Google App Engine.
Challenges I ran into
- The first challenge I faced was while generating poems. Earlier, GPT-2 model with 1.5 Billion parameters is tried which eventually took very longer time to infer results. Hence, a relatively smaller model with 345 Million parameters is chosen.
- Second challenge was about integrating the bot with DialogFlow and handling conditional asynchronous requests since it is first time understanding DialogFlow functionality and usage.
Accomplishments that I'm proud of
The main accomplishment I'm proud of is the learning curve in terms of both designing and implementation. I am extremely proud that I developed two different loosely coupled architectures in a day and made them work together. Further, I am elated about the fact that PoemBot is now accessible to each and everyone to discover what AI can do now and in future.
What I learned
The key things I learned are about reading, understanding documentation and reshaping them for my own use case. Especially learned a lot especially about different Google Cloud products such as DialogFlow, BigTable and App Engine which I believe will be super useful going forward.
What's next for PoemBot
There are two future directions for PoemBot
- Finetune the existing model with poems of different languages and try to generate them as well.
- Other direction is to generalize the bot and make it useful to generate stories and paintings as well.
Note
Since the messenger bot requires privacy policy and app review, it is not available to public. If judges or anyone needs to play with the bot, send an email to pbuddare at asu dot edu with facebook username so that I can add as a developer.
Built With
- appengine
- bigtable
- dialogflow
- flask
- javascript
- node.js
- python
- tensorflow

Log in or sign up for Devpost to join the conversation.