yangheng95 / PyABSA

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

Question about inference #47

Closed leohsuofnthu closed 2 years ago

leohsuofnthu commented 2 years ago

Hi, thanks for the nice work. Recently I try to use the multilingual pretrained model for inference. I found that if the model predicts both of 2 consecutive words as (B-ASP). There will be a 'empty separator' error while inferencing. Is there any advice for avoiding this situation? Thanks again !

image image

yangheng95 commented 2 years ago

Thank you for your feedback! We will fix it as soon as possible.

FYI, the provided checkpoints are for research only and not trained with sufficient resources. Fit the model on your datasets will bring performance improvement.

yangheng95 commented 2 years ago

Hi, thanks for the nice work. Recently I try to use the multilingual pretrained model for inference. I found that if the model predicts both of 2 consecutive words as (B-ASP). There will be a 'empty separator' error while inferencing. Is there any advice for avoiding this situation? Thanks again !

image image

I review the code, as a temp solution, please alter this if-clasuse https://github.com/yangheng95/PyABSA/blob/41a067aec58b067058c1998eba33b2d9908f4989/pyabsa/tasks/atepc/prediction/aspect_extractor.py#L233 into

if 'B-ASP' == pred_iobs[iob_idx] and 'B-ASP' in pred_iobs[iob_idx + 1] \
   or 'B-ASP' == pred_iobs[iob_idx] and 'ASP' not in pred_iobs[iob_idx + 1] \
   or 'I-ASP' == pred_iobs[iob_idx] and 'ASP' not in pred_iobs[iob_idx + 1]:

I will be appreciated if you told me the feasibility of this solution. If it works OK, I will merge into the package, many thanks!

leohsuofnthu commented 2 years ago

Hi, Thanks for the quick response. I bump into another situation as below. Hope this helpful for you. image

yangheng95 commented 2 years ago

Hi, thanks for your message. However the information from this screen is limited. Can you show me the whole error stacktrace and the example text?

yangheng95 commented 2 years ago

Hi, Thanks for the quick response. I bump into another situation as below. Hope this helpful for you. image

Hi, Using following if-caulse is more clear and may solve this preoblem. if 'B-ASP' == pred_iobs[iob_idx] and 'B-ASP' == pred_iobs[iob_idx + 1] \ or 'I-ASP' == pred_iobs[iob_idx] and 'B-ASP' == pred_iobs[iob_idx + 1]:

leohsuofnthu commented 2 years ago

Hi, Thanks, the code works, the new problem is that it ll combine distinct aspects as below: image

yangheng95 commented 2 years ago

Sorry for the buggy repair, I should release the repaire after full test of the code given a cuda device and enough cases. I will check and update again.

Since I cannot run full test then, I suggest you to change the if-clause again, as following:

    if pred_iobs[iob_idx].endswith('ASP') and not pred_iobs[iob_idx + 1].endswith('ASP'):
leohsuofnthu commented 2 years ago

No worry, it is great to help with this useful repository !

yangheng95 commented 2 years ago

I will be appreciated if you futher collect the bad cases and pass them to me

leohsuofnthu commented 2 years ago

No problem, Here is the error for the newest modification image

yangheng95 commented 2 years ago

No problem, Here is the error for the newest modification image

I mean could you paste the example texts to me to reproduce your errors?

leohsuofnthu commented 2 years ago

Here is the text:

'I am extremely disappointed and frustrated with the Granite Club programming since you seem to think the only preschoolers or parents that would be interested in participating are those who are stay at home parents or have at home help to bring children to weekday programming.'

and the model: model_path = ATEPCTrainedModelManager.get_checkpoint(checkpoint_name='english')

yangheng95 commented 2 years ago

if pred_iobs[iob_idx].endswith('ASP') and not pred_iobs[iob_idx + 1].endswith('I-ASP'):

yangheng95 commented 2 years ago

I test this example, however, I develop this package based on several cases and dont have enough example texts. If any error occurs please let me know, many thanks!

leohsuofnthu commented 2 years ago

Thank you ! I end up inferencing with version 0.8.7.9, and it works well for now :)

yangheng95 commented 2 years ago

Thank you ! I end up inferencing with version 0.8.7.9, and it works well for now :)

I will close this issue, but feel free to contact me if you have more advice or report.