Coder Social home page Coder Social logo

speak-turn-emb-dialog-act-clf's Introduction

Speaker Turn Modeling for Dialogue Act Classification

This repo implements this paper.

Installation

  1. unzip data.zip
  2. Install Pytorch and Huggingface Transformers.

Usage

To train the model on different datasets, simply run the corresponding file

python run_swda.py
python run_mrda.py
python run_dyda.py

The hyperparameters can be set in the three scripts and should be fairly understandable.

Train the model on other datasets

  1. Create a folder data/{dataset_name}
  2. Put your train/val/test data as train.csv, val.csv, and test.csv under this folder
    1. For any of the three files, each row represents an utterance, and it must have the following columns:
      1. conv_id. the id of this conversation
      2. speaker_id. the id of the speaker. the speaker id should be binary and indicates the turn of the speaker in this conversation. for dyadic conversations the original speaker ids should already be binary. in the case of multi-party conversations and speaker ids are non-binary, please refer to Section 3.3 of our paper on how to make the labels binary. if speaker ids are not available, just put all zeros.
      3. text. the text of the utterance.
      4. act. the dialogue act label.
      5. topic. the topic label. if not available, just put all zeros.
  3. Create a script as run_{dataset_name}.py. You can reuse most of the parameter settings in run_swda/mrda/dyda.py. If the conversations are very long (have a lot of utterances), consider slicing it into smaller chunks by specifying chunk_size to a non-zero value.
    1. Set copurs to your {dataset_name}.
    2. Set nclass to the number of dialogue act classes in your dataset.
  4. Run the script
python run_{dataset_name}.py
  1. In order to obtain the best performance, you may need to try different batch_size, chunk_size (32, 64, 128, 192, 256, 512 and etc.), lr (1e-4, 5e-5, 1e-5 and etc.), and nfinetune (1, 2).

Test the trained model to a new dataset

  1. Decide the pretraining dataset pre_corpus in {SWDA, MRDA, DyDA}. Choose the one that is most similar to your own datset.
  2. Train the model on the pretraining dataset using run_pre_corpus.py.
  3. Prepare your own dataset as described in Step 1 & 2 in "Train the model on other datasets". Encode the dialogue act labels of your own dataset using the mapping shown in the top comments of dataset.py. If you don't have training data and validation data, just put train.csv and val.csv as two empty dataframes, with the required columns (make two empty DataFrames using pandas and save with those column names).
  4. Make a copy of run_pre_corpus.py and change the following parameters.
    1. Set corpus to your {dataset_name}.
    2. Set mode to inference.
  5. Run the new script.
  6. The predictions of the model (a list of predicted labels) will be saved in preds_on_new.pkl.

Citation

@inproceedings{he2021speaker,
  title={Speaker Turn Modeling for Dialogue Act Classification},
  author={He, Zihao and Tavabi, Leili and Lerman, Kristina and Soleymani, Mohammad},
  booktitle={Findings of the Association for Computational Linguistics: EMNLP 2021},
  pages={2150--2157},
  year={2021}
}

speak-turn-emb-dialog-act-clf's People

Contributors

zihaohe123 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.