Lesson 2 of 4 Prompt Engineering for FMs

Applying Advanced Prompting Techniques

This lesson covers techniques that reliably improve FM performance on complex tasks: structured inputs, examples and reasoning instructions.

Learning outcomes

After completing this lesson, you will be able to:

  • Structure inputs with delimiters.
  • Choose between zero-shot and few-shot prompting.
  • Apply chain-of-thought and reasoning instructions.

Structured input components

Long prompts mix instructions, context documents, examples and the user's question. Delimiters such as XML-style tags (<documents>, <question>) or clearly labelled sections tell the model which part is which, so it does not treat document text as instructions. Placing long documents before the question, and key instructions at the start with a short reminder at the end, helps models attend to them in long contexts. Referring to the tags in instructions ("Answer using only the content of <documents>") makes the structure explicit.

True or false

Delimiting the prompt

Exam skills 1.6.5 · 3.1.5

Check three claims about structuring long prompts.

Log in to try this activity Interactive activities are free with an account.

Zero-shot, few-shot and examples

Zero-shot prompting gives the model instructions only, relying on its general training to perform the task. It works well for common tasks that are easy to describe. Few-shot prompting adds a small number of example inputs with their correct outputs, which demonstrate the desired format, tone or decision boundary more precisely than a description can. It is particularly effective for classification, where examples show exactly where one label ends and the next begins, and for output structure.

Models imitate examples closely, including their mistakes, their length and any patterns they happen to share. Examples should therefore be correct, diverse and representative of real inputs; if every example is short and positive, the model will tend to produce short, positive answers. Dynamic few-shot selection retrieves, for each input, the most similar examples from an example store, often with embeddings, so that the examples are always relevant without making every prompt long.

Scenario questions

Choosing a prompting technique

Exam skills 1.6.5

Choose the technique that best fits each situation.

Log in to try this activity Interactive activities are free with an account.

Chain-of-thought and reasoning

Chain-of-thought (CoT) instructions ask the model to reason step by step before answering, which improves multi-step problems such as calculations, eligibility rules and troubleshooting. The reasoning can be requested inside a tag, such as <thinking>, that the application strips before showing the final answer in <answer>. Models with built-in extended reasoning modes can instead be given a reasoning token budget through model-specific parameters. Reasoning raises output tokens, cost and latency, so it is used where accuracy gains justify it.

Related techniques include prompt chaining (splitting a task into sequential prompts), self-consistency (sampling several reasoning paths and taking the majority answer) and self-critique (asking the model to check and revise its draft). Assigning a precise role and providing relevant context often matter more than any single technique. The following table summarises when to use each technique.

TechniqueUse whenCost
Structured input with tagsPrompts mix instructions, documents and questionsNone
Few-shot examplesSpecific format, labels or tone are neededMore input tokens
Chain-of-thoughtMulti-step reasoning or rulesMore output tokens and latency
Prompt chainingDistinct sub-tasksMore calls, easier testing
Self-consistencyHigh-stakes answers with variable reasoningSeveral calls per request

The following diagram shows the reasoning step and what the user sees.

Chain-of-thought for eligibility decisions. The model checks each of the five rules in turn inside a thinking tag, guided by two worked examples of interacting rules, and puts its decision in an answer tag. The application removes the reasoning and shows the user only the answer.
Models with extended reasoning can use a reasoning budget instead of tags.
Match the pairs

Reasoning techniques

Exam skills 1.6.5 · 2.1.2

Match each reasoning technique with its description.

Log in to try this activity Interactive activities are free with an account.
Worked example

Eligibility errors

A benefits assistant must decide eligibility from five rules involving dates and employment types. It answers quickly but makes errors when two rules interact.

The task needs explicit reasoning. Adding chain-of-thought instructions that check each rule in turn inside a <thinking> tag, with two worked examples of interacting rules, and returning only the <answer> to users, improves accuracy. The extra output tokens are acceptable because errors are costly.

Check yourself

Why should few-shot examples be chosen carefully?

Show answer

Models copy them closely, including their format, labels and length, so poor examples produce poor outputs.

Exam Tips

Remember for the exam

  • Separate instructions, documents and questions with tags.
  • Few-shot examples fix format and labels; models copy them closely.
  • Multi-step logic: chain-of-thought or a reasoning budget.
  • Strip reasoning from user-facing output.