Home

Awesome

Bi-Encoder, Poly-Encoder, and Cross-Encoder for Response Selection Tasks

Requirements

Bert Model Setup

  1. Download BERT model from Google.

  2. Pick the model you like (I am using uncased_L-4_H-512_A-8.zip) and move it into bert_model/ then unzip it.

  3. cd bert_model/ then bash run.sh

Ubuntu Data

  1. Download and unzip the ubuntu data.

  2. Rename valid.txt to dev.txt for consistency.

DSTC 7 Data

  1. Download the data from the official competition site, specifically, download train (ubuntu_train_subtask_1.json), valid (ubuntu_dev_subtask_1.json), test (ubuntu_responses_subtask_1.tsv, ubuntu_test_subtask_1.json) split of subtask 1 and put them in the dstc7/ folder.

  2. cd dstc7/ then bash parse.sh

DSTC 7 Augmented Data (from ParlAI)

  1. This dataset setting does not work for cross encoder. For details, please refer to this issue.

  2. Download the data from ParlAI website and keep only ubuntu_train_subtask_1_augmented.json.

  3. Move ubuntu_train_subtask_1_augmented.json into dstc7_aug/ then python3 parse.py.

  4. Copy the dev.txt and test.txt file from dstc7/ into dstc7_aug/ since only training file is augmented.

  5. You can refer to the original post discussing the construction of this augmented data.

Run Experiments (on dstc7)

  1. Train a Bi-Encoder:

    python3 run.py --bert_model bert_model/ --output_dir output_dstc7/ --train_dir dstc7/ --use_pretrain --architecture bi
    
  2. Train a Poly-Encoder with 16 codes:

    python3 run.py --bert_model bert_model/ --output_dir output_dstc7/ --train_dir dstc7/ --use_pretrain --architecture poly --poly_m 16
    
  3. Train a Cross-Encoder:

    python3 run.py --bert_model bert_model/ --output_dir output_dstc7/ --train_dir dstc7/ --use_pretrain --architecture cross
    
  4. Simply change the name of directories to ubuntu and run experiments on the ubuntu dataset.

Inference

  1. Test on Bi_Encoder:

    python3 run.py --bert_model bert_model/ --output_dir output_dstc7/ --train_dir dstc7/ --use_pretrain --architecture bi --eval
    
  2. Test on Poly_Encoder with 16 codes:

    python3 run.py --bert_model bert_model/ --output_dir output_dstc7/ --train_dir dstc7/ --use_pretrain --architecture poly --poly_m 16 --eval
    
  3. Test on Cross_Encoder:

    python3 run.py --bert_model bert_model/ --output_dir output_dstc7/ --train_dir dstc7/ --use_pretrain --architecture cross --eval
    

Results

Ubuntu:

ModelR@1R@2R@5R@10MRR
Bi-Encoder0.7600.8550.9711.000.844
Poly-Encoder 160.7660.8680.9741.000.851
Poly-Encoder 640.7670.8800.9791.000.854
Poly-Encoder 3600.7540.8580.9701.000.842

DSTC 7:

ModelR@1R@2R@5R@10MRR
Bi-Encoder0.4370.5240.6440.7530.538
Poly-Encoder 160.4470.5340.6680.7600.550
Poly-Encoder 640.4380.5400.6680.7550.546
Poly-Encoder 3600.4530.5530.6650.7510.545
Cross-Encoder0.5020.5950.7120.7900.599
da + bert base0.5610.6590.7650.8580.659

Star History

Star History Chart