Sub topic 18
Scoping your first LLM project
This chapter assumes you have read the earlier chapters on prompting, structured output, retrieval, tool use, evaluation, and cost. It also assumes basic Python and familiarity with JSON and HTTP APIs. Scoping means deciding what the first version will do, how you will know it works, and what it will not do.
Start from the task, not the model
Write the task as one sentence: input, output, and who uses the result. "Given a support ticket, return one of four labels so the ticket reaches the right queue" is a scoped task. "Add AI to support" is not.
Then match the task to a pattern from the map of application types:
| Task shape | Pattern | Main risk |
|---|---|---|
| Sort text into categories | Classification | Wrong label on edge cases |
| Pull fields from documents | Extraction with validation | Missing or invented fields |
| Answer from your documents | Retrieval-augmented generation | Retrieving the wrong passage |
| Act on live data | Tool use | Wrong or unsafe calls |
| Multi-step goals | Agent loop | Compounding errors, cost |
Choose the simplest pattern that fits. A classifier is easier to test and cheaper to run than an agent.
Pick a first project with a bounded failure cost
Good first projects have three traits:
- A person reviews the output, or a wrong answer is cheap.
- Correct answers are easy to check against known examples.
- The input is text you are allowed to send to a model.
Classification, extraction, and drafting for human review fit well. Autonomous actions on money or customer data do not.
Define success before you build
Collect 30 to 50 real examples with the answers you expect. Decide the pass bar, for example "at least 90% of tickets get the right label". Fix this before tuning prompts, so you do not adjust the target to match the results.
The classifier from earlier chapters already shows a safe design. It limits the reply to allowed labels and falls back to other:
LABELS = ["billing", "bug", "feature_request", "other"]
def classify(ticket: str, complete) -> str:
prompt = (
"Classify the support ticket into exactly one label from: "
+ ", ".join(LABELS)
+ ".\nReply with the label only.\n\nTicket: " + ticket
)
answer = complete(prompt).strip().lower()
return answer if answer in LABELS else "other"Run it over your examples and count matches. That count is your baseline.
Escalate only when the numbers say so
Look at the failures before choosing a fix. Prompt changes address unclear instructions. Retrieval addresses missing facts. Fine-tuning is a last resort for consistent style or format problems.
Common scoping errors
- Starting with an agent when a single prompt would work.
- Having no test set, so quality is judged by a few good-looking demos.
- Ignoring cost and latency until after launch. Estimate tokens per request multiplied by expected volume.
- Sending sensitive data to a provider without checking privacy terms.
- Skipping a fallback path for when the model fails or returns something invalid.
Exercise
Your team wants an assistant that reads incoming invoices and pays them automatically. Name two changes that would make this a better first project.
Show answer
Limit the first version to extraction, with validation of fields such as vendor and total, instead of paying. Have a person approve each result. This bounds the cost of errors, and you can measure accuracy against invoices whose correct fields you already know. Automatic payment can come later, once the measured accuracy justifies it.