hcd.ai
AI in Practice

Prompt Engineering whitepaper from Google

The best freely available prompt engineering guide is Google's "Prompt Engineering" whitepaper by Lee Boonstra, published through Kaggle. It covers the core techniques that actually work (few-shot, chain-of-thought, ReAct, and more) with clear examples across Gemini and other models, and I've broken down its key insights here.

Source: Lee Boonstra

Download the whitepaper here:
https://www.kaggle.com/whitepaper-prompt-engineering

Prompt summaries

Prompt summaries below from the whitepaper created with AI. These techniques are especially relevant when working with AI agents, where ReAct prompting enables autonomous reasoning and action.

1. General Prompting / Zero shot

  • When to use: Quick requests without needing examples or much structure.
  • Why use: Fast setup, immediate results without extra input.
  • Example: "Summarise the following news article: [Article]."

2. One-Shot & Few-Shot Prompting

  • When to use: Need specific output formats or patterns.
  • Why use: Improves output structure & accuracy by providing concrete examples.
  • Example: "Here are examples of reviews and sentiment: 'Great product!' -> Positive. 'Waste of money' -> Negative. Now, classify the sentiment of this review: '[Insert Review Text]'."

3. System Prompting

  • When to use: Defining overarching context or goal clearly.
  • Why use: Provides global instructions for complex or domain-specific chats.
  • Example: "You are a customer service representative focused on refunds. Answer the following question: [Insert Customer Query]."

4. Role Prompting

  • When to use: When a response style or persona is needed.
  • Why use: Ensures responses fit the tone and knowledge expected of a specific role.
  • Example: "As an experienced software engineer, provide career advice for someone looking to advance in their career in [Field]."

5. Contextual Prompting

  • When to use: Additional background information is necessary.
  • Why use: Enhances response accuracy with relevant background context.
  • Example: "Given the background information about [Event], provide an analysis of its potential impact. Background: [Insert Background Details]."

6. Step-Back Prompting

  • When to use: Tasks that benefit from a broader perspective first.
  • Why use: Promotes broadened reasoning to apply core principles first.
  • Example: "Before solving the error '[Insert Error Description]', consider the general steps for debugging issues in [Context]."

7. Chain of Thought (CoT) Prompting

  • When to use: Tasks requiring detailed reasoning or decision-making.
  • Why use: Breaks down complex tasks into simpler, logical steps for clarity.
  • Example: "Solve the math problem step by step: 'If John has 3 apples and gets 4 more, how many apples does he have now?'. Let's think through the solution."

8. Self-Consistency

  • When to use: Need for reliable answers in ambiguous contexts.
  • Why use: Enhances reliability through agreement across diverse reasoning paths.
  • Example: "Assess the consistency of this interpretation: 'In the contract, what does the term [Term] mean? Let's consider different perspectives before concluding.'"

9. Tree of Thoughts (ToT)

  • When to use: Problems that can be approached by exploring multiple solutions.
  • Why use: Explores multiple reasoning paths to find the most comprehensive solution.
  • Example: "Explore multiple strategies for reaching [Goal]. Consider each possibility and develop a plan: 'How can we improve our customer satisfaction score?'."

10. ReAct (Reason & Act) Prompting

  • When to use: Tasks requiring execution of external actions.
  • Why use: Integrates with external systems for execution beyond text generation.
  • Example: "Determine the next available meeting slot using the calendar API for [Person/Team]. Follow these instructions and report the result."

11. Automatic Prompt Engineering

  • When to use: Automate prompt generation for iterative task refinement.
  • Why use: Enhances efficiency and creativity by through diverse prompt variations.
  • Example: "Generate 10 different ways to express: 'One Metallica t-shirt size S' for a chatbot training dataset."

12. Code Engineering

  • When to use: Generating, explaining, or translating code in different languages.
  • Why use: Accelerates coding tasks.
  • Example: "Write a Python script to rename all files in a directory by adding 'draft_' as a prefix. Here is the task detail: [Insert Task Details]."

Frequently Asked Questions

What is prompt engineering?

Prompt engineering is the practice of designing and refining inputs to large language models (LLMs) to get more accurate, relevant, and useful outputs. It includes techniques like zero-shot prompting, few-shot prompting, chain-of-thought reasoning, and ReAct prompting, each suited to different task types and complexity levels.

What is the difference between zero-shot and few-shot prompting?

Zero-shot prompting gives the model a task with no examples, relying entirely on its training. Few-shot prompting provides one or more examples of the desired input-output pattern before the actual task, which improves output structure and accuracy for tasks requiring specific formats.

When should I use chain-of-thought prompting?

Chain-of-thought (CoT) prompting is best for tasks requiring detailed reasoning, multi-step problem-solving, or decision-making. By asking the model to think step by step, it breaks complex tasks into simpler logical steps, improving clarity and reducing errors in the final output.

What is ReAct prompting and how does it work?

ReAct (Reason and Act) prompting combines reasoning with action execution. The model reasons about a task, takes an action such as calling an external API or tool, observes the result, then continues reasoning. It is used for tasks that require interaction with external systems beyond text generation.

How many prompt engineering techniques are covered in Google's whitepaper?

Google's prompt engineering whitepaper by Lee Boonstra covers 12 techniques: general/zero-shot prompting, one-shot and few-shot prompting, system prompting, role prompting, contextual prompting, step-back prompting, chain-of-thought, self-consistency, tree of thoughts, ReAct, automatic prompt engineering, and code engineering.