Prompt Engineering Techniques for the Professional Machine Learning Engineer Exam

GCP Study Hub
October 5, 2026

Prompt engineering improves large language model outputs by structuring prompts with clear instructions, context, and examples. It is an accessible way to raise output quality and reliability because using it effectively does not require a data science or machine learning engineering background. On the Professional Machine Learning Engineer exam, scenarios focus on selecting the right technique for a requirement such as consistent formatting, domain-specific tone, multi-step reasoning accuracy, or external tool access.

Zero-shot, one-shot, and few-shot prompting

The first three techniques differ by how many examples appear in the prompt.

  • Zero-shot prompting asks the model to perform a task with no examples, relying entirely on pre-trained knowledge. It works well for straightforward tasks the model has likely encountered during training, such as summarization, translation, or simple questions. Asking a model to summarize a customer review works without examples because the model already understands summarization conceptually. Zero-shot prompting is fast and direct, though it does not steer the model toward a custom format or specific requirements.
  • One-shot prompting provides one example before the task request. It fits situations where you want a consistent template, style, or pattern and a single clear reference establishes it. Showing a product description for wireless headphones with a product name, detailed description, and key features, then asking for a smartwatch description, lets the model infer the layout without exhaustive written rules.
  • Few-shot prompting provides multiple examples, usually two to five, to teach a complex pattern or domain-specific language. Rewriting formal documentation into a casual brand voice with three diverse examples that vary in context, phrasing, and intent helps the model learn vocabulary and brand personality. Few-shot examples also convey edge cases and decision logic, such as showing that shipping delays alone do not make feedback negative while a completely broken product does.

Few-shot prompting carries a trade-off. Every example lengthens the prompt and adds input tokens on every call. At high request volumes, those extra tokens raise costs and slow response times, so we want enough examples to establish the pattern and no more.

Role-based prompting and prompt chaining

Role-based prompting instructs the model to adopt a persona, typically starting with "you are" followed by a defined role. That persona shapes what the model says and how it says it, guiding tone, perspective, and level of detail. Asking directly for an explanation of compound interest can yield a generic, overly technical, or intimidating answer, whereas assigning a role frames the response because a financial advisor, a teacher, and a journalist explain topics differently.

Prompt chaining breaks a complex task into sequential steps instead of asking for everything at once. The output of one prompt becomes the input or context for the next, carrying each result forward. For an eco-friendly water bottle campaign, a first prompt might generate a tagline such as "Pure hydration, zero impact." A second prompt then requests a two-sentence social media caption using that tagline, weaving the earlier output into a finished caption about staying hydrated while protecting the planet. Chaining lets you inspect and refine output at each stage during complex content creation or problem solving.

Chain-of-thought and ReAct prompting

Chain-of-thought (CoT) prompting guides the model to generate intermediate reasoning steps before stating a final answer. Consider asking how much change Maria gets after buying seven apples at $1.20 each with a $10 bill. Without CoT, the model might jump to an incorrect answer of $1.40 with no visible reasoning to catch the error. Adding an instruction to think step by step leads it to compute seven times $1.20 as $8.40, subtract from $10, and reach $1.60. Showing intermediate steps aids auditing and improves accuracy because the model is less likely to jump to a wrong conclusion when it justifies each step first.

ReAct prompting combines chain-of-thought reasoning with external actions so the model is not limited to what it already knows and can use external tools while solving a problem. The loop runs in three phases before producing a final answer:

  • Thought: the model explains its logic and why it is taking the next action.
  • Action: the model executes a task such as a web search or an API call.
  • Observation: the model processes the results returned from that tool to help produce a final answer.

Unlike most other techniques, ReAct is usually configured through the system prompt rather than the user prompt. A developer sets it up in advance, defining the available tools and instructing the model to follow a strict Thought, Action, Observation, and Final Answer format for every request. That structure keeps reasoning and tool use traceable and controllable.

Metaprompting

Metaprompting uses an AI model as a prompt engineer to create, refine, or optimize other prompts. Instead of writing detailed instructions manually, you describe your high-level goal in a metaprompt and let the model generate the detailed prompt.

For example, you might tell the model you are building a customer service bot for a shoe company and ask it to act as an expert prompt engineer to write a detailed system prompt for handling refund requests politely, checking for a 30-day return window, and offering a discount code if a customer is unhappy. The model responds with a structured system prompt defining a specialized refund assistant and its goal.

Combining techniques on the exam

All of these techniques work on the same principle: adding different levels and types of context to guide the model. Because they share that mechanism, they can be combined to give the model more context than any single technique provides alone.

Combining role-based prompting with few-shot prompting shows how each piece contributes. Setting the role "you are a history professor with decades of experience" shapes tone and expertise level. Adding "explain the start of World War II to a freshman class using short sentences and chronological order" sets the task, audience, and format. Appending few-shot examples anchors the response style.

When answering questions on the Professional Machine Learning Engineer exam, match the method to the main constraint in the scenario: example count and input token budget for zero-shot, one-shot, and few-shot prompting, persona or sequential stages for role-based prompting and chaining, intermediate reasoning or system-configured external tools for CoT and ReAct, and automated prompt generation for metaprompting.

Our Professional Machine Learning Engineer course covers prompt engineering techniques alongside generative AI model selection and evaluation, with practice questions that drill these distinctions.

Get tips and updates from GCP Study Hub

arrow