Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
LYFY7 a0b7f69097 | 2 years ago | |
---|---|---|
.. | ||
__pycache__ | 2 years ago | |
datasets | 2 years ago | |
img | 2 years ago | |
layers | 2 years ago | |
log | 2 years ago | |
models | 2 years ago | |
poster | 2 years ago | |
state_dict | 2 years ago | |
state_dict_save_bert_renew | 2 years ago | |
.DS_Store | 2 years ago | |
README.md | 2 years ago | |
data_utils.py | 2 years ago | |
dependency_graph.py | 2 years ago | |
infer_example.py | 2 years ago | |
infoNCE.py | 2 years ago | |
losses.py | 2 years ago | |
run.sh | 2 years ago | |
run_test.sh | 2 years ago | |
train_cl.py | 2 years ago | |
train_k_fold_cross_val.py | 2 years ago |
This repo contains the PyTorch code and implementation for the paper Enhancing Aspect-Based Sentiment Analysis with Supervised Contrastive Learning.
Enhancing Aspect-Based Sentiment Analysis with Supervised Contrastive Learning
Bin Liang#, Wangda Luo#, Xiang Li, Lin Gui, Min Yang, Xiaoqi Yu, and Ruifeng Xu*. Proceedings of CIKM 2020
Please cite our paper and kindly give a star for this repository if you use this code.
For any question, plaese email luowangda_hitsz@163.com or bin.liang@stu.hit.edu.cn.
you can directly use the processed dataset located in datasets/
:
Note that you need to extract the data from the datasets folder: unzip datasets.zip
├── data
│ │ ├── semeval14(res14,laptop14)
│ │ ├── semeval15(res15)
│ │ ├── semeval16(res16)
│ │ ├── MAMS
The dataSet contains with cl_2X3 is the dataSet obtained after label argment, and each data is as follows:
Context
Aspect
Aspect-sentiment-label(-1:negative;0:netrual;1:positive)
Contrastive-label(aspect-dependent/aspect-invariant)
Contrastive-aspect-label(0:negative;1:netrual;2:positive)
a) Download the pytorch version pre-trained bert-base-uncased model and vocabulary from the link provided by huggingface. Then change the value of parameter --bert_model_dir to the directory of the bert model.
you can get the pre-trained bert-base-uncased model in https://github.com/huggingface/transformers.
b) Label enhancement method. For new data, additional supervised signals need to be obtained through label enhancement;
i) Through BERT overfitting the training set, the acc can reach more than 97%;
ii) Replace aspect with other or mask, and get the emotional label of the aspect after replacing the aspect;
iii) Determine whether the output label is consistent with the real label, and fill in the aspect-dependent/aspect-invariant label for the data.
c) The data defaults are in data_utils.py, which you can view if you want to change the data entered into the model.
bash run.sh
For run.sh code:
CUDA_VISIBLE_DEVICES=3 \
python train_cl.py \
--model_name bert_spc_cl \
--dataset cl_mams_2X3 \
--num_epoch 50 \
--is_test 0 \
--type cl2X3
For dataset,you can choose these dataset : "cl_acl2014_2X3" "cl_res2014_2X3" "cl_laptop2014_2X3" "cl_res2015_2X3" "cl_res2016_2X3" "cl_mams_2X3".
bash run_test.sh
@inproceedings{10.1145/3459637.3482096,
author = {Liang, Bin and Luo, Wangda and Li, Xiang and Gui, Lin and Yang, Min and Yu, Xiaoqi and Xu, Ruifeng},
title = {Enhancing Aspect-Based Sentiment Analysis with Supervised Contrastive Learning},
year = {2021},
isbn = {9781450384469},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3459637.3482096},
doi = {10.1145/3459637.3482096},
abstract = {Most existing aspect-based sentiment analysis (ABSA) research efforts are devoted to extracting the aspect-dependent sentiment features from the sentence towards the given aspect. However, it is observed that about 60% of the testing aspects in commonly used public datasets are unknown to the training set. That is, some sentiment features carry the same polarity regardless of the aspects they are associated with (aspect-invariant sentiment), which props up the high accuracy of existing ABSA models when inevitably inferring sentiment polarities for those unknown testing aspects. Therefore, in this paper, we revisit ABSA from a novel perspective by deploying a novel supervised contrastive learning framework to leverage the correlation and difference among different sentiment polarities and between different sentiment patterns (aspect-invariant/-dependent). This allows improving the sentiment prediction for (unknown) testing aspects in the light of distinguishing the roles of valuable sentiment features. Experimental results on 5 benchmark datasets show that our proposed approach substantially outperforms state-of-the-art baselines in ABSA. We further extend existing neural network-based ABSA models with our proposed framework and achieve improved performance.},
booktitle = {Proceedings of the 30th ACM International Conference on Information & Knowledge Management},
pages = {3242–3247},
numpages = {6},
keywords = {sentiment analysis, contrastive learning, aspect sentiment analysis},
location = {Virtual Event, Queensland, Australia},
series = {CIKM '21}
}
or
@inproceedings{liang2021enhancing,
title={Enhancing Aspect-Based Sentiment Analysis with Supervised Contrastive Learning},
author={Liang, Bin and Luo, Wangda and Li, Xiang and Gui, Lin and Yang, Min and Yu, Xiaoqi and Xu, Ruifeng},
booktitle={Proceedings of the 30th ACM International Conference on Information \& Knowledge Management},
pages={3242--3247},
year={2021}
}
Open Source Sentiment Analysis Algorithm inlcuding Aspect-Based Sentiment Analysis (-ABSA) and Emotion Cause Extraction (-ECE).
Pickle Raw token data Text CSV Python other
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》