## **Prompt Engineering, Google, 2025**
![[Google_Prompt Engineering.pdf]]
"Google Prompt Engineering" by Lee Boonstra is an in-depth whitepaper that explores techniques, configurations, and best practices for designing effective prompts to guide large language models (LLMs), specifically within Google's Vertex AI ecosystem using the Gemini model.
It aims to empower both technical and non-technical users to write prompts that yield accurate, relevant, and structured outputs. It presents a comprehensive methodology that emphasizes iterative experimentation, thoughtful configuration of model parameters, and structured prompt design to solve diverse tasks in natural language processing, code generation, reasoning, and more.
**Key Insights**
- **Prompt Engineering as Iterative Design**: Prompting is a non-linear, experimental process where clarity, context, structure, and examples are essential to guide LLMs effectively.
- **Model Configuration Matters**: Critical parameters such as output length, temperature, top-K, and top-P sampling control the randomness and creativity of the output. These should be tuned based on task specificity—deterministic outputs (e.g., math problems) require lower temperature, while creative tasks benefit from higher temperature.
- **Prompting Techniques**:
- **Zero-shot**, **one-shot**, and **few-shot** prompting vary in complexity, with examples enhancing model performance.
- **System prompting** sets overarching rules; **contextual prompting** adds task-specific data; **role prompting** defines personas for more tailored responses.
- Advanced strategies include:
- **Step-back prompting** to stimulate background reasoning.
- **Chain of Thought (CoT)** for stepwise logical reasoning.
- **Self-consistency** to enhance accuracy through sampling and majority voting.
- **Tree of Thoughts (ToT)** for branching reasoning.
- **ReAct** to integrate reasoning with external actions like API calls.
- **Code Prompting Use-Cases**: Includes writing, translating, explaining, and debugging code in Bash and Python, showcasing LLMs’ capabilities as developers’ assistants.
- **Automatic Prompt Engineering (APE)**: Automates prompt generation by leveraging LLMs to produce and refine prompts for tasks like chatbot training.
- **Best Practices**:
- Provide relevant, clear examples.
- Use specific instructions instead of negative constraints.
- Maintain prompt clarity, brevity, and focus.
- Use variables and structured formats (e.g., JSON) to increase reusability and consistency.
- Document every prompt iteration systematically, including model parameters and results.
**Actionable Takeaways**
- **Tune for Task**: Adjust temperature, top-K, and top-P based on whether the task is creative or deterministic. Default starting points are provided (e.g., temp 0.2/top-P 0.95 for balance).
- **Prompt Type Selection**:
- Use **few-shot prompting** with diverse examples for complex classification tasks.
- Apply **CoT** with temperature set to 0 for reasoning-heavy tasks.
- Implement **ReAct** for multi-step reasoning and tool use, such as querying search engines.
- **Adopt Schema-Based Structuring**:
- Use JSON for outputs to reduce hallucinations and increase clarity.
- Employ schemas for structured input to guide model interpretation.
- **Iterate & Document**: Track prompt performance in a structured template. Include prompt versions, outcomes, feedback, and hyperparameter settings for future refinements.
- **Collaborate and Evaluate**: Work with other prompt engineers, compare variations, and use metrics like BLEU or ROUGE for automatic evaluations.
**Notable Quotes**
- *“Prompt engineering is an iterative process.”*
- *“The clearer your prompt text, the better it is for the LLM to predict the next likely text.”*
- *“Instructions directly communicate the desired outcome, whereas constraints might leave the model guessing.”*
- *“With more freedom... the LLM might generate text that is less relevant.”*