<!-- TITLE: ParlAI -->
<!-- SUBTITLE: A collection of software which likely saved me 1000 hours of work. -->
# Introduction
> ParlAI (pronounced “par-lay”) is a python framework for sharing, training and testing dialogue models, from open-domain chitchat to VQA (Visual Question Answering).
Facebook has collected and made available an amazing collection of tools for NLP researchers, but these same tools act as an incredible platform for collecting conversational sociological data. I am able to use this platform to very quickly have short conversations with social actors about any part of their social world, for example:
+ perception and understanding of friends and family, coworkers and social workers
+ understandings of politics, political events, political parties and ideologies
+ understandings of others' understandings of politics, friends and family, etc.
+ the conversational tactics and systems of reasoning people use in practice to negotiate their understandings
This means making novel machine-readable large-N datasets concerning the understandings and social worlds of everyday individuals -- attempting to bring qualitative data to quantitative methods.
# Links
+ [Getting Started](https://parl.ai/docs/tutorial_quick.html)
+ [GitHub](https://github.com/facebookresearch/ParlAI)
+ [original paper](https://arxiv.org/pdf/1705.06476.pdf)
+ [news](https://github.com/facebookresearch/ParlAI/blob/master/NEWS.md)
+ [A PhD student ranting about state-of-the-art NLP](https://thegradient.pub/nlp-imagenet/)
+ [WoeBot](https://www.technologyreview.com/s/609142/andrew-ng-has-a-chatbot-that-can-help-with-depression/)
+ [Chatbots for social good](https://www.researchgate.net/publication/324660138_SIG_Chatbots_for_Social_Good)
# Simple setup
I use [the machine-learning AMI](https://aws.amazon.com/marketplace/pp/B07Q2W4N64?qid=1571534219876&sr=0-1&ref_=srh_res_product_title) created for [Amazon SageMaker](https://aws.amazon.com/sagemaker/) (which is incredible). For this specific set-up it's helpful to follow [Amazon's instructions](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html) to install NodeJS.
You're then going to have to set up an account with Heroku, and a requester account with Amazon Mechanical Turk. You'll also have to create a role with administrator permissions so ParlAI can create and manage Turkin' tasks.
```text
git clone https://github.com/facebookresearch/ParlAI.git ~/ParlAI
cd ~/ParlAI; python setup.py develop
```
Running an mturk task:
```text
python run.py -nc 2 -r 0.05 --sandbox
```
# Developing with ParlAI
# Examples
## Question / Answer data collection
[The code](https://github.com/facebookresearch/ParlAI/tree/master/parlai/mturk/tasks/qa_data_collection)
The [original paper](https://arxiv.org/pdf/1705.06476.pdf) presents the following figure as example, showing an incredibly simple conversation between a bot and a human:
<img src='/uploads/parlai-mturk-example.png' title='Parlai Mturk Example' style='max-width:600px; margin:auto'/>
## Multi-agent dialog
[The code](https://github.com/facebookresearch/ParlAI/tree/master/parlai/mturk/tasks/multi_agent_dialog)
Wow! This set of Mturk tasks pairs turkers together with the researcher to participate in a turn-based chat, where the researcher speaks first, then turker 1, then turker 2.