This repo contains the data and code for our paper "Bidirectional Generative Framework for Cross-domain Aspect-based Sentiment Analysis" (BGCA) in ACL 2023.
Specifically, our framework trains a generative model in both text-to-label and label-to-text directions. The former transforms each task into a unified format to learn domain-agnostic features, and the latter generates natural sentences from noisy labels for data augmentation, with which a more accurate model can be trained.
This repo is developed using the following packages:
- transformers==4.18.0
- sentencepiece==0.1.96
- pytorch_lightning==0.8.1
- editdistance==0.6.0
- scikit-learn==0.24.2
- numpy==1.22.3
- tqdm==4.64.0
We conduct experiments on four ABSA tasks:
- ATE
cd code
bash ../scripts/run_ate.sh
- UABSA
cd code
bash ../scripts/run_uasa.sh
- AOPE
cd code
bash ../scripts/run_aope.sh
- ASTE
cd code
bash ../scripts/run_aste.sh
constants.py
Contains constant variablesdata_utils.py
Contains code to prepare input & output for generative modeleval_utils.py
Contains code to extract sentiment elements and calculate metricmain.py
Contains code for the main functionmodel_utils.py
Contains code for model initializationpreprocess.py
Contains code to preprocess different task's data (ATE and UABSA share the same data)run_utils.py
Contains code for training, where data_gene() is the key method for this repo.setup.py
Contains code for setup such as args parsing
- Extract model in the code refers to text-to-label stage in the paper, and Gene model refers to label-to-text stage.
If the code is used in your research, please star our repo and cite our paper as follows:
@inproceedings{deng-etal-2023-bidirectional,
title = "Bidirectional Generative Framework for Cross-domain Aspect-based Sentiment Analysis",
author = "Deng, Yue and
Zhang, Wenxuan and
Pan, Sinno Jialin and
Bing, Lidong",
booktitle = "Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
month = jul,
year = "2023",
address = "Toronto, Canada",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2023.acl-long.686",
pages = "12272--12285",
}