Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
You're building a medical-document Q&A system: clinicians ask questions, your app retrieves relevant patient-note chunks, and the LLM answers based on those chunks. Specify the structural layout of the prompt: what each component is, where it lives (system vs user), and why. Address: instructions, output format, few-shot examples, refusal directive, citation constraint, context layout. Be specific about decisions and tradeoffs.
Put role, format schema, refusal rule, citation contract, and few-shot examples in the cacheable system message; put XML-tagged retrieved notes and the clinician's question, in that order, in the user message.
Imagine you are a brand-new hospital intern, and your supervisor hands you a binder of rules every morning, then on each patient case slides a stack of that patient's notes across your desk and asks one question. The binder never changes day to day. It tells you to answer only from the notes, write your answer in a fixed form, and admit when the notes do not say enough. The stack of notes is different every case, and the question always comes after the notes so it is the last thing you read before you answer. That two-part split (rules in the binder, evidence and question on the desk) is exactly how this prompt is laid out.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
5 min: system vs user split + cacheability boundary + verbatim citation contract + refusal path with confidence enum + XML-tagged notes plus end-placed question + regression-eval hooks.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Putting retrieved patient notes in the system message because they look like context, which breaks prompt caching and loses the recency-attention boost that the clinician's question needs.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.