What is Prompt Engineering?
- 🔧 Developing, designing, and optimizing prompts to enhance the output of FMs for your needs
- Simple prompts don't give enough guidance and leave a lot up to model's interpretation
- Components of enhanced prompting technique:
- Instructions: a task for the model to do (description, how the model should perform)
- Context: external information to guide the model
- Input data: the input for which you want a response
- Output Indicator: the output type or format
- Negative prompting technique: explicitly instruct the model on what not to include or do in its response
- Helps to avoid unwanted content, maintain focus, enhance clarity
- Simple prompting, enhanced prompting and negative prompting examples:
Prompt Performance Optimization
- LLMs generate text based on word probability in a sentence
- Selection is random but weighted
- Example
- Certain prompt/inference parameters can be tweaked in an LLM to change weighting, e.g. making the LLM more or less creative
- Screenshot of Prompt Configurations and Inference Parameters in Amazon Bedrock
Inference Parameters explanation
- System Prompts: how the model should behave and reply
- Temperature (0 to 1): creativity of the model’s output
- Low (ex: 0.2) → outputs more conservative, repetitive, focused on most likely response
- High (ex: 1.0) → outputs more diverse, creative, and unpredictable, maybe less coherent. Higher chance of hallucinations.
- Top P (0 to 1): top percentile of probable words to consider
- Low P (ex: 0.25) → consider the 25% most likely words, will make a more coherent response
- High P (ex: 0.99) → consider a broad range of possible words, possibly more creative and diverse output
- Top K: limits the number of probable words
- Low K (ex: 10) → only top 10 probable words considered, more coherent response
- High K (ex: 500) → top 500 probable words considered, more words, more diverse and creative response
- Length: maximum length of the answer
- Stop Sequences: tokens that signal the model to stop generating output