Photo by MontyLov on Unsplash

How To Implement GPT-3 In Your Chatbot

And Why It’s Not The Solution For All Conversational Problems…

Cobus Greyling
6 min readMay 24, 2021

--

Introduction

Since Open AI made text processing available with GPT-3, the question have been asked, is this the ultimate and only interface you need to create a Conversational AI interface, or chatbot? Why still bother with other frameworks and environments?

Yes, there are instances where GPT-3 can be used in a standalone mode. For instance; a mood-to-color chatbot, a fun sarcastic chatbot, a friend chit-chat bot etc.

Currently, GPT-3 has minimal capacity for supporting fine-tuning projects. GPT-3 is working on building a self-serve fine-tuning endpoint that will make this accessible for all users, but concrete timelines are not available.

For now, in most production and enterprise implementations, GPT-3 will play a support role…

Chatbot Architecture 101

Traditionally chatbot architecture can be divided into two parts, the Natural Language Understanding (NLU) and Dialog Management.

Traditionally chatbot architecture can be divided into four pillars

NLU is used to extract intents (verbs) and entities (nouns) from user input. The dialog part manages the bot’s responses and the dialog state.

Currently, GPT-3 cannot completely replace this structure, it is not a chatbot development framework. However, an ideal implementation of GPT-3 will be where it is used to augment and enhance an existing chatbot.

The Sentence in bold is the input, with points 1 t o 5 the output from GPT-3.

From the Open AI documentation, it is clearly stated that GPT-3 provides a general purpose interface, for text-in and text-out procedures.

Hence it is ideal to perform virtually any language text task. And in this lies their differentiator.

Most APIs are designed to perform a single language task. Such as sentiment, intent extraction, named entitles etc. Below are a few examples of how GPT-3 can support and augment a current chatbot implementation.

Practical Use-Cases For GPT-3

Grammar Correction

Correct Grammar of a sentence

There are existing grammar and spelling correcting API’s. But, often these mechanisms do not suffice. In cases where an intent and entities cannot be detected, the user utterance can be run through the Grammar correction API. As you can see from the examples above, the sentences provided are corrected to a large degree.

Text Summarization

Text summarization is a handy auxiliary tool for a few reasons... The first being for shortening user input. The other option is to shorten replies, especially where a knowledge base is queried and the response needs to be shortened to a specific length depending on the medium.

A paragraph is summarized into one sentence

Another use of text summarization is to present a user with a auto summarized dialog, with a read more option, which can then expand into the longer un-summarized version.

Keywords

Keywords can be extracted from a block of text. You can configure the environment to be conservative and select only keywords from the text. Or a higher temperature can be set to where related words or keywords are generated.

Key words generated from a Wikipedia paragraph.

This is very helpful to categorize text and create a search index. In the image above a extract on soccer was taken from Wikipedia. GPT-3 converted this quite large paragraph into six key words or themes.

Parse Unstructured Data

Create tables from long form text by specifying a structure and supplying some examples.

Here you can see the first entry is directly related to the sentence. The subsequent entries are somehow related and still relevant and applicable.

Classification

Classify items into categories via example inputs. Companies are named with categories defined. A new company can be mentioned and auto classified.

With limited training data a new company can be mentioned and auto classified.

Extract Contact Information

Extract contact information from a block of text. In this case, an address.

A complete address from the free text message.

Summarize For A Second Grader

This functionality takes a complex and relatively long piece, summarize and simplifies it into a sentence or two.

A large and complex piece of text is summarized and simplified.

Conclusion

There are definitely good implementation opportunities for the Conversational AI aspect of GPT-3.

Restaurant review is created from a few key words and the restaurant name.

As a support API where text can be processed to assist existing NLU functionality, there is a very real use case.

As mentioned, GPT-3 can be a great help in pre-processing user input as a help for the NLU engine. The challenge is that GPT-3 seems very well positioned to write reviews, compile questions and have a general conversation. This could lead to a proliferation of bots writing reviews, online adds and general copywriting tasks.

An apple pie review based on four generic words.

This automation does not need to be malicious in principle. Open AI is seemingly making every effort to ensure the responsible use of the API’s.

The fact the extensive training is not required, and a few key words or phrases can point the API in the right direction, is astounding.

There are however opensource alternatives for most of the functionality available.

Positives

  • GPT-3 has quite a bit of functionality which can serve to augment a current chatbot.
  • Dialog can be diversified with the NLG capability.
  • General chit-chat can easily be created.
  • Copywriting is made easy for slogans, headlines, reviews etc.
  • Text transformation
  • Text generation
  • Creating a general purpose bot to chat to.
  • With their underlying processing power and data, creating flexible Machine Learning stories should be a good fit.

Not-so Positives

  • The API is cloud hosted
  • Cost
  • Social media bot content generation
  • Not a framework for sustainable chatbot scaling; yet.
  • Possible over and under steering with training data.

--

--

Cobus Greyling

I explore and write about all things at the intersection of AI & language; LLMs/NLP/NLU, Chat/Voicebots, CCAI. www.cobusgreyling.com