UKPLab / sentence-transformers

State-of-the-Art Text Embeddings
https://www.sbert.net
Apache License 2.0
14.78k stars 2.43k forks source link

Dose the sentence-bert can be used for sentiment analysis for reviews? #2547

Open gyxgyx12138 opened 5 months ago

gyxgyx12138 commented 5 months ago

Hello, I am a graduate student researching how to use deep learning models to determine the sentiment of product reviews. Can your Sentence-BERT model be used for sentiment analysis of reviews?

ir2718 commented 5 months ago

Of course you can use it for sentiment analysis. Some of the benchmarks for estimating the quality of sentence embeddings are exactly sentiment analysis datasets (CR, MR, SST). For more details about the datasets have a look here.

tomaarsen commented 5 months ago

Hello!

It can indeed, this is a major use case of embedding models. Consider also looking into SetFit, a classification framework which uses Sentence Transformers under the hood. It might simplify some things for you, as you otherwise still have to build the classifier yourself.

If you don't want to do any meaningful training, then you can take any embedding model, embed your reviews, use a Sklearn classifier (e.g. Logistic Regression), and fit it using 1) embeddings of your reviews as X and 2) your label as Y.

During inference, you must first embed your text to get an embedding, and then feed the embedding through the logistic classifier. Even without any finetuning, I suspect you can reach 80% performance or so (and probably 90-95% with finetuning).