
Effective Prompting Techniques: Speaking Gemini's Language
Master the art of prompting. Learn the core principles of clarity, specificity, and structure to get high-quality outputs from Gemini.
Effective Prompting Techniques
Gemini is powerful, but it is a literalist. It gives you exactly what you ask for, which often isn't what you meant to ask for. Prompt Engineering is the skill of bridging that gap.
1. Be Specific (The Golden Rule)
Vague prompts get generic answers.
- Bad: "Write a poem about dogs." (Result: A generic rhyming scheme about barking).
- Good: "Write a Haiku about a Golden Retriever waiting for his owner in the rain. Focusing on the feeling of longing."
2. Use Delimiters
When you are pasting text for the model to process, separating your instructions from the data is crucial.
Use XML tags like <text> or triple quotes """.
- Prompt:
Summarize the text below. <text> [Paste 5 pages of text here] </text>
This prevents Prompt Injection (accidental or malicious instructions inside the data overriding your main instruction).
3. Order Matters
Put instructions at the beginning or the end of the prompt. Instructions buried in the middle of a massive block of text can be skipped (though less so with Gemini 1.5).
- Best Pattern:
- Role (System Instruction)
- Task Description
- Constraint (e.g., "Output JSON only")
- Input Data
4. Give the Model "Room to Think"
For complex tasks, don't ask for the answer immediately. Ask for the reasoning first.
- Zero-Shot CoT: Append "Let's think step by step."
- Why: It forces the model to generate tokens of logic before committing to a final answer.
Summary
- More detail is better.
- Structure your prompt with headers or XML tags.
- Don't assume common sense; state your constraints explicitly.
In the next lesson, we distinguish between System Prompts and User Prompts.