kevinscaria / InstructABSA

Instructional learning for Aspect Based Sentiment Analysis [NAACL-2024]
https://aclanthology.org/2024.naacl-short.63/
MIT License
147 stars 24 forks source link

Converting Huggingface Seq2SeqLMOutput object to (aspect, sentiment) form #3

Closed RajNS02 closed 1 year ago

RajNS02 commented 1 year ago

Hello,

Using Huggingface pre-trained transformer, I am getting the output of: 'The cab ride was amazing but the service was pricey' in the form of Seq2SeqLMOutput. I want to convert this in the form of (aspect, sentiment). I tried using the model.decode(tokenizer.decode(predicted_output.logits[0], skip_special_tokens=True), but I am getting this error: argument 'ids': 'list' object cannot be interpreted as an integer

Google Colab link where I have implemented the model: https://colab.research.google.com/drive/1gcHaM4ehqccX2zGIe8RbCeN6Q-hZh0bb?usp=sharing

Please help in this regard.

kevinscaria commented 1 year ago

Hey, If you want to extract the aspects and sentiment pairs for a given sentence, you have to use the joint task model weights. I have modified your colab notebook, I am not sure if you can see the changes, but I got the required answers in the notebook you shared.

Closing this issue now. You can open it again if the issue still persists. I will also upload a sample notebook for all three subtasks of ABSA.

Cheers!

RajNS02 commented 1 year ago

Thank you so much for your help!

Unfortunately, I am not able to see the changes. If possible, could you please share the notebook link where you made the changes? Thanks in advance.

kevinscaria commented 1 year ago

Here you go:

https://github.com/kevinscaria/InstructABSA/blob/main/inference_notebook.ipynb

RajNS02 commented 1 year ago

Thank you so much🙂