CCAR-F · Domain 4: Prompt Engineering & Structured Output · 20% of the exam
Task 4.2: Apply few-shot prompting to improve output consistency and quality
A few targeted examples that show the format, the reasoning behind ambiguous calls, acceptable versus problematic patterns, and how to extract from documents that are laid out differently.
Study it
Few-shot examples for format, ambiguous cases and varied documents
Try each one before opening the answer. Every option is explained, with the Anthropic documentation page that proves it.
Question 1 · choose 1
Your CI reviewer writes a markdown summary for each pull request. The instructions ask for the location, the issue, a severity and a suggested fix for every finding, yet some findings lack line numbers, severities vary in wording, and fixes are sometimes missing. Which change most reliably makes the findings consistent?
AAdd a few example findings to the prompt, each written in the exact format
BSet the temperature to 0 so that every finding comes out in the same format each time the review runs
CRepeat the format requirements in capital letters at both the start and the end of the instructions
DAsk Claude to check its findings against the format rules before finishing
Show the answer and why
AAdd a few example findings to the prompt, each written in the exact format
Correct
Examples are one of the most reliable ways to steer output format; they show the structure the instructions only describe.
BSet the temperature to 0 so that every finding comes out in the same format each time the review runs
Incorrect
Lower randomness does not teach the format; it can make the same inconsistent layout repeat more reliably.
CRepeat the format requirements in capital letters at both the start and the end of the instructions
Incorrect
Repetition and emphasis do not show what a correct finding looks like, so the variation continues.
DAsk Claude to check its findings against the format rules before finishing
Incorrect
A self-check against rules it already misapplies is weaker than a concrete pattern to copy.
When detailed instructions alone give inconsistent formatting, add a few targeted examples of the exact output. Few-shot examples demonstrate the format in a way prose cannot.
Your extraction system pulls cited references out of research reports. Some reports cite inline ("Smith et al., 2021"), others use numbered markers that point to a bibliography at the end. For the second kind, the references field often comes back empty although the bibliography is in the document. What should you change first?
ARetry every extraction whose references field comes back empty, with the same prompt and document
BMake the references field required so Claude must fill it for each report
CShorten the documents by removing their bibliographies before extraction so the prompt focuses on the body
DAdd few-shot examples that show correct extraction from both citation layouts
Show the answer and why
ARetry every extraction whose references field comes back empty, with the same prompt and document
Incorrect
An identical retry repeats the same misreading of the layout.
BMake the references field required so Claude must fill it for each report
Incorrect
Requiring a value pushes Claude to produce something, including invented references, without showing it where to look.
CShorten the documents by removing their bibliographies before extraction so the prompt focuses on the body
Incorrect
This deletes the very section that holds the references for the numbered-marker reports.
DAdd few-shot examples that show correct extraction from both citation layouts
Correct
Examples of each document structure show Claude how to find the data in layouts it is currently missing.
Few-shot examples that cover varied document structures (inline citations versus bibliographies) reduce empty or null extractions of fields that are present but laid out differently.
Your extraction prompt for shipping manifests already has detailed instructions, and output is still inconsistent. You are adding few-shot examples for the first time and want good results without inflating every request. How many examples does Anthropic's prompting guidance suggest as a starting point?
AThree to five well-chosen, diverse examples
BOne example per field in the schema, about 25 in all
CA single example of the most common manifest layout
DNone at first; keep adding instruction rules until the output stabilizes
Show the answer and why
AThree to five well-chosen, diverse examples
Correct
A few relevant, diverse examples give the best results for the tokens they cost.
BOne example per field in the schema, about 25 in all
Incorrect
That many examples inflates every request without proportional benefit.
CA single example of the most common manifest layout
Incorrect
One example is easily over-copied and shows none of the variation in real manifests.
DNone at first; keep adding instruction rules until the output stabilizes
Incorrect
More rules is what has not worked; examples are one of the most reliable ways to steer format and structure.
Examples are one of the most reliable ways to steer output. The prompting guidance suggests three to five for best results, rather than one example or dozens.
You have three examples for your extraction prompt and suspect they are too similar. You would like more coverage without writing every example by hand. What does the guidance suggest?
ARemove the examples and add more rules instead
BCopy each example three times with small wording changes
CAsk Claude to check them for diversity and draft more
DUse only examples taken from a different task
Show the answer and why
ARemove the examples and add more rules instead
Incorrect
Rules do not replace the demonstration examples give.
BCopy each example three times with small wording changes
Incorrect
Near-duplicates reinforce the same narrow pattern.
CAsk Claude to check them for diversity and draft more
Correct
Claude can evaluate examples for relevance and diversity or generate additional ones from your set.
DUse only examples taken from a different task
Incorrect
Examples should mirror your own use case.
You can ask Claude to evaluate your examples for relevance and diversity, or to generate additional ones based on your initial set.
Your support prompt has grown a list of 70 edge-case rules ("if the customer mentions X, do Y"). Behavior is brittle, and new edge cases keep breaking it. What does Anthropic's context-engineering guidance recommend instead?
AA small set of diverse, canonical examples
BOne very long example that covers all 70 cases at once
CRemoving all guidance and letting the model decide
DMore rules, so that every new edge case is covered
Show the answer and why
AA small set of diverse, canonical examples
Correct
Canonical examples portray the behavior and generalize better than a laundry list of rules.
BOne very long example that covers all 70 cases at once
Incorrect
A single sprawling example is hard to learn from.
CRemoving all guidance and letting the model decide
Incorrect
Too little guidance fails in a different way.
DMore rules, so that every new edge case is covered
Incorrect
The list keeps growing and still breaks on the next case.
Prefer a curated set of diverse, canonical examples over stuffing a prompt with edge-case rules.
Your few-shot examples for extracting fields from shipping manifests use tidy, typed documents, while real manifests are scanned, abbreviated and full of handwritten notes. Results on real documents are poor. What should you change?
AAdd a note that real documents will look different
BUse examples that look like the real manifests
CSwitch the examples to invoices, which are better structured
DKeep the tidy examples, since they show the ideal output most clearly
Show the answer and why
AAdd a note that real documents will look different
Incorrect
A note does not show how to handle the differences.
BUse examples that look like the real manifests
Correct
Examples should closely match the actual inputs to be useful.
CSwitch the examples to invoices, which are better structured
Incorrect
Examples from another document type are less relevant.
DKeep the tidy examples, since they show the ideal output most clearly
Incorrect
The output can be ideal while the inputs look realistic.
Make examples relevant: they should mirror the real inputs, including their mess, as well as cover diverse cases.
Your support replies are accurate but swing between stiff and overly casual. The brand guide describes the tone in a paragraph. What most reliably makes the tone consistent?
AA longer paragraph describing the brand voice
BA list of words the agent must never use
CA temperature of 0 for every reply
DA few example replies in the target tone
Show the answer and why
AA longer paragraph describing the brand voice
Incorrect
Description alone is what produces the inconsistency now.
BA list of words the agent must never use
Incorrect
Prohibitions do not show what the tone should be.
CA temperature of 0 for every reply
Incorrect
Lower randomness does not define the target tone.
DA few example replies in the target tone
Correct
Examples steer tone and style more reliably than a description.
Few-shot examples steer format, tone and structure; wrap them in example tags so Claude can tell them apart from instructions.