FinABSA is a T5-Large model trained for Aspect-Based Sentiment Analysis(ABSA) tasks using
SEntFiN 1.0. Unlike traditional sentiment analysis models which predict a single sentiment label for each sentence, FinABSA has been trained to disambiguate sentences containing multiple aspects. By replacing the target aspect with a [TGT] token the model predicts the sentiment concentrating to the aspect.
GitHub Repo
You can use this model directly using the AutoModelForSeq2SeqLM class.
1>>> from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
2
3>>> tokenizer = AutoTokenizer.from_pretrained("amphora/FinABSA")
4>>> model = AutoModelForSeq2SeqLM.from_pretrained("amphora/FinABSA")
5
6>>> input_str = "[TGT] stocks dropped 42% while Samsung rallied."
7>>> input = tokenizer(input_str, return_tensors='pt')
8>>> output = model.generate(**input, max_length=20)
9>>> print(output)
10The sentiment for [TGT] in the given sentence is NEGATIVE.
11
12>>> input_str = "Tesla stocks dropped 42% while [TGT] rallied."
13>>> input = tokenizer(input_str, return_tensors='pt')
14>>> output = model.generate(**input, max_length=20)
15>>> print(output)
16The sentiment for [TGT] in the given sentence is POSITIVE.
Using a test split arbitarly extracted from
SEntFiN 1.0 the model scores an average accuracy of 87%.