yangheng95 / PyABSA

Sentiment Analysis, Text Classification, Text Augmentation, Text Adversarial defense, etc.;
https://pyabsa.readthedocs.io
MIT License
902 stars 153 forks source link

ASTE giving triplets with duplicated opinions and polarities #327

Open BKleinman opened 1 year ago

BKleinman commented 1 year ago

PyABSA Version (Required)

PyABSA 2.3.1 Torch 2.0.1+cu117 Transformers 4.30.2

Code To Reproduce (Required)

from pyabsa import AspectSentimentTripletExtraction as ASTE

triplet_extractor = ASTE.AspectSentimentTripletExtractor("multilingual")

triplet_extractor = ASTE.AspectSentimentTripletExtractor("multilingual")

textList = [] import csv with open("C:\Users\userName\Desktop\Row64Stuff\Data\Data.csv") as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') for row in csv_reader: textList.append(row)

results = [] for text in textList: result = triplet_extractor.predict(text) if result != []: results.append(result[-1]) else: pass

Full Console Output (Required)

Example of one output: 'sentence': 'The ranked system of this game is actually such a freaking abysmal joke, from the mmr system, lack of transparency, trolls, duoq abusers, destructive lp gains, and matchmaking algorithm.', 'Triplets': [ {'Aspect': 'ranked system', 'Opinion': 'abysmal joke,', 'Polarity': 'Negative'}, {'Aspect': 'ranked system', 'Opinion': 'lack of transparency,', 'Polarity': 'Negative'}, {'Aspect': 'ranked system', 'Opinion': 'destructive', 'Polarity': 'Negative'}, {'Aspect': 'mmr system,', 'Opinion': 'abysmal joke,', 'Polarity': 'Negative'}, {'Aspect': 'mmr system,', 'Opinion': 'lack of transparency,', 'Polarity': 'Negative'}, {'Aspect': 'mmr system,', 'Opinion': 'destructive', 'Polarity': 'Negative'}, {'Aspect': 'lp gains,', 'Opinion': 'abysmal joke,', 'Polarity': 'Negative'}, {'Aspect': 'lp gains,', 'Opinion': 'lack of transparency,', 'Polarity': 'Negative'}, {'Aspect': 'lp gains,', 'Opinion': 'destructive', 'Polarity': 'Negative'}, {'Aspect': 'matchmaking algorithm.', 'Opinion': 'abysmal joke,', 'Polarity': 'Negative'}, {'Aspect': 'matchmaking algorithm.', 'Opinion': 'lack of transparency,', 'Polarity': 'Negative'}, {'Aspect': 'matchmaking algorithm.', 'Opinion': 'destructive', 'Polarity': 'Negative'}

Describe the bug

When the model predicts the outputs for each sentence I feed into the model - it produces each detected aspect with every opinion and polarity detected even if those opinions and polarities are not relevant to the specific aspect.

Expected behavior

I was hoping for each opinion and polarity to be attached to the relevant aspect as opposed to every aspect detected by the model.

yangheng95 commented 1 year ago

Probably this is a performance problem of the original model which I adapt from (according to the license). So, maybe you can contact the author to solve this problem. I will be happy to keep this model up-to-date with https://github.com/CCChenhao997/EMCGCN-ASTE

BKleinman commented 11 months ago

It seems that it is functioning correctly on the hugging face website (https://huggingface.co/spaces/yangheng/Multilingual-Aspect-Based-Sentiment-Analysis). Is there any difference between that model and this one?