Skip to content

DAMO-NLP-SG/BGCA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BGCA

This repo contains the data and code for our paper "Bidirectional Generative Framework for Cross-domain Aspect-based Sentiment Analysis" (BGCA) in ACL 2023.

Description

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.

Requirements

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

Usage

We conduct experiments on four ABSA tasks:

  1. ATE
cd code
bash ../scripts/run_ate.sh
  1. UABSA
cd code
bash ../scripts/run_uasa.sh
  1. AOPE
cd code
bash ../scripts/run_aope.sh
  1. ASTE
cd code
bash ../scripts/run_aste.sh

Code Sturcture

  • constants.py Contains constant variables
  • data_utils.py Contains code to prepare input & output for generative model
  • eval_utils.py Contains code to extract sentiment elements and calculate metric
  • main.py Contains code for the main function
  • model_utils.py Contains code for model initialization
  • preprocess.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

Note

  1. Extract model in the code refers to text-to-label stage in the paper, and Gene model refers to label-to-text stage.

Citation

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",
}

About

[ACL 2023] Code and Data for "Bidirectional Generative Framework for Cross-domain Aspect-based Sentiment Analysis"

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published