Promoting for sentiment analysis

To use the chatgpt prompt to perform a sentiment analysis function, how to write this prompt?
prompt = f"“”
what is the sentiment of the following product review,
which is delimited with triple backticks?
Review text: ‘’‘{review}’‘’
response = get_complention(prompt)

Here is a sentiment classifier. It’s more a demo of how the AI can understand pseudocode rather than good prompting. It needs to be made simpler because of dumber AI now.

You can press the “get code” button and see how to make a call to the API chat completions endpoint at gpt-3.5-turbo or gpt-4 models.

If you are actually wanting to use ChatGPT and not the API of the example you show, you can just ask. Put the input first, three hyphens, and then your task.

I hate ducks, they crap on everything.


AI task: Classify mood, one word
1 Like

Hi Jason - although the task is obvious, I would give the model choices to draw from for more consistent responses. In your prompt, you can just add: Choose from: good, bad, neutral. (or whatever categorization you had in mind).

For this type of task, finetuned models come in really handy. Depending on the specific circumstances there may be nuances to the sentiment analysis that GPT models can’t differentiate without training.

1 Like

It seems like you might be reading the output programmatically, if that is your use case, you might want to write a function instead, that will ensure the output can be processed by your program all the time.