What's all the Hype around Prompt Engineering About?
Mark Hinkle
I publish a network of AI newsletters for business under The Artificially Intelligent Enterprise Network and I run a B2B AI Consultancy Peripety Labs. I love dogs and Brazilian Jiu Jitsu.
Since OpenAi launched ChatGPT in November 2022, there has been a ton of fanfare around how it's going to create exponential gains in productivity. This is something I have witnessed personally. Before ChatGPT I spent a good bit of time using JasperAi to help create content. I was looking for a toolchain that I could use to improve my productivity for content marketing using AI tools.
Jasper is powered by OpenAI and gave me some early insights into how to generate content. However, soon after ChatGPT exploded and I started to come to grips with how to best communicate with Open AI using prompts. Today there is a lot of buzz about a skill called prompt engineering. Prompt engineering involves designing prompts, or starting points, for the chatbot to generate responses from. The better the prompt the better the resulting information.
Overview of OpenAI and Chat Interface
OpenAI is a research organization that focuses on advancing artificial intelligence in a safe and beneficial way. One of its most popular projects is the development of a language model called GPT (Generative Pre-trained Transformer). GPT-3, the third iteration of the model, has been widely used for a range of Natural Language Processing (NLP) tasks, including language translation, summarization, and question-answering. The chat interface works by allowing users to input a prompt or a few words as a starting point for the chatbot to generate responses.
Interacting with the Chat Interface or Prompt
To interact with the chat interface or prompt, users need to sign up for an OpenAI API key and then use a programming language such as Python to make API requests to OpenAI. Alternatively, users can use the OpenAI Playground to test out prompts without needing to write any code. This is what most of us have seen in social media and news articles.
Prompt Engineering
Prompt engineering involves creating effective prompts that provide enough context for the chatbot to generate meaningful responses. This is important because the chatbot's responses are only as good as the prompts it receives. Without good prompts, the chatbot may generate irrelevant or nonsensical responses, leading to a poor user experience. Prompt engineering is in high demand because businesses and organizations are increasingly using chatbots to automate customer service and support, and effective prompts are critical to the success of these applications.
Bad and Improved Prompt Examples
The key to getting good results from ChatGPT is to communicate with it in a way that it gets the information it needs to provide a thorough and correct result. I have seen numerous examples of the response being incorrect and even fictitious. The takeaway is always to check the facts.
So what constitutes a good or a bad prompt? A bad prompt might be something like "I want to buy a car." This prompt is too vague and does not provide enough context for the chatbot to generate a meaningful response. An improved prompt might be "I am looking for a mid-size SUV with good gas mileage and a price range of $30,000 to $40,000." This prompt provides more specific information that the chatbot can use to generate a helpful response.
Interacting with the OpenAI API
Going forward services will interact with OpenAI's API. Despite their initial pledge to serve humanity over shareholders, they are now a company that is both proprietary and appears to be for profit. Their product is a service that offers access to their latest models.
To interact with the OpenAI API using Python, you will need to install the OpenAI package using pip. Here is an example program that interacts with the OpenAI API to generate text:
领英推荐
python
Copy code
import openai import os # Set OpenAI API key openai.api_key = os.environ["OPENAI_API_KEY"] # Prompt for generating text prompt = "Hello, my name is" # Generate text using the OpenAI API response = openai.Completion.create( engine="text-davinci-002", prompt=prompt, max_tokens=50 ) # Print the generated text print(response.choices[0].text)
In this example, we first set the OpenAI API key using the openai.api_key function and passing in the key as an environment variable. Then, we define a prompt for generating text and call the openai.Completion.create function to generate text using the OpenAI API. We specify the language model to use (text-davinci-002 in this case) and the maximum number of tokens to generate (50 in this case). Finally, we print the generated text by accessing the text attribute of the first choice in the response object.
Note that this is just a simple example of how to interact with the OpenAI API using Python. There are many other functions and parameters available for generating text and working with the API, which are documented in the OpenAI API documentation. This program was actually generated by ChatGPT!
What is the Business Case for Prompt Engineering
Users of ChatGPT can expect to experience significant productivity gains in a variety of tasks. With the ability to generate human-like responses to natural language prompts, ChatGPT can be used to automate tasks that would otherwise require human intervention.
For example, customer service chatbots powered by ChatGPT can handle simple inquiries and support requests, freeing up human agents to focus on more complex issues. Additionally, ChatGPT can be used to automate content creation, such as generating social media posts, articles, and even entire books. By using ChatGPT to handle routine tasks, users can save time and increase productivity, allowing them to focus on higher-level tasks that require more creativity and critical thinking.
However, all of these use cases require users to understand the lingua franca of the AI system they are using. That's why prompt engineers or simply anyone that has good prompt engineering skills are currently in high demand.
Adding Context through Models
In NLP AI applications like ChatGPT, models are essential components that enable the system to generate responses to natural language inputs. Pre-trained language models like GPT-3 provide a powerful starting point for many applications, but there may be cases where a custom model is required to address specific use cases or domains.
For example, a customer service chatbot may require a custom model to understand and respond to specific types of inquiries related to a particular product or service. To incorporate a custom model into a ChatGPT application, developers can fine-tune an existing pre-trained model or train a new model from scratch using a dataset of labeled examples.
The use of custom models can significantly improve the accuracy and effectiveness of the ChatGPT system, making it better suited to specific use cases and domains. Ultimately, the use of models in ChatGPT and other NLP AI applications is critical to achieving high-quality, human-like interactions with users.
Summary and Resources
Prompt engineering is an important part of developing conversational AI that provides a good user experience. Effective prompts provide enough context for the chatbot to generate meaningful responses that maximize productivity. OpenAI provides a powerful language model and a chat interface for users to interact with. To learn more about prompt engineering, resources like OpenAI's documentation and blog can provide valuable information. I have added some additional resources below.
Doing Marketing to reach millions!| Integrated Marketing
1 年Your title and context is different
CEO of iUniq and inventor of "Credential Free Identity"
2 年Thank you for a simple clear explanation. Once again humans must bend to computer protocols in order to use them effectively. Just as we still use the same filing computer system hierarchy in order to manage our files as we did in the 1960's (no real change) now we must change how we use language to conform to a computer simulated NLP to use them. Computers should make our lives easier. They should adapt to our personalities (better programming), not require us bending to adapt to some synthetic NLP that the computer understands. I am reminded of how badly many companies handle a simple task such as calling in. We all have endure "...our menu options have recently changed..." only to be redirected and then disconnected after 10 or more minutes. That's not progress! Honestly, I am not sure if it is bad programming or justpoor implementation but I can't see this ending well. I am reminded of Captain Kirk who when the computer got surly, he demanded: "...Disconnect this computer NOW!" Thanks Mark Hinkle for the explanation.
Currently Enablement Specialist at SUSE. Previously Director of Solution Architects. SME for Kubernetes, Rancher, and Linux. CKA, SCA, & Licensed Realtor
2 年Prompt Engineering. Love it. A lot of have been doing it for years!!! It's good to see the likes of ChatGPT, NotionAI and others catch up to us "prompters".