Skip to content

Instructional learning for Aspect Based Sentiment Analysis

Notifications You must be signed in to change notification settings

Mouuaadd/InstructABSA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

InstructABSA: Instruction learning for Aspect Based Sentiment Classification

PWC

PWC

PWC

This repository is the official implementation of the paper. As part of our approach we show the efficacy of instruction tuned language models. This approach surpasses previous SOTA on downstream ABSA subtasks by significant margin.

Dataset Requirements

This section describes the format of the data required for the training and evaluation of the datasets using our approach. For all subtasks, the field names should match exactly as shown and have the same datatypes. The fields to be present in the raw dataset are as follows:

-- raw_text: This is the reviews section (str)

-- aspectTerms: This is the set of aspect terms and their polarities to be present as a list of dictionaries. Each dictionary will have atleast two keys with the one of the key term and the value which is an aspect in the corresponding sentence. The second key will be polarity and its value is the polarity for corresponding aspect. ([{'term':'aspect1', 'polarity':'polarity1'}, ...])

Warning When creating the dataset in this fashion and saving it, .xlsx/.csv format will convert the aspectTerms column into string/text format. But the package will handle that when loading the dataset file.

An example dataset is shown below and also in the Datasets folder.

raw_text aspectTerms
The cab ride was amazing but the service was pricey [{'term':'cab ride', 'polarity':'positive'}, {'term':'service', 'polarity':'negative'}]
I ordered the Barbeque Pizza [{'term':'noaspectterm', 'polarity':'none'}]

Model Checkpoints

All the model weights can be found here. The best performing models fro each task based on our experiments are presented in the table below:

Task Model Name Dataset Trained Model Type Instruction Configuration
ATE kevinscaria/ate_tk-instruct-base-def-pos-neg-neut-combined SemEval 2014 Laptops + Restaurants InstructABSA-2 Definition + 2 pos + 2 neg + 2 neut examples
ATSC kevinscaria/atsc_tk-instruct-base-def-pos-combined SemEval 2014 Laptops + Restaurants InstructABSA-1 Definition + 2 pos examples
Joint Task kevinscaria/joint_tk-instruct-base-def-pos-neg-neut-combined SemEval 2014 Laptops + Restaurants InstructABSA-2 Definition + 2 pos + 2 neg + 2 neut examples

Aspect Term Extraction

The ATE models can be trained from scratch or alternatively can be used to run inference on your datasets directly. This can be done through CLI (check the Scripts folder) or by adapting your code similar to run_model.py. An example shell command to run inference on individual samples is shown below.

To evaluate the ATE subtask on a single input using CLI run the following:

python run_model.py -mode cli -task ate \
-model_checkpoint kevinscaria/ate_tk-instruct-base-def-pos-neg-neut-combined \
-test_input 'The cab ride was amazing but the service was pricey'

Aspect Term Sentiment Classification

The ATSC models can be trained from scratch or alternatively can be used to run inference on your datasets directly. This can be done through CLI (check the Scripts folder) or by adapting your code similar to run_model.py. An example shell command to run inference on individual samples is shown below.

To evaluate the ATSC subtask on a single input using CLI run the following:

python run_model.py -mode cli -task atsc -model_checkpoint kevinscaria/atsc_tk-instruct-base-def-pos-neg-neut-combined -test_input 'The ambience was amazing but the waiter was rude|ambience'

Note the | delimiter that is used to pass the aspect term for which the polarity is to be extracted.

Joint Tasks

The Joint task models can be trained from scratch or alternatively can be used to run inference on your datasets directly. This can be done through CLI (check the Scripts folder) or by adapting your code similar to run_model.py. An example shell command to run inference on individual samples is shown below.

To evaluate the Joint Task on a single input using CLI run the following:

python run_model.py -mode cli -task joint \
-model_checkpoint kevinscaria/joint_tk-instruct-base-def-pos-neg-neut-combined \
-test_input 'The cab ride was amazing but the service was pricey'

About

Instructional learning for Aspect Based Sentiment Analysis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 51.4%
  • Jupyter Notebook 46.0%
  • Shell 2.6%