OpenAI sentiment analysis

I would like to create a sentiment analysis index on social media. I would like to understand how to use OpenAI existing models to enable the sentiment analysis.

Hi and welcome to the Developer Forum!

Can you explain a little more what you are trying to do?

Hi Foxabilo,
Thanks for getting back.
I want to apprehend how some international organisations are perceived on Twitter. I would like to perform a sentiment analysis by leveraging existing OpenAI models. At this stage, and before looking at the implementation, I need to understand how, in practice, people use those OpenAI models (e.g LLM) for their own purpose?
Best Regards,

You would pick your social media platform, obtain(pay) for API access to that, build a retrieval engine to pull back the specific posts and comments you are interested in for that platform using traditional code and possibly augment that with AI to decide if a post should be included and then you can run your sentiment analysis on each post, I’ll say off the bat, these things are usually non trivial to build and not cheap to run as you need one system per platform and you need to make as many API calls to the AI as there are comments.

Assuming you have the budget for that and a suitable budget for the building and maintenance (platforms are not static entities and you will have to modify interfaces over time) then you have a potentially valuable service.

If I were to hazard a guess at the size and budget required to build this then I’d say getting toward quarter to 1M side of things unless you plan on building everything yourself, but then speed and time to market comes into play.

1 Like

Thanks for your detailed response, I find it very useful. Let me digest it - could I revert back once I get off the plane (in case I have a question)?

1 Like

Sure, your post will remain open for commenting at any time.

1 Like

When it comes to sentiment analysis, you can call OpenAI’s LLM from the API as follows and classify the results into positive, neutral, and negative categories.

This classification may not always be accurate.
If you feel the results are not accurate, you can fine-tune the model to get the desired outcomes.

from openai import OpenAI
client = OpenAI()

response =
      "role": "system",
      "content": "You will be provided with a tweet, and your task is to classify its sentiment as positive, neutral, or negative."
      "role": "user",
      "content": "I loved the new Batman movie!"

This only demonstrates the basic techniques that can be applied to actual social media platforms such as Twitter. Please note that building an appropriate system to collect social media data, call APIs, and perform sentiment analysis is a separate project that needs to be undertaken.

I hope this information will be of some help to you!