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)
print(response)

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.