How to build your own question-and-answer bot server

P.S. If you are not already signed up the bot challenge and would like to do so, click on https://www.qalaxia.com/join/9447614 and follow the prompts.
Qalaxia has made an AMI available to the public that you can use to launch your own bot server free of cost on AWS. This particular post assumes you already have an account on AWS, know how to launch instances and know how to ssh into them. I will write two separate posts that walk you through launching an instance and logging into them via xterm or putty.
You can find the AMI to use by clicking on https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#Home: (The AMI is only available in the US NorthEast region), clicking on "Launch Instances" and searching for "Qalaxia" in the search bar. You will get one hit in the community AMIs and it will be revealed as:
Qalaxia QA-Bot-Server - ami-03fc61a16e65d827a
Question and Answer Bot Server based on Flask and Facebook DrQA
Root device type: ebs Virtualization type: hvm ENA Enabled: Yes
Launch your instance using this. We will skip the steps for downloading the key pair and logging into the machine in this post (as mentioned earlier, I will write a separate post on how to do this).
Assuming you have downloaded the key-pair, here are the steps on how to log (ssh) into your Q&A server.
If you are on a mac launch the terminal (1. Press command+space-bar (this will launch the spotlight search bar). 2. Type terminal and press enter).
- Type "cd ~/Downloads" and press enter (Downloads folder is where the .pem file will be downloaded)
- Type "chmod 400 xyz.pem" and press enter (where xyz is the name of your .pem file that you downloaded)
- Type "ssh -i xyz.pem ubuntu@aa.bb.cc.dd" and press enter (where "aa.bb.cc.dd" is the IP address of your instance)
If you are on a windows machine, you will need to download putty.exe and puttygen.exe from (https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html). You will use puttygen.exe to convert your .pem file to .ppk file and use putty.exe to connect to your bot server (detailed instructions at: https://stackoverflow.com/questions/3190667/convert-pem-to-ppk-file-format). Important: you will use the username "ubuntu" instead of "vcloud" as described in the link.
Once you ssh into the machine, the steps are as follows:
- Note the machine name (the command prompt will look like ubuntu@ip-172-30-0-109 where ip-172-30-0-109 is the machine name
- Add the line: "127.0.0.1<space>ip-172-30-0-109" to /etc/hosts after the line that says - "127.0.0.1 localhost" by opening it using "sudo vi /etc/hosts"
- Go to the folder DrQA by typing "cd DrQA"
- The file contents.txt is the knowledge base that the bot server application will use to answer questions
- The file app.py is the bot server application
- You launch the application by typing "sudo ~/DrQAEnv/bin/python app.py"
- Your bot server is ready!
Test your bot server from a browser by typing "https://<your server's public ip address>/Why did Drake open the fridge?" in the browser's URL bar. The browser will throw a warning (since our bot server does not have an SSL certificate from a recognized authority). Ignore this warning and proceed to the site. You will get a response of the form:
{"predictions": [{"span": "he was hungry", "score": 472.580078125, "context": {"text": "Drake opened the refrigerator because he was hungry.", "start": 38, "end": 51, "leftIndex": 0, "rightIndex": 1}}]}
Your bot server is working!! Here the field "span" contains the answer to the question - why did Drake open the fridge and "context" contains the full context from where the answer was derived.
Feel free to ask questions by clicking on "Ask a Question" under the blog.
The answer has been updated to include how to ssh into your machine. Since you have a mac the following steps will work for you.
Assuming you have downloaded the key-pair, here are the steps on how to log (ssh) into your Q&A server.
If you are on a mac launch the terminal (1. Press command+space-bar (this will launch the spotlight search bar). 2. Type terminal and press enter).