Large Language Model prompt
Providing information to an LLM and requesting an action
What is a prompt
Prompt is a piece of text and your way of communication with LLMs, to provide information and request an action. We know this communication is done in natural language form but we also know that not all communications reach the same success level.
Even though LLMs are improving beyond what we imagined less than a year ago, there are still shortcomings to their capacities. One critical factor for successful use of LLM is a good prompt. On this page, we summarize tips on how to form a good prompts. Links to sample prompts on Relevance are provided for each tip.
Tips on writing a good prompt (prompt engineering)
-
If the LLM needs information for doing a task, provide the information at the top. Use keywords such as “Context” to specify what the information represents (see a sample)
-
Keep the instruction short and precise. Specify what exactly needs to be done in the bare minimum required number of words (see a sample)
-
Note what you expect instead of noting what you don’t want For instance, instead of
avoid uninformative output
useanswer should be informative & useful
(see a sample) -
Include formatting instruction when necessary In many cases, we might need the output to follow a certain format or structure. This can be clearly stated in the prompt (see a sample)
-
Specify the scope using
"
,"""
or similar identifiers In many cases, we need to provide a large piece of text as the input data within the prompt. To avoid mixing the data and instruction (i.e. identifying the data scope), it is recommended to use characters such as"
,"""
at the beginning and end of the text or the corresponding date variable (see a sample) -
Explicitly note constraints and goals In more complicated prompts there are various information that can be categorize in sections. Two of the common categories are Constraints and Goals. Note them explicitly and it is recommended to mention goals after the constraints (see a sample)
-
For large prompts, note the goals and important instructions closes possible to the end of the prompt This is mostly valid for large prompts (see a sample)
-
Stick to one term when referring to the same concept throughout the prompt. LLMs tend to get confused when the prompt is long and wordy. The best way to avoid such a confusion is to use the exact same words and spelling when referring to the same concepts (see a sample)
-
Including examples specific to your data context can enhance performance. LLMs are good at imitation. So, do not hesitate when it comes to providing a few samples of how you expect the task to be done (see a sample)
Was this page helpful?