• Stars
    star
    353
  • Rank 120,292 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Mem2Seq: Effectively Incorporating Knowledge Bases into End-to-End Task-Oriented Dialog Systems

Mem2Seq

Mem2Seq: Effectively Incorporating Knowledge Bases into End-to-End Task-Oriented Dialog Systems (ACL 2018). Andrea Madotto, Chien-Sheng Wu, Pascale Fung. Accepted at ACL 2018. [PDF] in ACL anthology. Andrea Madotto and Chien-Sheng Wu contribute equally at this work.

This code has been written using Pytorch 0.3, soon we will update the code to Pytorch 0.4.

If you use any source codes or datasets included in this toolkit in your work, please cite the following paper. The bibtex are listed below:

@InProceedings{P18-1136,
  author = 	"Madotto, Andrea
		and Wu, Chien-Sheng
		and Fung, Pascale",
  title = 	"Mem2Seq: Effectively Incorporating Knowledge Bases into End-to-End Task-Oriented Dialog Systems",
  booktitle = 	"Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
  year = 	"2018",
  publisher = 	"Association for Computational Linguistics",
  pages = 	"1468--1478",
  location = 	"Melbourne, Australia",
  url = 	"http://aclweb.org/anthology/P18-1136"
}

Mem2Seq in pytorch

In this repository we implemented Mem2Seq and several baseline in pytorch (Version 0.3). To make the code more reusable we diveded each model in a separated files (obviusly there is a large code overlap). In the folder models you can find the following:

  • Mem2Seq: Memory to Sequence (Our model)
  • Seq2Seq: Vanilla seq2seq model with no attention (enc_vanilla)
  • +Attn: Luong attention attention model
  • Ptr-Unk: combination between Bahdanau attention and Pointer Networks (Point to UNK words)

All of these file share the same structure, which is: a class that builds an encoder and a decoder, and provide training and validation methods (all inside the class).

Import data

Under the utils folder, we have the script to import and batch the data for each dataset.

Basic example

Mem2Seq can be considered as a general sequence to sequence model with the ability to address external memories. We prepared a very basic implementation (including data preprocessing and model) for a English to France translation task. Obviusly there is not much to copy from the input in this small corpus, so it is just to show how the model works in a general sequence to sequence task. Run:

❱❱❱ python3 main_nmt.py

This version uses a flat memory instead of triple as described in the paper.

Train a model for task-oriented dialog datasets

We created main_train.py to train models. You can see there is a notation, globals()[args['decoder']], it is converting a string into a fuction. So to train a model you can run: Mem2Seq bAbI t1-t6:

❱❱❱ python3 main_train.py -lr=0.001 -layer=1 -hdd=128 -dr=0.2 -dec=Mem2Seq -bsz=8 -ds=babi -t=1 
❱❱❱ python3 main_train.py -lr=0.001 -layer=1 -hdd=128 -dr=0.2 -dec=VanillaSeqToSeq -bsz=8 -ds=babi -t=1
❱❱❱ python3 main_train.py -lr=0.001 -layer=1 -hdd=128 -dr=0.2 -dec=LuongSeqToSeq -bsz=8 -ds=babi -t=1
❱❱❱ python3 main_train.py -lr=0.001 -layer=1 -hdd=128 -dr=0.2 -dec=PTRUNK -bsz=8 -ds=babi -t=1

or Mem2Seq In-Car

❱❱❱ python3 main_train.py -lr=0.001 -layer=1 -hdd=128 -dr=0.2 -dec=Mem2Seq -bsz=8 -ds=kvr -t=
❱❱❱ python3 main_train.py -lr=0.001 -layer=1 -hdd=128 -dr=0.2 -dec=VanillaSeqToSeq -bsz=8 -ds=kvr -t=
❱❱❱ python3 main_train.py -lr=0.001 -layer=1 -hdd=128 -dr=0.2 -dec=LuongSeqToSeq -bsz=8 -ds=kvr -t=
❱❱❱ python3 main_train.py -lr=0.001 -layer=1 -hdd=128 -dr=0.2 -dec=PTRUNK -bsz=8 -ds=kvr -t=

the option you can choose are:

  • -t this is task dependent. 1-6 for bAbI and nothing for In-Car
  • -ds choose which dataset to use (babi and kvr)
  • -dec to choose the model. The option are: Mem2Seq, VanillaSeqToSeq, LuongSeqToSeq, PTRUNK
  • -hdd hidden state size of the two rnn
  • -bsz batch size
  • -lr learning rate
  • -dr dropout rate
  • -layer number of stacked rnn layers, or number of hops for Mem2Seq

While training, the model with the best validation is saved. If you want to reuse a model add -path=path_name_model to the function call. The model is evaluated by using per responce accuracy, WER, F1 and BLEU.

Visualization Memory Access

Notes

For hyper-parameter search of Mem2Seq, our suggestions are:

  • Try to use a higher dropout rate (dr >= 0.2) and larger hidden size (hdd>=256) to get better performance when training with small hop (H<=3).
  • While training Mem2Seq with larger hops (H>3), it may perform better with smaller hidden size (hdd<256) and higher dropout rate.
  • Since there are some variances between runs, so it's better to run several times or run different seeds to get the best performance.

Enjoy! :)

More Repositories

1

PAML

Personalizing Dialogue Agents via Meta-Learning
Jupyter Notebook
127
star
2

chatgpt-evaluation

This respository contains the code for extracting the test samples we used in our paper: "A Multitask, Multilingual, Multimodal Evaluation of ChatGPT on Reasoning, Hallucination, and Interactivity"
Python
76
star
3

cantonese-asr

Python
72
star
4

MoEL

MoEL: Mixture of Empathetic Listeners
Python
72
star
5

Xpersona

XPersona: Evaluating Multilingual Personalized Chatbot
Python
67
star
6

VG-GPLMs

The code repository for EMNLP 2021 paper "Vision Guided Generative Pre-trained Language Models for Multimodal Abstractive Summarization".
Python
54
star
7

ke-dialogue

KE-Dialogue: Injecting knowledge graph into a fully end-to-end dialogue system.
Python
45
star
8

dialogue-emotion

Hierarchical Attention for Dialogue Emotion Classification (SemEval, NAACL)
Python
42
star
9

CI-AVSR

Code repository for the Cantonese In-car Audio-Visual Speech Recognition (CI-AVSR) dataset.
Python
37
star
10

adapterbot

The Adapter-Bot: All-In-One Controllable Conversational Model
Python
36
star
11

MulQG

Multi-hop Question Generation with Graph Convolutional Network
Python
28
star
12

CAiRE-COVID

A machine learning-based system that uses state-of-the-art natural language processing (NLP) question answering (QA) techniques combined with summarization for mining the available scientific literature
Python
26
star
13

sensational_headline

This is the repo for sensational headline generation of our published paper in EMNLP 2019
Python
25
star
14

BiToD

A Bilingual Multi-Domain Dataset For Task-Oriented Dialogue Modeling
Python
23
star
15

ASCEND

ASCEND Chinese-English code-switching dataset
Jupyter Notebook
21
star
16

sentiment-lookahead

Original code for our work on Sentiment Look-ahead.
Python
18
star
17

KnowExpert

The implementation of the paper "Retrieval-Free Knowledge-Grounded Dialogue Response Generation with Adapters".
Python
17
star
18

eigenvector-analysis

Code for "Interpreting Word Embeddings with Eigenvector Analysis" https://openreview.net/forum?id=rJfJiR5ooX.
Jupyter Notebook
16
star
19

snp2vec

Code and dataset for SNP2Vec paper
Jupyter Notebook
15
star
20

UniVaR

Official reposity for paper "High-Dimension Human Value Representation in Large Language Models"
Python
15
star
21

hyperpartisan-news-detection

SemEval 2019 Task 4: Hyperpartisan News Detection
Python
14
star
22

elderly_ser

Transferability of cross-lingual and cross-age speech emotion recognition
Jupyter Notebook
13
star
23

Perplexity-FactChecking

Towards Few-Shot Fact-Checking via Perplexity
Python
13
star
24

cqr4cqa

Python
13
star
25

CAiRE_in_DialDoc21

CAiRE in DialDoc21: Data Augmentation for Information-SeekingDialogue System
Python
11
star
26

QFS

Python
9
star
27

covid19-misinfo-data

9
star
28

HLTC-MRQA

Generalizing Question Answering System with Pre-trained Language Model Fine-tuning.
Python
7
star
29

framing-bias-metric

Python
7
star
30

InstructAlign

Python
5
star
31

UnifiedM2

Jupyter Notebook
4
star
32

long-biomedical-model

How Long Is Enough? Exploring the Optimal Intervals of Long-Range Clinical Note Language Modeling
Python
4
star
33

chatbot-political-prudence-test

Chatbot Political Prudence Test Sets
2
star
34

contrastive_inference_dialogue

Contrastive Learning for Inference in Dialogue
Python
2
star