Code for "Adversarial Training for Aspect-Based Sentiment Analysis with BERT".
We have used the codebase from the following paper and improved upon their results by applying adversarial training. "BERT Post-Training for Review Reading Comprehension and Aspect-based Sentiment Analysis".
Place laptop and restaurant post-trained BERTs into pt_model/laptop_pt
and pt_model/rest_pt
, respectively. The post-trained Laptop weights can be download here and restaurant here.
Execute the following command to run the model for Aspect Extraction task:
script\run_ae.bat ae laptop_pt laptop pt_ae 9
Here, laptop_pt
is the post-trained weights for laptop, laptop
is the domain, pt_ae
is the fine-tuned folder in run/
, 9
means run 9 times.
Similarly,
script\run_ae.bat ae rest_pt rest pt_ae 9
Execute the following command to evaluate the model for Aspect Extraction task:
eval\run_ae_eval.bat laptop 9
Here laptop
is the domain, 9
means run 9 predictions corresponding to 9 runs
The evaluation additionally needs Java JRE/JDK to be installed.
Open result.ipynb
and check the results.
@misc{karimi2020adversarial,
title={Adversarial Training for Aspect-Based Sentiment Analysis with BERT},
author={Akbar Karimi and Leonardo Rossi and Andrea Prati and Katharina Full},
year={2020},
eprint={2001.11316},
archivePrefix={arXiv},
primaryClass={cs.LG}
}