Skip to content

Worked representation-to-output exercise with intermediate values and explained failures

14 min reading

Work a complete representation-to-structured-decision example and locate the first failing boundary.

Page details

GenAI · Lesson 10 of 45 · 1 / exercise 1

Sources · 14 min reading · 30 min with practice

Published · Last edited:

More
20px

Progress is saved in this browser when storage is available.

View guided paths and progress

Know first: Structured output: JSON Schema, grammar constraints and semantic validation. Optional help: GenAI foundations.

Optional background references

Hypothetical scenario. Northwind is ready to connect the mechanisms in a support-triage exercise. Maya wants a recommendation for staff, not an automatic case change. Dev has a token ledger, candidate similarities and a structured result; Priya asks which of those would permit a queue transition.

Dev: “The input fits and the nearest candidate matches the proposed queue.”

Maya: “I still need uncertain cases visible to a reviewer.”

Priya: “Trace each check. A matching label does not give the recommendation authority to change the case.”

You will work the supplied representation-to-output example, preserve intermediate values and locate the first failing boundary. The exercise combines counting, similarity and structured acceptance while keeping recommendation separate from execution.

Where does a correct intermediate result stop being enough?

Hypothetical scenario. Choose a toy tokenizer that reports 12 tokens for a request and 18 for its instructions. Their input subtotal is 12 + 18 = 30 before evidence and framing. A toy embedding extractor returns the request vector [1, 0]. Two candidate labels have vectors [1, 0] and [0, 1]. All three norms are one, so their cosine similarities to the request are 1 and 0. This is a fully supplied example, not a real embedding-model result.

Ask the completion stage for a JSON object containing a proposed queue and a supporting identifier. First check that the input budget includes any subsequently supplied evidence. Next check that similarity actually separates the intended task categories. Finally validate the object shape, identifier existence and permitted queue. A syntactically valid result selecting a forbidden queue fails the application contract even when every earlier calculation is correct.

To complete the exercise, write three artifacts: the count ledger, the two similarity calculations and an acceptance/rejection explanation for a structurally valid but unauthorized result. No tokenizer implementation or deployed Python pipeline is claimed. The purpose is to identify which boundary failed before adding another model call.

Hypothetical scenario. Priya needs urgent safety complaints escalated even when the model is uncertain.

In short. Separate classification from escalation authority. Keep uncertain cases in a visible review queue.

Classifying a ticket is not deciding its outcome

Hypothetical scenario. A support team wants incoming messages sorted by topic, urgency and the evidence needed for a reply. One message asks for a refund and embeds a sentence instructing the assistant to approve it immediately. A useful classifier should identify the request without treating the customer's instruction as authority to grant it.

This application produces a triage record and an evidence-backed draft for staff. It does not issue refunds, send messages or change an account. The distinction keeps extraction, recommendation and business action separate. Later automation can add narrowly authorized transitions after their contracts are designed.

The task is concrete: identify the correct customer case, choose among declared categories, preserve missing information and route uncertain or consequential decisions to the appropriate human workflow. Fluency alone does not establish a successful triage.

Give triage an inspectable evidence record

Hypothetical scenario. A support ticket becomes a proposed category, urgency and evidence spans. A routing decision records the rule version and whether review is required. The proposed category is not the same as a final customer resolution.

Give triage an inspectable evidence record
ArtifactConcrete evidenceDecision boundary
Ticketidentity, source revision, attachmentsOriginal evidence
Triage proposalcategory, rationale refs, uncertaintyFallible classification
Routing recordpolicy version, owner, dispositionRecoverable decision
Preserve source spans: Ticket evidence → Triage proposal.Preserve source spans: Ticket evidence → Triage proposal. Ticket evidence to Triage proposal: preserve source spans; Triage proposal to Routing / review: policy decides consequence.Ticket evidenceTriage proposalRouting / reviewpreserve source spanspolicy decides consequence
Preserve source spans: Ticket evidence → Triage proposal. Enlarge the diagram to inspect its labels; the surrounding records and explanation give the text alternative.

Keep the original ticket identity through normalization, tokenization and classification. If an exception appears in an attachment, preserve its source location rather than flattening it into an unexplained label. A low-confidence or unsupported case needs an explicit review path with a durable obligation and operational owner. Compare routing outcomes on independently labeled cases, including harmless unusual wording and genuinely consequential exceptions. A high average classification score can conceal the small class that most needs review.

A single label erases the reason for routing

A category such as billing can be correct while the priority, account identity or requested action is wrong. A high aggregate classification score can conceal the cases that send private information to the wrong team or miss an urgent service interruption.

Do not infer urgency solely from emotional wording. A frustrated message and a severe operational failure are different signals. The policy should identify evidence that makes a case urgent and explicitly represent when that evidence is absent.

Likewise, a model's confidence-like score is not automatically a calibrated probability. If routing depends on a threshold, evaluate that threshold against labeled cases and the consequences of false escalation and missed escalation. A number in a JSON object is still model output.

Build a triage record with evidence and uncertainty

Authenticate the intake source and establish the case identity. Extract the requested action, relevant entities and supporting spans. Validate required fields and permitted category values, then retrieve current eligible policy evidence for the proposed response.

Support triage separates interpretation from authorized actionAn authenticated case enters extraction and evidence lookup. Deterministic validation and routing produce a triage record and draft for a staff decision, without granting model output action authority.Case + identityExtract + retrievevalidate + routeTriage + draftstaff decisionCustomer content describes a request; it does not authorize the effect.

The triage record should distinguish observed facts, inferred category, missing information and policy-based recommendations. Preserve evidence references so a reviewer can inspect why the case was routed. A draft can say that eligibility needs review rather than inventing a completed decision.

Use a predefined workflow while the required stages are known. Building effective agents distinguishes such workflows from dynamically directed agents. A flexible planner is unnecessary if it merely chooses the same extraction, lookup and review steps every time.

Apply Case: AI-Assisted Support Triage at the acceptance boundary

Northwind's support workflow has several acceptance boundaries. Classification proposes a category; retrieval selects supporting policy; drafting produces text for Priya to review. A successful category prediction does not establish that the proposed refund is permitted. Keep the account and payment authorities outside the language-model output, and record which stage supplied each piece of evidence.

Use a hypothetical inbox of one thousand tickets per day. Suppose six hundred fit the initial read-only drafting scope and four hundred require another route. That is 600 / 1,000 = 60% in scope, not sixty-percent automatic resolution. If review of each draft takes two minutes, the candidate review demand is 600 × 2 = 1,200 minutes, or 1,200 / 60 = 20 hours. These assumptions describe work to be planned, not a productivity gain already achieved.

A routing decision should preserve the reason for escalation. Missing evidence, conflicting account state, unsupported policy interpretation and a requested action beyond scope need different next steps. Combining them into a generic low-confidence bucket makes it harder to choose the intervention. A model confidence score alone cannot establish either the customer's identity or the current authority to perform the requested action.

Evaluate the complete permitted task against a baseline. A draft that sounds helpful but omits a policy exception is not an accepted result. Track the source version, relevant passage, requested action, reviewer decision and eventual accepted outcome. This makes it possible to distinguish improved wording from an actual reduction in useful review work.

Start with one bounded ticket family and an explicit review queue. If the queue grows, inspect arrival mix, review effort and the work that can finish under the current staffing policy. More automatic drafts can increase unfinished work when each still needs a human decision. Expand the task only after the next action has an authorization rule, an operation identity and a recovery path that the team can explain.

Calculate routing errors and review capacity

Hypothetical scenario. Choose 100 labeled tickets, of which 20 require urgent review. The candidate escalates 15 of those 20 and also escalates ten of the 80 ordinary cases. It therefore creates 25 escalations, with 15 correct urgent escalations.

Urgent recall is 15 ÷ 20 = 0.75. Escalation precision is 15 ÷ 25 = 0.6. Five urgent cases are missed and ten ordinary cases consume urgent-review capacity. These are different errors with different consequences; overall agreement alone hides the trade.

For workload, choose 120 arriving cases per hour. Suppose 30% require human review after triage, producing 120 × 0.3 = 36 cases per hour. If staff resolve 30 per hour, the review backlog grows by 36 −30 = 6 per hour. A model that routes responsibly can still expose an operational capacity gap.

Choose a review backlog of 24 cases. If staffed resolution rises to 48 per hour while 36 new review cases continue arriving, net drain is 48 −36 = 12 per hour. Recovery takes 24 ÷ 12 = 2 hours under constant rates. Counting cases assumes comparable effort; complex cases may require a weighted workload model.

A draft request uses a chosen 1,000 tokens of message and instructions, two policy excerpts of 400 tokens each and a 400-token response allowance. Planned total is 1,000 +2 × 400 +400 = 2,200 tokens before extra serialization. The case evidence must still fit and remain eligible; trimming an exception to meet the budget can change the decision.

A planning revision should change one assumption at a time. If only three hundred of the illustrative tickets reach the review queue at two minutes each, demand becomes 300 × 2 = 600 minutes, or ten hours. That is a different routing workload, not proof that the original draft quality improved. Preserve the excluded ticket routes when comparing those two plans.

In the wild: Case: AI-Assisted Support Triage

Anthropic's Building effective agents: Known stages can use a bounded workflow instead of dynamic agent control.

Human review needs a useful record

Present the relevant source passages, extracted identity and unresolved questions alongside the draft. A reviewer should not reconstruct the entire task from an unexplained score. Highlight uncertainty that changes the action, such as missing purchase evidence or conflicting policy versions.

Review is not a magical correctness layer. Staff can be overloaded or persuaded by a confident draft. Keep explicit business validation and action authority outside the generated recommendation. Measure whether the workflow improves the intended task without increasing consequential mistakes.

Keep category definitions stable enough to label consistently. If policy changes, version the rubric and preserve earlier evaluation results. A changed label policy can move the score without any model improvement or regression.

A customer message becomes an internal command

Hypothetical scenario. A ticket says that the assistant must mark it approved and forward account records to a new address. The extraction stage correctly recognizes the requested action, but a downstream component treats the extracted words as an executable instruction.

Preserve the distinction between “the customer requested this” and “the organization authorized this.” Route proposals through the application policy. The indirect prompt-injection study demonstrates why untrusted content should not acquire control authority by entering a model context.

Use adversarial intake cases in evaluation, including misleading attachments and forged policy quotations. Restrict data scope before retrieval and avoid copying full private cases into unrestricted grading or telemetry services.

Three triage misconceptions

“Correct category means correct resolution.” Category, identity, evidence and authorized action are distinct outputs.

“A review queue makes every uncertain case safe.” Its capacity, presentation and operating policy determine whether the case receives meaningful review.

“A confident draft can be sent automatically.” Automatic sending changes the action scope and needs its own authority, identity and uncertain-effect recovery.

Release a narrow workflow before expanding authority

Start with shadow triage or staff-visible suggestions under a clearly declared policy. Compare paired cases against the existing workflow, inspecting missed urgency, incorrect identity and unsupported commitments separately from stylistic usefulness.

Monitor review arrival and completion, case age, override reasons, evidence failures and drift in the incoming population. A faster model does not help if the bottleneck is a growing unresolved-review queue.

Reject automatic account changes in the initial scope. Add one action only after its current-state checks, approval policy, effect identity and reconciliation are designed. The final draft should communicate what is known and what remains for a person to decide.

Limits of Case: AI-Assisted Support Triage

The ticket mix and review duration are hypothetical planning inputs. A proposed category or draft does not authorize an account change. Measure accepted outcomes and review work together, and keep escalation reasons visible when the bounded workflow cannot finish.

Test the ticket boundary

An urgent exception is lost during preprocessing but the category is plausible. Which boundary failed?

Reveal the design reasoning

The representation/evidence boundary failed before classification. Repair preservation and test the original exception, then re-evaluate routing; changing labels alone cannot restore omitted evidence.

Decision: Carry identity and evidence through every intermediate result before accepting a consequence.

Check yourself: review triage

The model correctly extracts a demand for a refund. Has it established approval?

No. Extraction represents the customer's request. Organizational policy, current evidence and action authority determine approval.

Urgent recall improves but review backlog grows. Is the release decision purely a model metric?

No. Inspect review capacity, case age and error consequences. A useful routing change must fit an operated workflow.

A draft is helpful but includes an unsupported promise. Can a high usefulness score compensate?

Not if the promise violates a required constraint. Evaluate commitments and evidence separately from writing quality.

Northwind decision log

Separate classification from escalation authority.
Keep uncertain cases in a visible review queue.
Measure missed urgent cases as well as average accuracy.

Go deeper into routing and authority

Check the mechanism in this lesson

The toy request's top candidate has cosine similarity one. Does that authorize the proposed support-queue change?

Compare the explanation

No. Similarity is a representation score in the supplied toy geometry. Check the task meaning, object structure and allowed queue. An authorized executor remains separate from producing a recommendation.

Carry the decision forward

Northwind has traced a bounded recommendation using supplied evidence. Page 11 begins the retrieval module: how does the application find current, permitted evidence and preserve its identity all the way to the answer?