AI Engineering
/
Prompting & Structured Output
/

Write an extraction prompt with examples

Prompting & Structured Output · 90 minutes

Write an extraction prompt with examples

Rewrite a vague request into a testable extraction prompt with category rules, a missing-data policy, consistent examples, and a JSON output contract, then explain why parseable JSON can still be wrong.

Easy
Conceptual

1.5 h

Used in interview rounds:

Technical Screen (Easy)

Step 1: The question

Rewrite "Read this ticket and give me the details" into a prompt for category and order-ID extraction. Include category definitions, missing-data handling, two examples, and an output format. Then say what the application must still check after the model replies.

The ticket task

Suppose a support tool sends each new ticket to a model with the instruction "Read this ticket and give me the details." A program reads the reply and routes the ticket, so the reply has to be machine-readable. The fictional product policy is:

  • Categories: billing (charges, invoices, refunds), technical (application errors, access failures), and other (anything else, or not enough information). A ticket with both a billing and a technical issue is other, so a person can review it.
  • Order ID: ORD- followed by exactly three digits, copied only when it appears in the ticket.
  • Output: the fields category and order_id, and order_id is always present.

The vague instruction says none of this. It does not name the categories, say what to return when no order ID or two different order IDs appear, show an example, or define the format of the reply. Tickets are written by customers, so some will contain text that looks like instructions.

Constraints

  • Use only the categories billing, technical, and other, as the ticket policy defines them
  • An order ID is ORD- followed by exactly three digits and is copied only when it appears in the ticket
  • A program parses the reply, so it must be one JSON object with no surrounding text
  • The ticket is untrusted source data, supplied separately from the instructions

Deliverables

  • An instruction with category definitions and a rule for tickets that fit more than one category
  • A missing-data and ambiguity policy for order_id
  • Two examples with expected outputs that agree with the rules
  • The output format, plus what must still be checked after generation

Step 2: Hints

Optional. Each hint gives a little more away.

Step 3: Your answer

Kept in this browser. Saving your score below keeps a copy with it.

0 / 5000

Step 4: Reference answer

Step 5: Score yourself

Score each dimension 0, 1, or 2, then save the score to your history. Readiness thresholds are editorial estimates.

Grades your written answer against this rubric with your own AI provider key from Settings. It is a second opinion: the score you save is still yours.

Task clarity
Category and ambiguity rules
Examples
Missing-data handling
Validation awareness

0 of 10 · Scored 0 of 5 dimensions

Ready at 8 of 10

Kept in this browser until you sign up, then it moves to your account.

Complete this level when you can write a prompt another developer can evaluate without guessing your intent, predict the practice fixtures without looking, and explain why parseable JSON still needs source checks.

Your saved scores

Practice saves and mock interview answers on this question, newest first.

No saved scores yet. Score every dimension, then save.

Step 6: Follow-up questions

An interviewer may ask these next.

What makes a prompt testable?

When would you add examples?

Is JSON enough for safe processing?

Why use null?

Can a role instruction ensure accuracy?

Step 7: Mark complete