yangheng95 / PyABSA

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

How to train Quadruple Model, pretty confused. is it possible to fine tune it based on your model, how train data looks like? #301

Closed Ibrokhimsadikov closed 1 year ago

Ibrokhimsadikov commented 1 year ago

@yangheng95, first of all thank you for your amazing work.

Inspired from your work I want to train Quadruple model:

1)How input data looks like in training stage? Is this below correct? {"text": "keyboard and mouse pad seem fine , but overall it seems strangely slow .", "labels": [{"aspect": "keyboard", "opinion": "fine", "polarity": "positive", "category": "KEYBOARD#DESIGN_FEATURES"}, {"aspect": "mouse pad", "opinion": "fine", "polarity": "positive", "category": "KEYBOARD#DESIGN_FEATURES"}, {"aspect": "NULL", "opinion": "slow", "polarity": "negative", "category": "LAPTOP#GENERAL"}]}

2) How train this model in Hugging face way, as I saw couple of spaces as examples here, is it possible to fine tune them: https://huggingface.co/spaces/yangheng/PyABSA

Should I follow here to train the model: https://github.com/yangheng95/PyABSA/tree/v2/examples-v2/aspect_opinion_sentiment_category_extraction

rely on your support and guidance!

yangheng95 commented 1 year ago

This model is only tested and available for pyabsa, not for huggingface. To train your own model, you can try to annotate your own dataset and use the training script in https://github.com/yangheng95/PyABSA/tree/v2/examples-v2/aspect_opinion_sentiment_category_extraction, ie., multitask_train.py

Ibrokhimsadikov commented 1 year ago

Thank you so much @yangheng95 for prompt response.

If I want to annotate my own dataset, it should look like that:

{"text": "keyboard and mouse pad seem fine , but overall it seems strangely slow .", "labels": [{"aspect": "keyboard", "opinion": "fine", "polarity": "positive", "category": "KEYBOARD#DESIGN_FEATURES"}, {"aspect": "mouse pad", "opinion": "fine", "polarity": "positive", "category": "KEYBOARD#DESIGN_FEATURES"}, {"aspect": "NULL", "opinion": "slow", "polarity": "negative", "category": "LAPTOP#GENERAL"}]}

If not, can you please provide one example snapshot how training data should look like?

Much appreciate your support on that

yangheng95 commented 1 year ago

Thank you so much @yangheng95 for prompt response.

If I want to annotate my own dataset, it should look like that:

{"text": "keyboard and mouse pad seem fine , but overall it seems strangely slow .", "labels": [{"aspect": "keyboard", "opinion": "fine", "polarity": "positive", "category": "KEYBOARD#DESIGN_FEATURES"}, {"aspect": "mouse pad", "opinion": "fine", "polarity": "positive", "category": "KEYBOARD#DESIGN_FEATURES"}, {"aspect": "NULL", "opinion": "slow", "polarity": "negative", "category": "LAPTOP#GENERAL"}]}

If not, can you please provide one example snapshot how training data should look like?

Much appreciate your support on that

Yes

lorisdiquilio commented 1 year ago

@yangheng95 Hi, thanks a lot for your work. Can you provide also for me a snapshot of the data in order to fine-tune the Quadruple model?? I'm very interesting on that.

yangheng95 commented 1 year ago

@lorisdiquilio Please refer to: https://github.com/yangheng95/PyABSA/blob/v2/examples-v2/aspect_opinion_sentiment_category_extraction/multitask_train.py

lorisdiquilio commented 1 year ago

@yangheng95 Ok, thanks a lot. Once I trained the model with this structure mentioned: {"text": "keyboard and mouse pad seem fine , but overall it seems strangely slow .", "labels": [{"aspect": "keyboard", "opinion": "fine", "polarity": "positive", "category": "KEYBOARD#DESIGN_FEATURES"}, {"aspect": "mouse pad", "opinion": "fine", "polarity": "positive", "category": "KEYBOARD#DESIGN_FEATURES"}, {"aspect": "NULL", "opinion": "slow", "polarity": "negative", "category": "LAPTOP#GENERAL"}]}

how can i predict on the new sentences?

yangheng95 commented 1 year ago

You can refer to the example: https://github.com/yangheng95/PyABSA/blob/v2/examples-v2/aspect_opinion_sentiment_category_extraction/inference.py

Ibrokhimsadikov commented 1 year ago

I was able to train the model thanks to @yangheng95 guide! Thanks