Unlocking environment friendly textual content classification with pre-trained fashions: a case research utilizing OpenAI’s GPT-3.5-turbo
Historically, any pure language processing textual content classification undertaking would begin with gathering situations, defining their respective labels, and coaching a classification mannequin, corresponding to a logistic regression mannequin, to categorise the situations. At the moment, the fashions out there in OpenAI will be instantly used for classification duties that may usually require gathering a considerable quantity of labeled knowledge to coach the mannequin. These pre-trained fashions can be utilized for a number of text-processing duties, together with classification, summarization, spell-checking, and key phrase identification. We don’t require any labeled knowledge or the necessity to prepare a mannequin. Easy, proper?
ChatGPT gives a graphical interface for the fashions carried out by OpenAI. Nevertheless, what if we need to run these fashions instantly in Python? Nicely, the out there different is the OpenAI API, which permits us to entry their fashions from a programming atmosphere. On this article, we’ll describe with a short instance how we are able to entry the API to detect whether or not an SMS is spam or not. To perform this, we’ll make the most of one of many Open AI fashions, particularly the GPT-3.5-turbo mannequin.
The preliminary step to entry the OpenAI API entails creating an account on OpenAI to acquire the API key required for accessing the fashions. Upon creating the account, we’ll have $5 of credit score at our disposal, which, as we’ll later observe, will permit us to conduct quite a few checks.
On this instance, we’ll make the most of the free model of OpenAI, which comes with limitations on requests per minute and per day. Adhering to those limits is essential to keep away from Charge Restrict Errors. The values for these two parameters are set at 3 requests per minute and 200 per day. Whereas this naturally imposes constraints, significantly for large-scale tasks, it suffices for the needs of this text’s instance.
As soon as we have now created the account, we are able to entry the OpenAI fashions out there for the free model from Python utilizing the OpenAI library. First, we create a operate known as chat_with_gpt to entry the GPT-3.5-turbo mannequin. The enter to this operate would be the immediate, which we’ll design afterward.