Sub topic 1
Start from the task, not the model
Prerequisites
This chapter assumes you have called an HTTP API or SDK before and can read basic Python. You should also know what a large language model does, and what a prompt, a token, and a context are.
Why the task comes first
Model names change every few months. Your requirements change much more slowly. If you start by asking "which model is best?", you will compare leaderboards that measure someone else's work. If you start by asking "what must my application do?", you get criteria you can test.
A selection criterion is a measurable requirement that a model must meet for your application to work. The rest of this tutorial turns each criterion into a number you can check: memory, cost, latency, and quality on your own examples.
Turn needs into criteria
Write down the task in one sentence, then answer the questions below. Each answer constrains the choice.
| Question about the task | Criterion it produces | Later chapter topic |
|---|---|---|
| How hard is the task (extraction, summarizing, multi-step reasoning)? | Minimum quality, and so a model size range | Model sizes |
| How much text goes in per request? | Required context window | Context window |
| How many requests per month, and how many tokens each? | Budget ceiling | Token pricing |
| How fast must a reply arrive? | Latency target | Latency and throughput |
| Can the data leave your network? | Hosting options allowed | Privacy and compliance |
| How likely is it that you will change models? | Need for a swappable design | Portability |
Notice that the table does not name a single model. It describes the job.
A worked example
Suppose you are building a feature that reads a customer email and extracts the invoice number. Here is the task written as criteria.
requirements = {
"task": "extract one invoice number from a short email",
"difficulty": "low", # pattern-like, one right answer
"input_tokens": 2_000, # email plus instructions
"output_tokens": 20,
"requests_per_month": 50_000,
"max_latency_seconds": 3,
"data_may_leave_network": False, # emails contain customer data
"min_pass_rate": 0.98, # measured on your own examples
}
for key, value in requirements.items():
print(f"{key}: {value}")Reading this list tells you a lot before you look at any model:
- The task is easy, so a small model may be enough.
- The input is short, so a large context window adds nothing.
- Customer data must stay inside your network, which rules out some hosted options and points toward an open-weight model you run yourself.
- A pass rate of 98% gives you a pass or fail test for every candidate.
How the pieces connect
The criteria drive every later decision in this tutorial.
Common mistakes
- Picking the model with the highest public benchmark score, then discovering it is too slow or too costly.
- Leaving privacy until the end, after the prototype already sends customer data to a provider.
- Writing criteria that cannot be tested.
Exercise
A team wants to summarize 300-page legal contracts that cannot leave their company network. Name two criteria from the table that they must fix before choosing a model, and say what each one implies.
Show answer
The context window must be large enough to hold the contract text (or the team must split documents into pieces), and the data privacy limit means the model must run inside their network, so they need an open-weight model they host themselves or a provider arrangement that meets their compliance rules. Cost and quality targets also matter, but these two narrow the options first.