AI - Node - ChatGPˇ

Understanding OpenAI and ChatGPT

Introduction

AI was first mentioned as a concept in 1956 and has progressed massively since then due to increased data volumes, improved algorithms and advances in computer power and storage. Early research was focused on problem solving and symbolic approach it wasn’t until the 1960s when the US Department of Defense took an interest and taught computers to mimic basic human reasoning. Narrow AI(responsible for the working of Siri, Google Search, Image Recognition Software, etc), Machine Learning and Deep Learning are some of the different aspects of Artificial Intelligence.

OpenAI And Their Mission To Benefit Humanity

OpenAI, one of the world’s most ambitious artificial intelligence labs, is an AI research and deployment company with a mission to ensuring that artificial general intelligence benefits all of humanity. OpenAI conducts fundamental, long-term research towards the creation of safe AGI(Artificial General Intelligence). This research tend to focus on reinforcement learning and their effort has yielded the following milestone launches:

  • ChatGPT : a model which optimizes language models for dialogue. ChatGPT interacts in a conversational way and can answer followup questions, admit its mistake, challenge incorrect premises and reject inappropriate requests.
  • DALL-E : a model which enables a user to create images from text, from OpenAI. DALL-E creates images from text captions for a wide range of concepts expressible in natural language.
  • Whisper : a neural net for speech recognition. It is an automatic speech recognition(ASR) system trained on 680,000 hours of multilingual and multi-task supervised data collected from the web. A good application of this has been the usage of this model in generating Youtube subtitles for any video.
  • Codex :  a new machine learning tool that translates your text in the English language into code. Codex is designed to speed up the work of professional programmers, as well as help amateurs get started coding.
  • CLIP : a neural network for connecting text and images by OpenAI. It efficiently learns visual concepts from natural language supervision; it can be applied to any visual classification benchmark by simply providing the names of the visual categories to be recognized, similar to the “zero-shot” capabilities of GPT-2 and 3. There’s also other models launched by OpenAI such as Spam-Detecting AI, OpenAI universe and OpenAI Gym.

Using Language Models

Large language models are powerful tools for processing natural language data quickly and accurately with minimal human intervention, and can be used for a variety of tasks such as sentiment analysis, question answering systems, automatic summarization, machine translation, document classification and more.

Stanford University in their article titled ”How Large Language Models Will Transform Science, Society, and AI” reported that in July 2020, OpenAI unveiled GPT-3, a language model that was easily the largest known at the time.

What is ChatGPT?

ChatGPT (Generative Pre-trained Transformer) is a chatbot launched by OpenAI in November 2022. It is built on top of OpenAI’s GPT-3.5 family of large language models, and is fine-tuned with both supervised and reinforcement learning techniques. It is essentially a variant of OpenAI’s popular GPT-3.5 language-generation software that’s been designed to carry conversations with people.

Some of its features include answering follow-up questions, challenging incorrect premises, rejecting inappropriate queries and even admitting its mistakes, according to an OpenAI summary of the language model. This is achieved through the use of transformer architecture and pre-training on a large dataset.

OpenAI APIs

Overall, OpenAI’s models provide a valuable resource for programmers and developers looking to leverage the power of AI in their work.

OpenAI offers a range of APIs that can be used to access the capabilities of their machine learning models from within your own applications. OpenAI released one of such APIs that allows researchers and developers to build advanced GPT 3 machine learning models with few lines of code based on the paper “Language Models are Few-Shot Learners”.

These APIs are easy to use and support a variety of programming languages, including JavaScript. In order to use these APIs, you’ll need to obtain an API key from OpenAI.

You can sign up for a free API key here

In this article, we are going to be using that API to start interacting with the state-of-the-art GPT3 model and build a pet name generator.

Let’s get started…

Step 1 - Setting Up Your OpenAI Profile

  • To start using OpenAI APIs, create an account here

Sign Up Page For OpenAI

  • Get a free API key here

Get free API key

Step 2 - Installing OpenAI

  • You will be interacting with the API through HTTP requests via the official Node.js library.
  • To install the official Node.js library, run the following command in your Node.js project directory:
	bash
		
  
npm install openai

Step 3 - Selecting Your Model & Building

OpenAI GPT-3 models can understand and generate natural language. They offer four main models with different levels of power suitable for different tasks, with Davinci being the most capable, and Ada being the fastest. You can read more about the models here

  • Select your model type  Select Model Type

  • You will also be using the OpenAI completion API and below are the list of parameters to understand. More details on the parameters can be found here

Parameter Details

  • Clone the code repository
	bash
		
  
git clone https://github.com/openai/openai-quickstart-node.git
  • Navigate into the project directory and copy the example environment variables file.
	bash
		
  
cd openai-quickstart-nodecp .env.example .env
  • Copy your secret API key created in Step 1 above and set it as the OPENAI_API_KEY in your newly created .env

NB: Make all your API calls on the server-side only when using JS, since making calls in client-side browser code will expose your API key.

  • Navigate back to project folder and run the following commands to install dependencies and run the app.
	bash
		
  
npm install
npm run dev

pet name generator landing page

Conclusion

In a year that’s turned into a dud for the technology sector, with mass layoffs, wrecked stock prices and crypto catastrophes dominating the headlines, ChatGPT has served as a reminder that innovation is still happening. It has got the world in a frenzy since it was first made available to the public as users are amazed by its potential to provide human-quality responses, with a lot of users sharing the sentiment that it may eventually have the power to disrupt how humans interact with computers and change how information is retrieved.

The program has its limitations, including a knowledge base that ends in 2021, a tendency to produce incorrect answers, constantly using the same phrases and when given one version of a question, the bot claims it cannot answer it, but when given a slightly tweaked version, it answers it just fine.

Connect with me on Twitter if you have any questions.