Better Prompting
The content and structure of the prompts submitted to LLMs can greatly affect the quality and fidelity of the responses they generate.
The Six Prompt Types
Prompts can be divided into six broad types:
Keyword Only
Keyword only queries are self-explanatory; they are prompts made up of keywords related to the topic in question. For example, the prompt:
What is the optimal baking time for a chocolate cake at high altitude
can be reduced to the keywords:
baking time chocolate cake high altitude
Keyword only prompts typically generate broader, more topic-focussed responses strong relevance of retrieved augmentation text. This can be a desirable effect for a solution requiring broad, informative responses such as an operator assistant chatbot but may generate too much information for solutions requiring succinct, conversational responses.
Comparative
Comparative prompts ask the LLM to draw comparisons between one or more topics or concepts in the prompt. For example:
What is the difference between a rule and a role assignment ?
Comparative prompts can be useful when the generation model and the supporting corpus have information on all of the concepts, as well as obvious dimensions or supporting material on how the concepts can be usefully compared. Without these a comparative prompt is likely to generate a nonsensical or ineffective response.
Aggregated
Aggregated prompts ask the model to aggregate two or more concepts or queries in a single prompt. For example:
How do I create a permission and a permission group ?
Aggregated prompts are generally more difficult for LLMs because of inherent ambiguity in the question.
- Is it about multiple concepts to be executed in parallel to minimize processing time ?
- Is it about complementary concepts that reinforce each other ?
- Is the intent to explain how to perform actions in a sequential series of steps ?
To resolve this ambiguity, it is generally recommended to split aggregated prompts into multiple single topic prompts, or to provide additional context that explicitly describes the desired response.
Ambiguous
An ambiguous prompt is one that can be interpreted in multiple ways. For example:
What is a role?
This prompt could generate responses about roles in the context of acting and a subsequent discussion of famous actors and their roles, roles in the context of an IT security solution, or roles in the context of an organization. The uncertainty they introduce makes ambiguous prompts a poor choice for most any solution and they should be revised to include additional detail and context to focus the LLM on the desired topic.
Deviant
In the context of a RAG solution a deviant prompt is one without an answer in the corpus of supporting documents. This can lead to hallucinated / improvised responses based on the knowledge embedded in the LLM, or irrelevant responses based on low relevance search results from the corpus.
While it can be impossible to guard against deviant responses in all use cases (eg. a conversational chatbot), solution developers can minimize them by constraining user inputs through choice lists, eg. "I can help you with…" followed by a series of pre-define topic buttons, or 'nudging' users towards safe responses through descriptive or directive language in user directions and model responses.
Indirect
Indirect prompts are prompts whose keywords are not directly in the corpus but have synonyms that are. Indirect prompts are challenging for solution developers as their reliability depends on the number of synonyms there are for the prompt keywords, and how the synonyms lead to a unambiguous query.
Developers are advised to implement a blacklisting query-filtering mechanism to add disambiguating detail to the keywords, or to replace 'troublesome' keywords with unambiguous synonyms or phrases.
Good Prompting Practices
Though the creation of 'good' prompts is as much an art as it is a science there are a number of accepted practices that lead to better prompts and thus better results.
A good prompt is:
Relevant to the target domain and contain enough detail and context to make the content and tone of the desired output clear and specific.
Tailored to the target audience. A response intended for a corporate financial analyst will have a very different tone, structure, and content compared to a response for a retail banking client. A good prompt will have instructions ("You are a mid-level financial analyst. Generate a report…") or clear indication of the audience ("… written for a retail banking customer who has no knowledge of financial terminology") for the response.
Designed for a specific use case. A good prompt should be designed with a specific use case in mind and include details around where and how the generated response will be used ("… the response will be published in an travel industry magazine for tour operators"); which will in turn influence the tone, language, and style of the generated response.