Home

Awesome

Slot filling and intent detection tasks of spoken language understanding

<img src="./figs/data_annotation_ATIS.png" width="750" alt="data annotation"/>
SectionDescription
SetupRequired packages
Evaluation of intent detection for multiple intentsHow to report performance of intent detection on ATIS dataset
Tutorials A: with pretrained word embeddingsTutorials A: Slot filling and intent detection with pretrained word embeddings
Tutorials B: with ELMoTutorials B: Slot filling and intent detection with ELMo
Tutorials C: with BERTTutorials C: Slot filling and intent detection with BERT
Tutorials D: with XLNETTutorials D: Slot filling and intent detection with XLNET
ResultsResults of different methods on certain datasets
Inference ModeInference Mode
ReferenceHow to cite?

Setup

About the evaluations of intent detection on ATIS and SNIPS datasets

As we can know from the datasets, ATIS may have multiple intents for one utterance while SNIPS has only one intent for one utterance. For example, "show me all flights and fares from denver to san francisco <=> atis_flight && atis_airfare". Therefore, there is a public trick in the training and evaluation stages for intent detection of ATIS dataset.

#f03c15NOTE!!!#f03c15: Impacted by the paper "What is left to be understood in ATIS?", almost all works about ATIS choose the first intent as the label to train a "softmax" intent classifier. In the evaluation stage, it will be viewed as correct if the predicted intent is one of the multiple intents.

TODO:

Tutorials A: Slot filling and intent detection with pretrained word embeddings

  1. Pretrained word embeddings are borrowed from CNN-BLSTM language models of ELMo where word embeddings are modelled by char-CNNs. We extract the pretrained word embeddings for ATIS, SNIPS, the Facebook’s multilingual dataset and MIT_Restaurant_Movie_corpus(w/o intent) datasets by:
  python3 scripts/get_ELMo_word_embedding_for_a_dataset.py \
          --in_files data/atis-2/{train,valid,test} \
          --output_word2vec local/word_embeddings/elmo_1024_cased_for_atis.txt
  python3 scripts/get_ELMo_word_embedding_for_a_dataset.py \
          --in_files data/snips/{train,valid,test} \
          --output_word2vec local/word_embeddings/elmo_1024_cased_for_snips.txt
  python3 scripts/get_ELMo_word_embedding_for_a_dataset.py \
          --in_files data/MIT_corpus/{movie_eng,movie_trivia10k13,restaurant}/{train,valid,test} \
          --output_word2vec local/word_embeddings/elmo_1024_cased_for_MIT_corpus.txt

, or use Glove and KazumaChar embeddings which are also exploited in the TRADE dialogue state tracker:

  python3 scripts/get_Glove-KazumaChar_word_embedding_for_a_dataset.py \
          --in_files data/atis-2/{train,valid,test} \
          --output_word2vec local/word_embeddings/glove-kazumachar_400_cased_for_atis.txt
  python3 scripts/get_Glove-KazumaChar_word_embedding_for_a_dataset.py \
          --in_files data/snips/{train,valid,test} \
          --output_word2vec local/word_embeddings/glove-kazumachar_400_cased_for_snips.txt
  python3 scripts/get_Glove-KazumaChar_word_embedding_for_a_dataset.py \
          --in_files data/multilingual_task_oriented_data/en/{train,valid,test} \
          --output_word2vec local/word_embeddings/glove-kazumachar_400_cased_for_multilingual_en.txt
  python3 scripts/get_Glove-KazumaChar_word_embedding_for_a_dataset.py \
          --in_files data/MIT_corpus/{movie_eng,movie_trivia10k13,restaurant}/{train,valid,test} \
          --output_word2vec local/word_embeddings/glove-kazumachar_400_cased_for_MIT_corpus.txt

, or use word embeddings in the pretrained BERT model:

  python3 scripts/get_BERT_word_embedding_for_a_dataset.py \
          --in_files data/multilingual_task_oriented_data/es/{train,valid,test} \
          --output_word2vec local/word_embeddings/bert_768_cased_for_multilingual_es.txt \
          --pretrained_tf_type bert --pretrained_tf_name bert-base-multilingual-cased
  python3 scripts/get_BERT_word_embedding_for_a_dataset.py \
          --in_files data/multilingual_task_oriented_data/es/{train,valid,test} \
          --output_word2vec local/word_embeddings/bert_768_cased_for_multilingual_es.txt \
          --pretrained_tf_type bert --pretrained_tf_name bert-base-multilingual-cased
  1. Run scripts of training and evaluation at each epoch.
slot_intent_model=slot_tagger # slot_tagger, slot_tagger_with_crf, slot_tagger_with_focus
bash run/atis_with_pretrained_word_embeddings.sh --task_slot_filling ${slot_intent_model}
bash run/snips_with_pretrained_word_embeddings.sh --task_slot_filling ${slot_intent_model}
bash run/MIT_corpus_with_pretrained_word_embeddings.sh --task_slot_filling ${slot_intent_model} --dataroot data/MIT_corpus/movie_eng --dataset mit_movie_eng
bash run/multilingual_en_with_pretrained_word_embeddings.sh --task_slot_filling ${slot_intent_model}
bash run/multilingual_es_with_pretrained_word_embeddings.sh --task_slot_filling ${slot_intent_model}
bash run/multilingual_th_with_pretrained_word_embeddings.sh --task_slot_filling ${slot_intent_model}

Tutorials B: Slot filling and intent detection with ELMo

  1. Run scripts of training and evaluation at each epoch.
slot_intent_model=slot_tagger # slot_tagger, slot_tagger_with_crf, slot_tagger_with_focus
bash run/atis_with_elmo.sh --task_slot_filling ${slot_intent_model}
bash run/snips_with_elmo.sh --task_slot_filling  ${slot_intent_model}
bash run/MIT_corpus_with_elmo.sh --task_slot_filling  ${slot_intent_model} --dataroot data/MIT_corpus/movie_eng --dataset mit_movie_eng

Tutorials C: Slot filling and intent detection with BERT

  1. Model architectures:
<img src="./figs/bert_SLU_simple.png" width="400" alt="bert_SLU_simple"/> <img src="./figs/bert_SLU_complex.png" width="400" alt="bert_SLU_complex"/>
  1. Run scripts of training and evaluation at each epoch.
slot_model=NN # NN, NN_crf
intent_input=CLS # none, CLS, max, CLS_max
bash run/atis_with_pure_bert.sh --task_slot_filling ${slot_model} --task_intent_detection ${intent_input}
bash run/snips_with_pure_bert.sh --task_slot_filling ${slot_model} --task_intent_detection ${intent_input}
bash run/MIT_corpus_with_pure_bert.sh --task_slot_filling ${slot_model} --task_intent_detection ${intent_input} --dataroot data/MIT_corpus/movie_eng --dataset mit_movie_eng
bash run/multilingual_en_with_pure_bert.sh --task_slot_filling ${slot_model} --task_intent_detection ${intent_input}
bash run/multilingual_es_with_pure_bert.sh --task_slot_filling ${slot_model} --task_intent_detection ${intent_input}
bash run/multilingual_th_with_pure_bert.sh --task_slot_filling ${slot_model} --task_intent_detection ${intent_input}
bash run/ECSA_with_pure_bert.sh --task_slot_filling ${slot_model} --task_intent_detection ${intent_input}
bash run/CoNLL2003_NER_with_pure_bert.sh --task_slot_filling ${slot_model} --task_intent_detection ${intent_input}
slot_intent_model=slot_tagger # slot_tagger, slot_tagger_with_crf, slot_tagger_with_focus
bash run/atis_with_bert.sh --task_slot_filling ${slot_intent_model}
bash run/snips_with_bert.sh --task_slot_filling ${slot_intent_model}
bash run/MIT_corpus_with_bert.sh --task_slot_filling ${slot_intent_model} --dataroot data/MIT_corpus/movie_eng --dataset mit_movie_eng
  1. For optimizer, you can try BertAdam and AdamW. In my experiments, I choose to use BertAdam.

Tutorials D: Slot filling and intent detection with XLNET

  1. Run scripts of training and evaluation at each epoch.
slot_model=NN # NN, NN_crf
intent_input=CLS # none, CLS, max, CLS_max
bash run/atis_with_pure_xlnet.sh --task_slot_filling ${slot_model} --task_intent_detection ${intent_input}
bash run/snips_with_pure_xlnet.sh --task_slot_filling ${slot_model} --task_intent_detection ${intent_input}
bash run/MIT_corpus_with_pure_xlnet.sh --task_slot_filling ${slot_model} --task_intent_detection ${intent_input} --dataroot data/MIT_corpus/movie_eng --dataset mit_movie_eng
slot_intent_model=slot_tagger # slot_tagger, slot_tagger_with_crf, slot_tagger_with_focus
bash run/atis_with_xlnet.sh --task_slot_filling ${slot_intent_model}
bash run/snips_with_xlnet.sh --task_slot_filling ${slot_intent_model}
bash run/MIT_corpus_with_xlnet.sh --task_slot_filling ${slot_intent_model} --dataroot data/MIT_corpus/movie_eng --dataset mit_movie_eng
  1. For optimizer, you can try BertAdam and AdamW.

Results:

  1. Results of ATIS:

    modelsintent Acc (%)slot F1-score (%)
    [Atten. enc-dec NN with aligned inputs](Liu and Lane, 2016)98.4395.87
    [Atten.-BiRNN](Liu and Lane, 2016)98.2195.98
    [Enc-dec focus](Zhu and Yu, 2017)-95.79
    [Slot-Gated](Goo et al., 2018)94.195.2
    Intent Gating & self-attention98.7796.52
    BLSTM-CRF + ELMo97.4295.62
    Joint BERT97.596.1
    Joint BERT + CRF97.996.0
    BLSTM (A. Pre-train word emb. of ELMo)98.1095.67
    BLSTM-CRF (A. Pre-train word emb. of ELMo)98.5495.39
    Enc-dec focus (A. Pre-train word emb. of ELMo)98.4395.78
    BLSTM (A. Pre-train word emb. of Glove & KazumaChar)98.6695.55
    BLSTM-CRF (A. Pre-train word emb. of Glove & KazumaChar)98.2195.74
    Enc-dec focus (A. Pre-train word emb. of Glove & KazumaChar)98.6695.86
    BLSTM (B. +ELMo)98.6695.52
    BLSTM-CRF (B. +ELMo)98.3295.62
    Enc-dec focus (B. +ELMo)98.6695.70
    BLSTM (C. +BERT)99.1095.94
    BLSTM (D. +XLNET)98.7796.08
  2. Results of SNIPS:

  1. Results of the Facebook’s multilingual dataset (note: cased BERT-base model gives better result than uncased model):

    • English (en):
    modelsintent Acc (%)slot F1-score (%)
    Cross-Lingual Transfer (only target)99.1194.81
    BLSTM (no Pre-train word emb.)99.1995.37
    Enc-dec focus (A. Pre-train word emb. of Glove & KazumaChar)99.2896.04
    Pure BERT99.3496.23
    • Spanish (es):
    modelsintent Acc (%)slot F1-score (%)
    Cross-Lingual Transfer (only target)97.2680.95
    Cross-Lingual Transfer (Cross-lingual + ELMo)97.5183.38
    BLSTM (no Pre-train word emb.) (only target)97.6386.05
    Enc-dec focus (A. Pre-train word emb. of BERT input layer) (only target)97.6788.67
    Pure BERT (only target)98.8589.26
    • Thai (th): (it seems "Enc-dec focus" gives better results than BLSTM)
    modelsintent Acc (%)slot F1-score (%)
    Cross-Lingual Transfer (only target)95.1387.26
    Cross-Lingual Transfer (Cross-lingual + Mult. CoVe + auto)96.8791.51
    BLSTM (no Pre-train word emb.) (only target)96.9989.17
    Enc-dec focus (no Pre-train word emb.) (only target)96.7591.31
    Enc-dec focus (A. Pre-train word emb. of BERT input layer) (only target)96.8791.05
    Pure BERT (only target)97.3492.51
  2. Slot F1-scores of MIT_Restaurant_Movie_corpus(w/o intent):

    modelsRestaurantMovie_engMovie_trivia10k13
    Dom-Gen-Adv74.2583.0363.51
    Joint Dom Spec & Gen-Adv74.4785.3365.33
    Data Augmentation via Joint Variational Generation73.082.965.7
    BLSTM (A. Pre-train word emb. of ELMo)77.5485.3767.97
    BLSTM-CRF (A. Pre-train word emb. of ELMo)79.7787.3671.83
    Enc-dec focus (A. Pre-train word emb. of ELMo)78.7786.6870.85
    BLSTM (A. Pre-train word emb. of Glove & KazumaChar)78.0286.3368.55
    BLSTM-CRF (A. Pre-train word emb. of Glove & KazumaChar)79.8487.6171.90
    Enc-dec focus (A. Pre-train word emb. of Glove & KazumaChar)79.9886.8271.10
  3. Slot F1-scores of E-commerce Shopping Assistant (ECSA) from Alibaba(w/o intent, in Chinese):

    modelsslot F1-score (%)
    Basic BiLSTM-CRF43.02
    Pure BERT46.96
    Pure BERT-CRF47.75
  4. Entity F1-scores of CoNLL-2003 NER(w/o intent):

    modelsF1-score (%)
    Pure BERT91.36
    Pure BERT-CRF91.55

Inference Mode

An example here:

bash run/atis_with_pretrained_word_embeddings_for_inference_mode__an_example.sh

Reference