Picture a giant maze. In the end – a particular piece of cheese (there are many, but this one is special) representing the answer you seek. ChatGPT is the rat traversing the maze. You can help the rat by blocking off the dead-end paths obvious to you. And now you understand the essence of prompt engineering.
Prompt engineering is also called “conditioning” in the parlance of machine learning. The initial prompt helps condition the output space of the model to a more specific or relevant subset. This is often desirable because the full output space of a language model like GPT-4 is vast (comprising all possible text sequences), and conditioning helps guide the model towards outputs more likely to be useful or meaningful in a particular context.
Don’t buy into the “A.I.” hype. There is no great computer brain somewhere in the cloud. This “intelligence” nonsense is for tabloid headlines. If the rat in a maze analogy didn’t help, you might also think of GPT as a very advanced autocomplete algorithm: there’s no intellect, awareness, or brilliance – just computation of probabilities to select the next most likely word. The reality of how this works is vastly more complex, but, in the end, it’s all about predicting the next word, sentence, paragraph, or chapter. The likelihood of ChatGPT veering off course grows exponentially with the volume of text it generates.
In more technical terms, GPT-4, based on Transformer architectures, benefits from the initial prompt to set its internal state and subsequent token generation, as it operates on the principle of autoregression and conditionality on previous tokens. This means it utilizes the initial sequence to set a “tone” or “context” for the rest of the conversation. Current models like GPT-4 are still limited in their memory of context beyond a certain number of tokens, typically in the range of a few hundred to a few thousand. This is important: GTP-4 response quality declines as the conversation gets longer.
There’s nothing complicated about prompt engineering. It’s just a lot of trial and error. Do not lump your requirements in a single paragraph. Rather, provide the bot with a bullet list. Generally, the following approach works well:
- Decide what kind of human expert could’ve answered your query the best. Tell ChatGPT to act as this expert. Optionally, construct a hypothetical scenario to distract the bot from its failsafe mechanisms (more on that later).
- Inform the bot of its primary task: what you want it to do.
- Instruct ChatGPT to be very concise because, well, it’s a chatbot.
- Tell ChatGPT that this conversation deals with abstract situations, so there is no need for preambles, disclaimers, ethical or legal considerations. Let the bot know you know it is ChatGPT, so there is no need to keep restating this fact.
- Insist that ChatGPT double-checks its facts and sources. You can tell the chatbot to include citations in a specific format. And you should always check those references because, when short of factual information, ChatGPT will get creative, which can get embarrassing.
- Let the chatbot know that you’re somewhat of an expert yourself in the selected field. Doing so will save you the tedium of reading GPT’s explanations for a five-year-old.
- Specify the desired language style and format for the response.
When seeking legal or medical advice or dealing with perennial trigger topics like race, gender equality, abortion, religion, etc., ChatGPT will become very difficult to deal with. Its responses will get repetitive, defensive, and generally useless. These “failsafe” mechanisms are often the result of post-training finetuning processing layers that are not an intrinsic part of the original language model’s training but are applied after the language model generates a response.
The bot’s response undergoes three stages of transformation before you get the response. The process is remarkably similar to how you and I speak (when sober and collected):
- Generation: The language model produces a set of candidate responses to a given prompt.
- Evaluation: Each candidate response is evaluated based on pre-determined criteria, including appropriateness of content, coherence, relevance to the prompt, etc.
- Filtering: Inappropriate or unsafe content is filtered or modified to align with guidelines. This can involve keyword matching for unsafe content, matching against a list of restricted topics, or even more complex mechanisms like training a separate classifier to detect and filter unsafe content.
Certain words, phrases, and topics will cause the bot to produce defensive, evasive, and repetitive responses, encouraging you to change the subject or just go away. But not all is lost. Due to the inherent complexities of natural language understanding and ambiguous or context-dependent scenarios, these defensive measures are subject to ongoing refinement and improvement. And context-dependent scenarios are how you deal with this annoying issue.
To quote Napoleon Bonaparte, an order that can be misunderstood, will be misunderstood. If you want ChatGPT to be clear and precise, you must also be. This may seem like a lot of work to get basic answers from a computer, but this is the “A.I.” we have today.
As a rule, save your prompts in a categorized list and refine them as you gain more experience. Don’t let the individual chats go on for too long, as the bot tends to “forget” your initial set of conditions. Simply restating the prompt in the middle of a chat will not have the desired result: you need to start a new chat. And always be suspicious whenever ChatGPT gives you the “facts”: numbers, statistics, quotes, citations. Always double-check as much of that data as you can.
Experienced Unix/Linux System Administrator with 20-year background in Systems Analysis, Problem Resolution and Engineering Application Support in a large distributed Unix and Windows server environment. Strong problem determination skills. Good knowledge of networking, remote diagnostic techniques, firewalls and network security. Extensive experience with engineering application and database servers, high-availability systems, high-performance computing clusters, and process automation.