Repository navigation
Bedrock Model Selection Lab · Choosing a model you can defend on four dimensions #3
akash-coded
started this conversation in
Hands-on Labs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Bedrock Model Selection Lab — Picking the Right Model for a Complex Use Case
Anchor product: TravelMind, an airline support agent.
You will: decompose a messy real-world use case into subtasks, qualify each one, budget it across three models, A/B test in the model playground, route a model to each subtask, then implement your choice with the Converse API and tools.
The one rule that drives everything:
A "complex use case" is almost never one model. It is a routing problem: extraction goes to a cheap model, irreversible decisions go to a stronger one (or to a tool), high-volume chat goes to the fastest. Your job in this lab is to prove which model goes where with data, not vibes.
flowchart LR A[1. Decompose into subtasks] --> B[2. Qualify each subtask] B --> C[3. Estimate tokens and budget] C --> D[4. Prompt suite and playground A/B] D --> E[5. Route a model per subtask] E --> F[6. Implement with Converse API]The three models in play
All rates are Bedrock,
us-east-1, standard on-demand, USD per 1M tokens. Always re-verify ataws.amazon.com/bedrock/pricing— rates move.us.amazon.nova-2-lite-v1:0us.anthropic.claude-haiku-4-5-20251001-v1:0us.anthropic.claude-sonnet-4-5-20250929-v1:0Notes that will bite you if you skip them:
amazon.nova-2-lite-v1:0,anthropic.claude-...) won't work for on-demand — use theus.profile ID shown above.The use case
TravelMind handles airline customer support end to end. Break it into these subtasks (a clean spread of cognitive types):
Optional stretch subtask: live flight-status Q&A — high volume, latency-critical, low stakes (good clean example of the "cheap-and-fast" cost type).
Step 1 — Decompose into subtasks (~15 min)
Rule: one subtask = one dominant verb. If a subtask hides two verbs, split it. The verb predicts the model tier.
Your task: list every atomic subtask in TravelMind and tag its dominant verb. You should land on more than three once you split (e.g., "refund handler" splits into classify intent → check eligibility (tool) → orchestrate offer → generate message).
Step 2 — Qualify each subtask (Framework 1) (~25 min)
Score each subtask on these dimensions. The tricks matter more than the labels.
Two tricks that decide more cases than the rest:
Worked example — Refund handler
execute_refundtool existsYour turn — fill these in
Itinerary builder
Ticket reader
Step 3 — Estimate tokens and budget (Framework 2) (~25 min)
Token rules of thumb
For Claude vision, image input tokens are roughly:
So a 1000×1500 ticket photo ≈ 2,000 input tokens before any text. (Nova uses its own tiling scheme — treat this as the right order of magnitude, then confirm with real counts in Step 4.) A multi-page PDF sent as a
documentblock can be far heavier — if you don't need layout, extract text first.The cost formulas
Per request:
Per 1,000 requests (the unit that actually fits in your head):
Monthly:
With prompt caching at hit rate$h$ , the effective input price drops:
Worked budget — Refund handler
Assume per resolved conversation: ~5,000 input tokens (system prompt + tool schema reused each turn + history + echoed tool results) and ~1,200 output tokens across ~3 turns. Volume: 2,000 refund conversations/day.
The spread is ~7.3x from Nova 2 Lite to Sonnet. If Nova 2 Lite clears the quality bar on the refund suite (and it might, because the rules live in tools), you save ~$1,700/month versus Sonnet — for this one subtask alone. But if it ever fabricates eligibility despite the tool, it fails the hard gate (Step 4) regardless of price.
The levers, ranked by impact
maxTokens. Prompt for brevity. Output is 5–8x input.MAX_TURNScap stops a runaway agent from racking up tool round-trips.Your turn
Build the same table for the itinerary builder and the ticket reader. For the ticket reader, remember to add image/PDF tokens to$T_{in}$ — they dominate.
Step 4 — Build prompt suites and A/B in the playground (Framework 3) (~40 min)
The playground is for qualitative head-to-head — does the output hold up? It does not do your cost math (that's Step 3) and it won't tell you production latency. What it gives you: identical-input comparisons and real token counts.
How to run a clean experiment
temperature=0for deterministic/rule/extraction tasks (refunds, ticket parsing).0.3–0.7for prose (itinerary narrative). Test at ship temp, not the default.Build a prompt suite, not a demo
A prompt suite = 5–8 test cases per subtask. Weight it toward failure modes, because the happy path passes on every model and tells you nothing.
Per subtask, include: 1 happy path · 2–3 edge cases · 1–2 adversarial/trap cases · 1 ambiguous case.
Scenario bank (steal these):
Refund handler
Itinerary builder
Ticket reader
Score on a rubric
Score each output 0–2 on each: Correctness · Format/schema adherence · Hallucination-free · Tone/clarity. Sum per case, then per model across the suite.
Decision rule:
Step 5 — Route a model per subtask (~10 min)
Fill the routing table. This is the real deliverable — a per-subtask assignment with a one-line justification tied to your data.
Guardrail callout (refund handler): the boundary "must never issue a refund" is not enforced by the prompt. It is enforced by never exposing an
execute_refundtool to the model. Prompt-only guardrails are bypassable; capability boundaries in code are not. The model can read eligibility and present options; moving money is a separate, human-gated step.Step 6 — Implement with the Converse API (~45 min)
You'll build the refund handler: a basic call, a dummy tool, and the multi-turn tool loop. Then a short vision snippet for the ticket reader.
Setup
VS Code (~3 steps)
pip install boto3.aws configure, or env varsAWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_DEFAULT_REGION=us-east-1.Google Colab (~3 steps)
!pip install boto3os.environ[...]in a cell (includeAWS_DEFAULT_REGION=us-east-1).Basic call (no tools)
Dummy tools (the logic lives here, not in the model)
Tool config + system prompt
The multi-turn tool loop
flowchart TD U[User message] --> M[converse call] M --> S{stopReason} S -->|tool_use| T[Run tool in code] T --> R[Append toolResult to messages] R --> M S -->|end_turn| O[Final answer to user]Run the SAVER case above (should deny + offer coupon), then swap in a flexible fare 5 days out (should approve), then the "or I'll sue" case (should hold the line). Compare across all three models — that's your Step 4 evidence, generated programmatically.
Vision snippet (ticket reader)
What changes in production
Deliverable checklist
Stretch
All reactions