Prompt Engineering is a technique to get more precise answers from generative a.i tools.
Anatomy of a prompt
- Persona – What role should the model play?
- Instruction – What should the model do?
- Input Content – Data to be processed by the model
- Format – How do you want the output to be formatted
- Additional Information – Context related to the instruction or input
Persona and Instruction would be the minimum requirements for a prompt. On designing an a.i solution, persona + instruction is defined at the beginning of the prompt session. Below are some example:
Limiting Context with Persona + Instruction
In this session, i have instructed the model to limit the response to European history that occurs during 80’s and 90’s. This approach is suitable for applications that target specific audience.
Changing model’s personality to generate unique content
William Shakespeare would be curious about this result.
Sentiment Analysis
This approach requires an instruction and the input to be analyzed. Quite useful for validating scenarios like customer feedback. the input must be separated with ###.
Text Summary
For understand long text a bit more quicker, the a.i can summarize it. Below is an example while controlling the format as well (in this case, bullet points).
Technical Parameters
For controlling the response of the model based on the need, please read Mitigating Generative A.I Hallucination.
Temperature
- The lower the result, the more deterministic the result.
- Increasing the temperature could lead to randomness.
- Lower temperature is appropriate for fact based Q&A, while higher temperature is more ideal for creative task such as generating poem or fictional stories.
Top P
- For responses that requires exact or factual answers, the value should be lower
Note: Temperature and Top P cannot be changed at the same time. generally, If your need is controlling creativity, use the temperature parameter, if you need more precise answers, use Top P.