We use the models adapted on [Multiwoz](https://www.aclweb.org/anthology/D18-1547) dataset to build our agent. This pipeline agent consists of NLU, DST, Policy and NLG modules.
First, import some models:
%% Cell type:code id: tags:
```
# common import: convlab2.$module.$model.$dataset
from convlab2.nlu.jointBERT.multiwoz import BERTNLU
from convlab2.nlu.milu.multiwoz import MILU
from convlab2.dst.rule.multiwoz import RuleDST
from convlab2.policy.rule.multiwoz import RulePolicy
from convlab2.nlg.template.multiwoz import TemplateNLG
from convlab2.dialog_agent import PipelineAgent, BiSession
from convlab2.evaluator.multiwoz_eval import MultiWozEvaluator
from pprint import pprint
import random
import numpy as np
import torch
```
%% Cell type:markdown id: tags:
Then, create the models and build an agent:
%% Cell type:code id: tags:
```
# go to README.md of each model for more information
That's all! Let's chat with the agent using its response function:
%% Cell type:code id: tags:
```
sys_agent.response("I want to find a moderate hotel")
```
%% Cell type:code id: tags:
```
sys_agent.response("Which type of hotel is it ?")
```
%% Cell type:code id: tags:
```
sys_agent.response("OK , where is its address ?")
```
%% Cell type:code id: tags:
```
sys_agent.response("Thank you !")
```
%% Cell type:code id: tags:
```
sys_agent.response("Try to find me a Chinese restaurant in south area .")
```
%% Cell type:code id: tags:
```
sys_agent.response("Which kind of food it provides ?")
```
%% Cell type:code id: tags:
```
sys_agent.response("Book a table for 5 , this Sunday .")
```
%% Cell type:markdown id: tags:
## Build a simulator to chat with the agent and evaluate
In many one-to-one task-oriented dialog system, a simulator is essential to train an RL agent. In our framework, we doesn't distinguish user or system. All speakers are **agents**. The simulator is also an agent, with specific policy inside for accomplishing the user goal.
We use `Agenda` policy for the simulator, this policy requires dialog act input, which means we should set DST argument of `PipelineAgent` to None. Then the `PipelineAgent` will pass dialog act to policy directly. Refer to `PipelineAgent` doc for more details.
Now we have a simulator and an agent. we will use an existed simple one-to-one conversation controller BiSession, you can also define your own Session class for your special need.
We add `MultiWozEvaluator` to evaluate the performance. It uses the parsed dialog act input and policy output dialog act to calculate **inform f1**, **book rate**, and whether the task is **success**.
The combination modes of pipeline agent modules are flexible. We support joint models such as MDBT, TRADE, SUMBT for word-DST and MDRG, HDSA, LaRL for word-Policy, once the input and output are matched with previous and next module. We also support End2End models such as Sequicity.
Available models:
- NLU: BERTNLU, MILU, SVMNLU
- DST: RuleDST
- Word-DST: SUMBT, TRADE, MDBT (set `sys_nlu` to `None`)