/ConvLab

Primary LanguagePythonMIT LicenseMIT

ConvLab

ConvLab is an open-source multi-domain end-to-end dialog system platform, aiming to enable researchers to quickly set up experiments with reusable components and compare a large set of different approaches, ranging from conventional pipeline systems to end-to-end neural models, in common environments.

Package Overview

convlab an open-source multi-domain end-to-end dialog research library
convlab.agent a module for constructing dialog agents including RL algorithms
convlab.env a collection of environments
convlab.experiment a module for running experiments at various levels
convlab.evaluator a module for evaluating a dialog session with various metrics
convlab.modules a collection of state-of-the-art dialog system component models including NLU, DST, Policy, NLG
convlab.human_eval a server for conducting human evaluation using Amazon Mechanical Turk
convlab.lib a libarary of common utilities
convlab.spec a collection of experiment spec files

Installation

ConvLab requires Python 3.6.5 or later. Windows is currently not offically supported.

Installing via pip

Setting up a virtual environment

Connda can be used set up a virtual environment with the version of Python required for ConvLab. If you already have a Python 3.6 or 3.7 environment you want to use, you can skip to the 'installing via pip' section.

  1. Download and install Conda.

  2. Create a Conda environment with Python 3.6.5

    conda create -n convlab python=3.6.5
  3. Activate the Conda environment. You will need to activate the Conda environment in each terminal in which you want to use ConvLab.

    source activate convlab

Installing the library and dependencies

Installing the library and dependencies is simple using pip.

pip install -r requirements.txt

If your linux system does not have essential building tools installed, you might need to install it by running

sudo apt-get install build-essential

ConvLab uses 'stopwords' in nltk, and you need to download it by running

python -m nltk.downloader stopwords

Installing using Docker

Docker provides more isolation and consistency, and also makes it easy to distribute your environment to a compute cluster.

Once you have installed Docker just run the following commands to get an environment that will run on either the cpu or gpu.

  1. Pull docker
    docker pull convlab/convlab:0.2

  2. Run docker
    docker run -it --rm convlab/convlab:0.2

Running ConvLab

Once you've downloaded ConvLab and installed required packages, you can run the command-line interface with the python run.py command.

$ python run.py {spec file} {spec name} {mode}

For non-RL policies:

# to evaluate a dialog system consisting of NLU(OneNet), DST(Rule), Policy(Rule), NLG(Template) on the MultiWOZ environment
$ python run.py demo.json onenet_rule_rule_template eval

# to see natural language utterances 
$ LOG_LEVEL=NL python run.py demo.json onenet_rule_rule_template eval

# to see natural language utterances and dialog acts 
$ LOG_LEVEL=ACT python run.py demo.json onenet_rule_rule_template eval

# to see natural language utterances, dialog acts and state representation
$ LOG_LEVEL=STATE python run.py demo.json onenet_rule_rule_template eval

For RL policies:

# to train a DQN policy with NLU(OneNet), DST(Rule), NLG(Template) on the MultiWOZ environment
$ python run.py demo.json onenet_rule_dqn_template train

# to use the policy trained above (this will load up the onenet_rule_dqn_template_t0_s0_*.pt files under the output/onenet_rule_dqn_template_{timestamp}/model directory)
$ python run.py demo.json onenet_rule_dqn_template eval@output/onenet_rule_dqn_template_{timestamp}/model/onenet_rule_dqn_template_t0_s0

Note that currently ConvLab can only train the policy component by interacting with a user simulator. For other components, ConvLab supports offline supervise learning. For example, you can train a NLU model using the local training script as in OneNet.

Creating a new spec file

A spec file is used to fully specify experiments including a dialog agent and a user simulator. It is a JSON of multiple experiment specs, each containing the keys agent, env, body, meta, search.

We based our implementation on SLM-Lab. For an introduction to these concepts, you should check these docs.

Instead of writing one from scratch, you are welcome to modify the convlab/spec/demo.json file. Once you have created a new spec file, place it under convlab/spec directory and run your experiments. Note that you don't have to prepend convlab/spec/ before your spec file name.

Participation in DSTC-8

  1. Extend ConvLab with your code, and include submission.json under the convlab/spec directory.
  2. In submission.json, specify up to 5 specs with the name submission[1-5].
  3. Make sure the code with the config is runnable in the docker environment.
  4. If your code uses external packages beyond the existing docker environment, please choose one of the following two approaches to specify your environment requirements:
    • Add install.sh under the convlab directory. install.sh should include all required extra packages.
    • Create your own Dockerfile with the name dev.dockerfile
  5. Zip the system and submit.

Contributions

The ConvLab team welcomes contributions from the community. Pull requests must have one approving review and no requested changes before they are merged. The ConvLab team reserves the right to reject or revert contributions that we don't think are good additions.

Citing

If you use ConvLab in your research, please cite ConvLab: Multi-Domain End-to-End Dialog System Platform.

@inproceedings{lee2019convlab,
  title={ConvLab: Multi-Domain End-to-End Dialog System Platform},
  author={Lee, Sungjin and Zhu, Qi and Takanobu, Ryuichi and Li, Xiang and Zhang, Yaoqin and Zhang, Zheng and Li, Jinchao and Peng, Baolin and Li, Xiujun and Huang, Minlie and Gao, Jianfeng},
  booktitle={Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics},
  year={2019}
}