paint-brush
Dive Into OpenAI's AI-Powered Application Ideas for Your Next Projectby@aspper
807 reads
807 reads

Dive Into OpenAI's AI-Powered Application Ideas for Your Next Project

by Amit PrafullaMarch 30th, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Explore 50+ machine learning ideas to be used in your next project or you can think of adding a module in one of your existing projects which are powered by AI
featured image - Dive Into OpenAI's AI-Powered Application Ideas for Your Next Project
Amit Prafulla HackerNoon profile picture

Artificial intelligence is taking the world by storm. People are amazed seeing the stuff it can do. With AI becoming more and more relevant in the world we live in, why not explore this and try to implement it in your own projects?


The OpenAI API

In this post, I’d be discussing about the API OpenAI (the organization behind ChatGPT) has created for developers to experiment with.


Start by registering on their website at https://platform.openai.com/ and get your API key. Explore the example page they have and you’d find 50+ cool ideas to try for your next AI-powered application.


Here are my favourites from the list they have which I explored:


  • Language conversion from English to Spanish
  • Keyword extractor from paragraphs of text
  • Item classifier based on categories
  • Grammar correction
  • Movie to emojis
  • Ad from the product description
  • Tweet classifier
  • Javascript to Python
  • Questions and Answers
  • Explain code
  • Interview Questions


They have a quick start guide where they illustrate how to build a ‘pet name generator‘ in Node JS here - https://platform.openai.com/docs/quickstart/closing.


I actually used this ‘Interview Questions‘ model they had on the examples page. This would generate a list of questions for you based on the topic you provide in the text box. For instance, if you type something like “15 Most popular interview questions in Python“, it would reply back with 15 most popular interview questions in Python, exactly what you asked it for. You can try playing around with this here - https://platform.openai.com/playground/p/default-interview-questions?model=text-davinci-003


As of now, they have examples in Python and Javascript. They have packages available which you can use for testing.


My App Experiment

Mine was a simple app using React with just a payload being passed to the API in JSON format. Below is the excerpt I took from the application I built. This contains the payload I passed to the openAI end-point.


const jsonData = {
    "model": "text-davinci-003",
    "prompt": "Python interview questions",
    "temperature": 0.5,
    "max_tokens": 150,
    "top_p": 1.0,
    "frequency_penalty": 0.0,
    "presence_penalty": 0.0
}


The ‘Model‘ key specifies which model to be used from the OpenAI API. “Prompt“ is the input sequence you pass into the model. The model then breaks down this sequence into granular pieces called ‘tokens‘ which are fed into the model to process.


‘Temperature‘ parameter in Layman's terms simply means it controls the degree of randomness and creativity of the response generated by the model. A high-temperature value triggers more unpredictable outcomes from the model while a low value injects more confidence the model has in the most probable generated outcomes.


‘Top_P‘ parameter is used for sampling the model outcomes based on cumulative probability distribution. For instance, a top_p of 0.3 means that only the tokens comprising the top 30% probability mass are considered.


‘Frequency Penalty‘ limits the text from occurring further in the response based on the frequency of its presence till now in the response text.


‘Presence Penalty‘ has a similar purpose to ‘frequency penalty‘ except that it does not take the frequency of words into account while diminishing the relevance of keywords generated in the response text.


This was just a basic explanation of the options you pass in the payload. To get more comfortable with it, the best way inevitably would be to just play around with the options and see the difference in the produced response. It definitely helps if you know statistics and machine learning concepts. This post was more targeted towards people coming from other domains willing to explore the AI API provided by openAI. Here’s the link for the project I implemented in Vue JS using this API for the folks who are interested:- https://github.com/Apfirebolt/ask-interview-questions-ai-in-vue


This brings this post to the conclusion 😀. If you like this post, please consider a reaction in form of a like or comment. Until then, see you in the next post 👋


The lead image for this article was generated by HackerNoon's AI Image Generator via the prompt "artificial intelligence".