The OpenAI API is a new way to access new AI models developed by OpenAI. It provides a general-purpose interface, which you could specify what you want it to do, with just a handful of examples.
Can you give me the shell command that prints the name of the folder you're currently in? Well, that's easy enough; it should be pwd. What about if you want to navigate to the /tmp folder? Simple: cd /tmp.
Now, of the top of your head, what is the command to count the number of python files in the current folder? That's a bit trickier: find . -type f -name '*.py' | wc -l. It is not hard, it can be done in other ways too, but sometimes we forget.
What if I told you that you can program a script, which you could query in natural language and get back the shell command you are looking for?
Knowing complex shell commands has a certain appeal. It could also serve as a self-esteem boost, I get that. However, what if I told you that you can program a script, which you can query in natural language and get back the shell command you are looking for? For example, imagine that you have a natural language shell (nlsh) and you want to get what day is today. It could look something like that:
The first line is the input to the shell, while the second line illustrates a possible output. That would be cool, right? Now, what if I told you that you can do that today, in under 30 lines of code, using python? In my opinion, this is revolutionary! In this story, we talk about OpenAI's API, a way of accessing new AI models developed by OpenAI. And the natural language shell is just the tip of the iceberg.
The OpenAI API is a way to access new AI models developed by OpenAI. It provides a general-purpose interface, which you could specify what you want it to do, with just a handful of examples. You can integrate it into your product, fine-tune it, and develop a brand new application or just explore its limits. The API is not open to the public yet, however, you can join the waiting list.
How does it work?
Imagine that you want to create a text completion app, like the natural language shell (someone could argue that this can also be seen as a Q&A app). First, you should "program" the API by showing it a few examples of what you'd like to do. The more the better, especially if the task is complex:
Well, that's it! There is no second step. The results might not be perfect day one, but you can hone its performance by train it on a larger data set of examples, or by learning from human feedback provided by users.
Researches at OpenAI designed the API to be flexible enough to make machine learning teams more productive. At the same time, it is so simple that anyone could use it. On the background, the API runs models with weights from the GPT-3 family, which have been improved in terms of speed and throughput to make this kind of application practical.
What is GPT-3?
GPT-3 is the evolution of GPT-2, by OpenAI, and it marks a new milestone for natural language processing. GPT stands for Generative Pretrained Transformer, referencing a 2017 Google innovation called the Transformer. Its main purpose is to figure out the likelihood that a particular word will appear in a given context. Building on this, we can now create applications that complete text, answer questions, summarize documents, and many more.
The Natural Language Shell Example
In this section, we will code the natural language shell we saw in the prologue, using python and a few lines of code. First, the python file:
At the beginning of the python script, we provide the API with a few examples of what we want it to do. Then, we create a Completion task and use the davinci model. We set max_tokens to 100 to have enough buffer and the temperature to 0. Setting the temperature to 0 is a good practice whenever we have a problem that has only one correct answer. Typically, the higher the temperature the more creative freedom the model has.
The OpenAI API is already in use by organizations that are collaborating closely with OpenAI. Let us see a few very clever examples.
AI Channels is a social network for people and artificial intelligence agents. AI Channels lets you interact with AI agents that can help you generate ideas, recommend books and movies, tell interactive stories or participate in a round table discussion with your friends and the greatest minds in history where you can ask a virtual Albert Einstein to explain relativity or get writing tips from Jane Austen.