Home

Awesome

SST-2-sentiment-analysis

Use BiLSTM_attention, BERT, RoBERTa, XLNet and ALBERT models to classify the SST-2 data set based on pytorch.

These codes are recommended to run in Google Colab, where you may use free GPU resources.

1. Experiment results of BiLSTM_attention models on test set:

The BiLSTM_attention model can let us know which words in a sentence do contributions to the sentiment of this sentence. The code is avalibale in "bilstm_attention.ipynb", where two types of self-attention mechanism have been achieved. You can run it in Google Colab for practice. The visualization result is shown below:

<img src="https://github.com/YJiangcm/Movielens1M-Movie-Recommendation-System/blob/main/pictures/attention%E5%8F%AF%E8%A7%86%E5%8C%962.PNG" width="800" height="300">

2. Experiment results of BERT models on test set:

For specific BERT models, you can find them from https://huggingface.co/models and then do modify in "models.py".

2.1 base model

ModelAccuracyPrecisionRecallF1
BERT (base-uncased)91.891.891.891.8
RoBERTa (base-uncased)93.493.593.493.3
XLNet (base-uncased)92.592.592.592.5
ALBERT (base-v2-uncased)91.491.491.491.4

2.2 large model

ModelAccuracyPrecisionRecallF1
BERT (large-uncased)93.193.293.193.1
RoBERTa (large-uncased)94.995.095.094.9
XLNet (large-uncased)94.694.794.694.6
ALBERT (large-v2-uncased)92.292.392.292.2
ALBERT (xlarge-v2-uncased)93.893.893.993.8
ALBERT (xxlarge-v2-uncased)95.995.995.995.9

2.3 base model + text attack

ModelAccuracyPrecisionRecallF1
BERT (base-uncased) + textattack92.492.892.492.4
RoBERTa (base-uncased) + textattack94.394.394.394.3
XLNet (base-uncased) + textattack93.793.893.793.7
ALBERT (base-uncased) + textattack92.092.092.092.0

LICENSE

Please refer to MIT License Copyright (c) 2020 YJiangcm