Sentiment Analysis for Customer Service Chatbot

Hello guys, junior developer here :).

I’d like to build a customer service chatbot using a fictitious company’s proprietary data. So I’m planning to fine tune the text-davinci model with a large corpus of data which also includes previous customer support chats.

On top of this I would like to implement a feature regarding sentiment analysis: basically if the model detects negative sentiment from the user’s prompt more than two times consecutively, I would like to prompt the user to contact a human (employee working for company XYZ).

In order to implement this, do you think I would have to fine-tune another model to train it on sentiment analysis? Would I be able to use both models at the same time?
Any recommendation is more than welcome!

If you’re reading this, have a nice day and thank you for the help.

Welcome to the forum!

Couple of things, GPT-3.5-Turbo can perform sentiment analysis on most topics extremely well, so unless your sentiment is something very unique within a specialised field then there is no need to tune.

Fine-Tuning is not a method for adding data to a model, it is a way of teaching it new ways of thinking, new patterns to use, I would advise looking into the topic of embeddings for retrievals on large text corpuses. OpenAI Platform

Thank you very much for your answer! @Foxalabs

You are right, but how would I keep track/memory of the ‘judged sentiment’ within the framework?

How do I give da vinci the tasks of both answering to the chatbot question, as well as prompting user to request human operator in case of ‘negative perceived sentiment on more than 2 consecutive interactions’?

Thank you, and sorry if the way I am phrasing it is confusing.

This kind of more complex bot needs (IMHO) multiple API calls to models to perform different tasks, one call would be to GPT-3.5-Turbo to asses the sentiment of the last user input, you could define one of the new “functions” abilities to be a “moderator” and it requires as an attribute the prompts sentiment in the form of an integer from -1 to 1 where -1 represent negative sentiment and 1 positive, you could then add that return value to a moderation variable and it it reaches -2 you can handle that as you see fit.

You would then need to make another API call to asses the users question and provide a response, perhaps it could create a vector embedding retrieval prompt to search your now vectorised corpus for relevancy… all sort of possibilities open up, although as you can appreciate this becomes quite
a complex endeavour, but very doable with careful planning and execution.

1 Like