Gemini Best Practices
Follow Google's recommended best practices for prompt engineering with Gemini models to achieve optimal performance and reliability in various applications.
When to use
When developing applications using Google Gemini models and seeking to improve output quality, reduce hallucinations, or enhance response consistency.
How to apply
Start with a clear and concise prompt that directly states the desired outcome.
Provide specific instructions and constraints, such as output format or length.
Use few-shot examples to demonstrate the expected input-output pattern.
Break down complex tasks into smaller, manageable steps.
Implement safety best practices by filtering sensitive content and handling potential misuse.
Iterate on your prompts by testing and refining them based on model responses.
Glossary
- Output quality
- The degree to which the model's response is accurate, relevant, and useful for the given task.
- Hallucinations
- Instances where the model generates information that is factually incorrect or nonsensical, despite being presented as true.
- Response consistency
- The ability of the model to produce similar and reliable outputs when given similar inputs or prompts over time.
- Clear and concise prompt
- A prompt that is easy to understand, free of ambiguity, and directly communicates the user's intent.
- Specific instructions
- Detailed directions within a prompt that guide the model on how to process information or format its output.
- Few-shot examples
- Providing a small number of input-output pairs within the prompt to teach the model the desired task or style.
- Complex tasks
- Problems or requests that involve multiple steps, sub-problems, or require intricate reasoning.
- Safety best practices
- Guidelines and techniques used to prevent the model from generating harmful, biased, or inappropriate content.
- Testing and refining
- The process of evaluating model responses to prompts and making adjustments to the prompts to improve performance.
Sources
