Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

Prompt and Context Optimisation

Free · sign in to start and track progress

1 · Designing prompts systematically

  • 1Prompting current Claude models
  • 2Choosing few-shot examples

    Exercise answers

    • Answer: Run an example ablation on the enquiries drafter
  • 3Eval-driven prompt iteration

2 · Optimising and operating prompts

  • 4Automatic prompt optimisation
  • 5Optimising tools, instructions and skills
  • 6Prompt registries and online tests
  • 7Model migration and regression suites
CapstoneOptimise and ship the questions drafterReference implementation

Module 1 · Designing prompts systematically · Lesson 2

Choosing few-shot examples

What examples actually teach a model, when they help and when they anchor it, how to select, order and place them (static, retrieved, many-shot), and how to measure whether they earn their tokens, using a follow-up questions drafter.

65 min 1 video 2 exercises 6-question quiz Answers
Setup for the exercises:Install Claude CodePython with uv

By the end of this lesson you can

  • Explain what in-context examples teach (format, label space, input distribution) and why that makes them powerful and risky
  • Choose between no examples, a static curated set, retrieved examples and many-shot prompting for a given step, and justify the choice
  • Implement example selection with similarity plus diversity (MMR) and stratification, keeping the example pool disjoint from the eval set
  • Place examples so prompt caching still works, and compute the cost difference between static and dynamic examples
  • Design an ablation that measures whether examples help, including an anchoring check

On this page

  • What examples actually teach
  • Known biases
  • Four strategies
  • Worked example: selecting enquiry examples
  • Where to put them, and what it costs
  • Measuring whether examples help
  • Misconceptions and limits
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01What examples actually teach
  2. 02Known biases
  3. 03Four strategies
  4. 04Worked example: selecting enquiry examples
  5. 05Measuring whether examples help
  6. 06Misconceptions and limits
  7. 07Connections
  8. 08Summary

Sources & further reading

  • Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?Paper · Min et al. · 2022Randomly replacing labels in demonstrations barely hurt accuracy; the label space, input distribution and format did the work. The key result for understanding what examples teach (EMNLP 2022).
  • What Makes Good In-Context Examples for GPT-3?Paper · Liu et al. · 2021The seminal case for retrieving examples semantically similar to the input instead of picking them at random.
  • Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order SensitivityPaper · Lu et al. · 2022The same examples in a different order moved results from near state of the art to near chance on the models studied (ACL 2022).
  • Calibrate Before Use: Improving Few-Shot Performance of Language ModelsPaper · Zhao, Wallace, Feng, Klein and Singh · 2021Diagnoses the biases behind few-shot instability (recency, label frequency, common tokens). Read section 4 for the bias analysis (ICML 2021).
  • In-Context Learning with Long-Context Models: An In-Depth ExplorationPaper · Bertsch et al. · Carnegie Mellon University · 2024With hundreds or thousands of demonstrations, retrieval's advantage shrinks and order sensitivity drops, but grouping same-label examples hurts. The state of the art on many-shot behaviour (NAACL 2025).
  • Many-Shot In-Context LearningPaper · Agarwal et al. · Google DeepMind · 2024Large gains from hundreds of examples on many tasks, plus model-generated rationales as a substitute for human-written examples (NeurIPS 2024).
  • Prompting best practices (use examples effectively)Docs · AnthropicCurrent guidance for Claude - relevant, diverse, structured examples in tags, typically three to five.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 8 more sections
  • 2 hands-on exercises
  • A 6-question quiz
  • Progress, quiz scores and bookmarks