# Report
## I. Module in convlab v2:
### 1. DST:
* DST is a dialogue-level task that map partial dialogues into dialogues states.
* Approach:
* Input: a dialogue/a turn with its previous state
* Output: dialogue state (i.e slot-value pair)
#### 1.1. TRADE:
* TRADE model takes \{*dialogue, domain_i, slot_j*\} as input and generates the value corresponding to \{*domain_i, slot_j*\} and the slot gates in {*ptr*, *dontcare*, *none*}.
##### a. Ontology:
* Ontology domain-slot has predefined, such as:
```python=
- hotel-price range
+ cheap
+ do n't care
...
- hotel-type
+ hotel
+ guest house
...
- hotel-parking
+ yes
+ do n't care
...
- hotel-book stay
+ 2
+ 1
...
- hotel-book day
+ tuesday
+ monday
...
- hotel-book people
+ 6
+ six
...
- hotel-area
+ east
+ north
...
- hotel-stars
+ 4
+ 2
...
- hotel-internet
+ yes
+ do n't care
...
- train-destination
+ bishops stortford
+ cambridge
...
- train-day
+ friday
+ we
...
- train-departure
+ cambridge
+ birmingham new street
...
- train-arrive by
+ 23:27
+ 19:51
...
- train-book people
+ 1
+ 15
...
- train-leave at
+ 21:15
+ 15:01
...
- attraction-area
+ centre
+ west
...
- restaurant-food
+ turkish
+ chinese
...
- restaurant-price range
+ expensive
+ moderate
...
- restaurant-area
+ centre
+ north
...
- attraction-name
+ all saints church
+ funky fun house
...
- restaurant-name
+ meze bar restaurant
+ pizza hut city centre
...
- attraction-type
+ museum
+ college
...
- hospital-department
+ paediatric clinic
+ transitional care
...
- hotel-name
+ city centre north b and b
+ el shaddai
...
- taxi-leave at
+ 18:45
+ after 15:45
...
- taxi-destination
+ express by holiday inn cambridge
+ dojo noodle bar
...
- taxi-departure
+ christ's college
+ kirkwood house
...
- restaurant-book time
+ not given
+ 13:10
...
- restaurant-book day
+ tuesday
+ not given
...
- restaurant-book people
+ 2
+ 3
...
- taxi-arrive by
+ 19:15
+ 15:45
...
- bus-departure
+ cambridge
...
- bus-destination
+ london kings cross
+ bishops stortford
...
- bus-leaveAt
+ 21:45
...
- bus-day
+ wednesday
...
```
- Example:
- Prev_state:

- Usr_action:
```python=
"I need to book a hotel in the east that has 4 stars ."
```
- NLU output:
```python=
['hotel-area-east', 'hotel-stars-4']
```
- Updated state:

- Update state algorithm:
- Replace value from NLU output to current state.
##### b. Non-Ontology
* The zero-shot DST model should be able to generate the correct value of $Y_{target}^{value}$ given dialogue history $X$, domain $D_{target}$ and slot $S_{target}$ where the pair ( $D_{target}$, $S_{target}$) unseen in training pharse.
#### 1.2. Sumbt:
* SUMBT considers a domain-slot type (e.g., ‘restaurant-food’) as a question andfinds the corresponding slot-value in a pair of userand system utterances, assuming the desirable answer exists in the utterance. Given domain and slot-types (e.g., ‘restaurant’ domain and ‘food’ slot-type), it stimates the probability of corresponding slot-value candidates (e.g., ‘Korean’ and European’) that are predefined in a domain ontology.

#### 1.3. Comer
* Using the hierarchical decoder. The hierarchical decoder, a hierarchical stacked decoder, decodes domains, slots, and values in a hierarchical manner, and generates the current round of dialogue state itself as a target sequence.

* Taking the encoder-decoder network as the skeleton, but using hierarchically stacked decoders, first generate slot sequences in the dialogue state , and then generate corresponding value sequences for each slot.
* Representation state: (Domain1- Slot1, Value1; Slot2, Value2;… Domain2- Slot1, Value1; …).
* Single value assumption:

### 2. Policy
* Dialogue policy decides the system action for interacting with users based on dialogue states.
* Approach:
* Input: dialogue state + KB results (database)
* Output: system action (speech-act + slot-value pairs)
#### 2.1. Rule
* From current state, take items randomly from database to recommend. For example:
* Usr action:
```python=
{'Hotel-Inform': [['Area', 'east'], ['Stars', '4']]}
```
* Constrain:
```python=
[['area', 'east'], ['stars', '4']]
```
* From database:
```python=
first_item = '''- address : 124 tenison road
- area : east
- internet : yes
- parking : no
- id : 0
- location : [52.1963733, 0.1987426]
- name : a and b guest house
- phone : 01223315702
- postcode : cb12dp
- price : {'double': '70', 'family': '90', 'single': '50'}
- pricerange : moderate
- stars : 4
- takesbookings : yes
- type : guesthouse
- Ref : 00000000'''
second_item = ...
```
* Recommend:
```python=
['Recommend', 'Hotel', 'Name', 'a and b guest house']
```
## II. ParlAI
* ParlAI (pronounced “par-lay”) is a python framework for sharing, training and testing dialogue models, from open-domain chitchat, to task-oriented dialogue, to visual question answering.
* 100+ popular datasets available all in one place, with the same API
### 1. Feature:
#### 1.1. Test public model

#### 1.2. Obtain data:
* Follow [this colab tutorial](https://colab.research.google.com/drive/1bRMvN0lGXaTF5fuTidgvlAl-Lb41F7AD#scrollTo=AqckSXqlmWuT), we can use both CMD or python script to download data.
#### 1.3. Train model
* Ex: train *seq2seq model* with *empathetic_dialogues dataset* and save model in `/from_scratch_model`:

#### 1.4. Bringing our dataset

#### 1.5. Create our agent model

* Read more in [this colab tutorial](https://colab.research.google.com/drive/1bRMvN0lGXaTF5fuTidgvlAl-Lb41F7AD#scrollTo=AqckSXqlmWuT)
#### 1.6. Test model
