A prompt is a text you feed to the model and prompt engineering is the way of articulating your prompts to get the best response from the model.
Types of Prompts
- Zero-shot prompt — Does not contain any context or examples to assist the model.
- One-shot prompt — Provides one example to the model for context.
- Few-shot prompt — Provides at least two examples to the model for context.
- Role prompt — Provides a frame of reference for the model to work from as it answers questions.
Elements of a Prompt
- Preamble — The introductory text you provide to give the model context and instructions before your main question or request. Think of it as setting the stage for the LLM. It can include the context for the task, the task itself, and examples to guide the model.
- Input — The central request you're making to the LLM. It's what the instruction or task will act upon.
Best Practices
-
Write detailed and explicit instructions
-
Define boundaries for the prompt
-
Adopt a persona for your input
-
Keep each sentence concise
Summary
Prompting is the process of providing specific instructions to a Gen AI tool to receive new information or to achieve a desired outcome on a task. Models are multimodal — they work with text, images, sound, video, and code.
5-Step Framework
Remember it as: Thoughtfully Create Really Excellent Inputs
- Task — What you want the AI to do. Include persona ("Act as an expert") and format ("Organize in a table").
- Context — The more context, the better the output. ("Turning 26 years old")
- References — Provide examples.
- Evaluate — Check if the result is what you wanted.
- Iterate — Keep refining.
Iteration Methods
- Revisit the prompting framework
- Separate prompts into shorter sentences
- Try different phrasing or switch to an analogous task
- Introduce constraints
Hallucinations and biases are common problems. Always be responsible and evaluate your results.
Components of a Prompt
- Task (required)
- System instructions (optional)
- Few-shot examples (optional)
- Contextual information (optional)