Six AI Prompting Strategies

Digital Transformation / Tips

Six AI Prompting Strategies

Artificial intelligence requires forethought and planning to produce the desired results. Here are six strategies for tuning your models for the right output.

Write Clear Instructions

These models can’t read your mind. If outputs are too long, ask for brief replies. If outputs are too simple, ask for expert-level writing. If you dislike the format, demonstrate the format you’d like to see. The less the model has to guess what you want, the more likely you’ll get it.

Use these 6 strategies to focus AI model output:

Details, details, details
Include details in your query to get more relevant answers. The more detail you provide on the way in, the more details the model can select from to produce the output.
Personality is Relative
Ask the model to adopt a persona. Ultimately, your AI model will act in accordance with the words, phrasing, style, and mannerism you program into it. Asking your model to act in a certain manner and tone (e.g. friendly, confident, formal, appreciative, encouraging, optimistic) results in different outputs.
Set Boundaries
Use delimiters to clearly indicate distinct parts of the input. For example, an AI model trained for a dog training blog provides answers and information about the topic of dog training. If you don't want it to generate answers around the topic of dog grooming, you can prompt it with something like, "Do not answer questions or generate answers around the topic of dog grooming."
Specify the Steps
AI models are great listeners and follow your instructions. If you want your model to solve tasks, teach it the steps required to accomplish the task.
Provide Examples
Just like humans, AI systems are led by example. If you want your model to follow certain actions, you must train it to act certainly. High-quality model input results in high-quality model output.
Size Matters
To avoid the model from rambling on and hallucinating (a known issue), specify the length of the ouput. For example, if you want your model to be less "wordy" and verbose, you can train it with a prompt like, "Generate only brief responses with a maximum length of 100 words."

Provide Reference Text

Language models can confidently invent fake answers, especially when asked about esoteric topics or for citations and URLs. In the same way that a sheet of notes can help a student do better on a test, providing reference text to these models can help in answering with fewer fabrications.

Reference Text
Instruct the model to answer using a reference text. You can use websites, Word documents, PDFs, and databases as text sources to equip your model with the answers it needs.
Instruct the model to answer with citations from the reference text. AI models have near-perfect memory, giving them the ability to recall and generate output from references, formulas, and patterns within your specified data.

Split Complex Tasks

Just as it is good practice in software engineering to decompose a complex system into a set of modular components, the same is true of tasks submitted to a language model. Complex tasks tend to have higher error rates than simpler tasks. Furthermore, complex tasks can often be re-defined as a workflow of simpler tasks in which the outputs of earlier tasks are used to construct the inputs to later tasks.

Use intent classification to identify the most relevant instructions for a user query.
For dialogue applications that require very long conversations, summarize or filter previous dialogue.
Summarize long documents piecewise and construct a full summary recursively.

Give the Model Time to “Think”

If asked to multiply 17 by 28, you might not know it instantly, but can still work it out with time. Similarly, models make more reasoning errors when trying to answer right away, rather than taking time to work out an answer. Asking for a “chain of thought” before an answer can help the model reason its way toward correct answers more reliably.

Work Out the Solution
Instruct the model to work out its own solution before rushing to a conclusion
Model Reasoning
Use inner monologue or a sequence of queries to hide the model’s reasoning process
Ask the model if it missed anything on previous passes

Use External Tools

Compensate for the weaknesses of the model by feeding it the outputs of other tools. For example, a text retreival system (sometimes called RAG or retreival augmented generation) can tell the model about relevant documents. A code execution engine like OpenAI’s Code Interpreter can help the model do math and run code. If a task can be done more reliably or efficiently by a tool rather than by a language model, offload it to get the best of both.

Use embeddings-based search to implement efficient knowledge retreival
Use code execution to perform more accurate calculations or call external APIs
Give the model access to specific functions

Test Changes Systematically

Improving performance is easier if you can measure it. In some cases a modification to a prompt will achieve better performance on a few isolated examples but lead to worse overall performance on a more representative set of examples. Therefore to be sure that a change is net positive to performance it may be necessary to define a comprehensive test suite (a.k.a. an “eval”).

Evaluate model outputs with reference to gold-standard answers

PSA: Remember to relax, stay focused on your health, and have fun with IT!

Joke of the Day

Chuck Norris can dribble a bowling ball.