Improving Multi-label Malevolence Detection in Dialogues through Multi-faceted Label Correlation Enhancement
- csv
- tqdm
- numpy
- pickle
- scikit-learn
- PyTorch1.5+
- matplotlib
- pandas
- transformers=4.5.1
We use MDMDdata which is uploaded to openview.net
-
Put the dataset file in the
./pybert/dataset/data_transform/data_input/multi-label-n
-
Use
./pybert/dataset/data_transform/data_preprocessiong_n.py
to split the data, the splited data will saved in./pybert/dataset/data_transform/data_set/
-
cd pybert/dataset/data_transform
-
Run
python data_preprocessiong_n
to preprocess the data.
Bert model is part of the bert-MCRF model and is a baseline model.
you need to download pretrained bert model firstly.
BERT: bert-base-uncased
-
Download the Bert pretrained model from here
-
Download the Bert config file from here
-
Download the Bert vocab file from here
-
Rename:
bert-base-uncased-pytorch_model.bin
topytorch_model.bin
bert-base-uncased-config.json
toconfig.json
bert-base-uncased-vocab.txt
tobert_vocab.txt
-
Place
model
,config
andvocab
file into the/pybert/pretrain/bert/base-uncased
directory. -
pip install pytorch-transformers
from github. -
We use MDMDdata, which is uploaded to
openview.net
. -
Modify configuration information in
pybert/configs/basic_config.py
(the path of data,...). -
Run
python run_bert.py --do_data
to transfer the splited data to formulated data which will be save in./pybert/dataset/data_transform/data_set/
-
Run
python run_bert.py --do_train --save_best --do_lower_case
to fine tuning bert model. -
Run
run_bert.py --do_test --do_lower_case
to predict new data. -
After training the bert model, we move the the trained bert model from
./pybert/output/checkpoints/bert
topybert/model/prev_trained_model/bert-base
and continue the save the Bert-MCRF model.
Run cd pybert/model
to prepare to train the bert-MCRF model.
- Set
TASK_NAME="mcrf"
in./pybert/model/models/scripts/run_bert_MCRF.sh
- Set
--do_train
- run
bash scripts/run_bert_MCRF.sh
with 2 GPUs to train the bert-MCRF model. - Set
--predict
- run
bash scripts/run_bert_MCRF.sh
with 2 GPUs to train the bert-MCRF model.
Bert-CRF is a baseline model.
Run cd pybert/model
to prepare to train the bert-CRF model.
- Set
TASK_NAME="crf"
in./pybert/model/models/scripts/run_bert_CRF.sh
- Set
--do_train
- run
bash scripts/run_bert_CRF.sh
with 2 GPUs to train the bert-CRF model. - Set
--predict
- run
bash scripts/run_bert_CRF.sh
with 2 GPUs to train the bert-CRF model.
- Set
TASK_NAME="mcrfwolcc"
in./pybert/model/scripts/run_bert_MCRF.sh
- In
./pybert/model/models/bert_MCRF.py
change thefrom .layers.CRFKL import CRF
withfrom .layers.CRFKLwoLCC import CRF
- run
bash scripts/run_bert_MCRF.sh
with 2 GPUs to train the bert-MCRF model. - Set
--predict
- run
bash scripts/run_bert_MCRF.sh
with 2 GPUs to train the bert-MCRF model.
- Set
TASK_NAME="mcrfwolct"
in./pybert/model/scripts/run_bert_MCRF.sh
- In
./pybert/model/models/bert_MCRF.py
deleteposition_ids=position_ids
in line 78. - Use line99 and delete line101 and line 102.
- run
bash scripts/run_bert_MCRF.sh
with 2 GPUs to train the bert-MCRF model. - Set
--predict
- run
bash scripts/run_bert_MCRF.sh
with 2 GPUs to train the bert-MCRF model.
- Set
TASK_NAME="mcrfwolct"
in `./pybert/model/scripts/run_bert_MCRF.sh - Use line99 and delete line101 and line 102.
- run
bash scripts/run_bert_MCRF.sh
with 2 GPUs to train the bert-MCRF model. - Set
--predict
- run
bash scripts/run_bert_MCRF.sh
with 2 GPUs to train the bert-MCRF model.
- Set
TASK_NAME="mcrfwolct"
in./pybert/model/scripts/run_bert_MCRF.sh
- In
./pybert/model/models/bert_MCRF.py
deleteposition_ids=position_ids
in line 78. - run
bash scripts/run_bert_MCRF.sh
with 2 GPUs to train the bert-MCRF model. - Set
--predict
- run
bash scripts/run_bert_MCRF.sh
with 2 GPUs to train the bert-MCRF model.
@inproceedings{zhang2022improving, title={Improving Multi-label Malevolence Detection in Dialogues through Multi-faceted Label Correlation Enhancement}, author={Zhang, Yangjun and Ren, Pengjie and Deng, Wentao and Chen, Zhumin and Rijke, Maarten}, booktitle={Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)}, pages={3543--3555}, year={2022} }