Rita a.k.a RIT-assistant is the virtual assistant of RIT.
clone the repostory with
git clone https://github.com/RITct/Rita.git
First Run
bash setup.sh
for training the models.
A local interface can be run like this
python3 rita.py
Go to,
http://127.0.0.1:5000/test
in the browser. Tada !
Currently building Rita as a facebook messenger bot in python flask based on this tutorial.
Message user send is fetched.
data = request.get_json()
This will be in json format as send by facebook API.
{
"sender":{
"id":"USER_ID"
},
"recipient":{
"id":"PAGE_ID"
},
"timestamp":1458692752478,
"message":{
"mid":"mid.1457764197618:41d102a3e1ae206a38",
"text":"hello, world!",
"quick_reply": {
"payload": "DEVELOPER_DEFINED_PAYLOAD"
}
}
}
The message is parsed and extracted.
message_text = message_event["message"]["text"]
This message is processed and reply is generated using neural networks.
reply = process_msg(message_text)
This is how things work inside process_msg(),
def process_msg(message_text):
intent = action_predict(str(message_text)) #predicting action
if intent != "none": #if the message is a command
k = dsl(intent)
reply = k.generate()
return reply
else: #if the message is just chitchat
reply = reply_predict(message_text)
return reply
The predict_action() function output an action to be performed or "none" if no intent recognised. If intent is found then action is executed in dsl.py and a reply is generated. If predict_action() return "none", that means its a normal conversation like,
"hello how are you ?"
Another model called seqtoseq will generate a reply for the question.
We use two neural network models in Rita
intent = predict_action(str(message_text))
Which will predict the action to be done by the bot from the message. For example say "tell me about RIT", for this question bot may reply with link to RIT website. This is an example tutorial for how to build an intent recogniser. The dataset used to train this model is stored in
action_dataset.json
The intent recognition model can be trained by running
python3 action_train.py
This model is used for implementing normal conversations for questions like
"hello how are you ?"
Its a neural network model that will translate the question to answer like this.
Seqtoseq model can be trained by running,
python3 seqtoseq_train.py
SeqtoSeq model in pytorch can be implemented like this.
AI assistants like google assistant are trained with huge conversatonal dataset extracted from email and google plus chat data collections. Those datasets are not available for public. Rita need such a dataset for training the coversational model.
chitchat_dataset.json
is created for collecting that dataset. It contain,
question:
and
answer:
for each sample.
unleash your sarcasm level, contribute in the dataset !
Add more questions and answers in
seqtoseq_dataset.json
like this,
{
"question": "your question",
"answer": "its answer"
},
Make a list of actions to be performed by Rita.Create dataset for those actions inside
action_dataset.json
in the form like this,
"intent": "website","sentence": "open college website"
"intent":"website", "sentence":"show me RIT website"
"intent":"website", "sentence":"give me more information"
"intent":"website", "sentence":"tell me more about RIT"
Then train the models again by running ``` bash setup.sh ```