new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Prompt Engineering · all subjects

few-shot prompting

9 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Few-shot prompting definition and effectiveness

Few-shot prompting is the technique of giving Claude examples of how you want it to behave or how you want it not to behave. This approach is extremely effective for getting the right answer and getting the answer in the right format. The term 'few-shot' refers to the number of examples used within the prompt, and related terms include 'zero-shot' (no examples), 'one-shot' (one example), and 'n-shot' (n examples).

Few-shot prompting more effective than descriptive instructions for formatting

When you need Claude to extract and format information in a specific way, providing a few correctly-formatted examples is much easier and more effective than walking Claude through step-by-step formatting instructions. Claude can extrapolate the desired format from the examples.

Using prefill to guide few-shot formatting example

When using few-shot prompting for formatting tasks, you can prefill the assistant's response to start Claude off on the right foot. For example, when extracting names and professions, prefilling with the opening tag '<individuals>' helps Claude continue in the same format.

Parent bot tone example without few-shot prompting

Without examples, Claude's default response to 'Will Santa bring me presents on Christmas?' is quite formal and robotic, which breaks a child's heart.

Parent bot tone example with few-shot prompting

To get Claude to respond in a warm, child-friendly tone, you can provide an example conversation and then ask Claude to continue in that style. Example prompt: 'Please complete the conversation by writing the next line, speaking as "A". Q: Is the tooth fairy real? A: Of course, sweetie. Wrap up your tooth and put it under your pillow tonight. There might be something waiting for you in the morning. Q: Will Santa bring me presents on Christmas?' This guides Claude to respond with warmth and imagination rather than formally.

Entity extraction with few-shot formatting example

For extracting names and professions from text and formatting them as a numbered list with professions in brackets, provide multiple examples showing the desired format. The prompt includes narratives about individuals followed by correctly formatted extraction examples like '1. Dr. Liam Patel [NEUROSURGEON]'. Claude can then apply this format to new text.

Email classification exercise with few-shot prompting

Exercise 7.1 demonstrates using few-shot prompting to classify emails into four categories: (A) Pre-sale question, (B) Broken or defective item, (C) Billing question, (D) Other. The exercise requires editing a prompt to include examples of emails with their correct classifications so Claude learns the classification scheme and outputs the correct category letter.

Examples are most effective prompt tool

Examples are probably the single most effective tool in knowledge work for getting Claude to behave as desired. Provide at least one example of an ideal response in <example></example> XML tags. Multiple examples improve performance. Examples of edge cases and scratchpad formats should be included. More examples generally equals better results.

Examples are the single most effective tool in knowledge work prompts

When crafting prompts for knowledge work tasks, provide at least one example of an ideal response that Claude can emulate. Multiple examples are better than one. Include examples of common edge cases, not just typical scenarios. For prompts using scratchpads or intermediate reasoning, show what the scratchpad should look like. This approach is more effective for getting desired behavior than relying solely on instruction.

Give your agent this brain