VITON13School

Generative AI for BeginnersLesson 3 of 21

Choosing an LLM for your task

There is no best model, only the best fit for a task, a budget and a response time you can accept. This lesson gives you a short, repeatable way to choose, based on your own prompts rather than on headlines.

Course by , Founder of VITON13 SCHOOL
  • Part 1: Foundations
  • 40 min

You will be able to

  • Name the main kinds of generative models and what each one outputs
  • Weigh open-weight against closed models for privacy, control and effort
  • Explain how model size affects quality, cost and latency
  • Decide whether better prompts, retrieval or fine-tuning should come before a model switch
  • Compare candidate models on a small test set and justify a choice

Kinds of models and the main families

Models differ first by what they produce. Chat and text models write prose and code, embedding models turn text into lists of numbers for search, image models draw pictures from descriptions, and speech models convert between audio and text. Many current chat models are multimodal and also accept images or audio as input.

Among text models you will meet a handful of families: GPT from OpenAI, Claude from Anthropic, Gemini from Google, Llama from Meta, plus Mistral, Qwen and DeepSeek. Each family comes in several sizes, from large flagship models to small fast ones, and some offer reasoning variants that think through a problem before answering.

Under the hood most generative text models are decoder-only transformers, built to continue a sequence. Encoder-style models such as BERT read text rather than write it and are still common for classification and embeddings. You rarely choose by architecture, but the distinction explains why an embedding model cannot chat.

You will also hear the term foundation model. It describes a large model trained on broad data that serves as a base for many tasks, either used as it is or adapted with further training.

Open weights or a closed model

A closed model keeps its weights with the provider; you reach it only through an API. You get a managed service with safety systems, scaling and support, but your data travels to the provider, you accept its terms, and it can change or retire the model on its own schedule.

An open-weight model can be downloaded and run on your own hardware or by a host you choose. That gives you control over privacy, offline use and versions. It also hands you the work: hardware, updates, monitoring and safety filtering become your job.

Open weights are not the same as open source, and they are not automatically free for every use. Licences range from permissive ones to licences with restrictions on use or scale, so read the licence before you build a product on a model.

There is also a middle path. Many hosting companies and routers serve open-weight models through the same kind of API as closed ones, so you can start with a hosted copy and move to your own server later without rewriting the app.

Size, cost and latency

Bigger models usually handle hard reasoning, long instructions and subtle writing better. They are also slower and cost more per token. Smaller models are fast and cheap and often good enough for classification, extraction, short rewrites and simple questions.

Cost is the sum of input and output tokens, each multiplied by the provider's rate, and output tokens are often the more expensive kind. Long system prompts and chat histories add input tokens to every request, so a cheap model with a bloated prompt can cost more than you expect.

Latency has two parts that users feel differently: the time until the first token appears and the time until the answer is complete. Streaming hides some of the wait. Check rate limits and the context window size as well, because a model that fits your quality bar but refuses your traffic is no use.

A hosted service is more than the model inside it. It bundles the model with content filters, logging, quotas and uptime guarantees, and two services running the same open-weight model can still differ in speed, limits and supported features.

  • Hard, rare, high-stakes tasks: start with a large model.
  • Frequent, simple, well-defined tasks: try a small model first.
  • Private data or offline use: consider an open-weight model you host.

Improve before you switch

Many failures blamed on the model are really prompt failures. Before you change model, give clear instructions, the context the model cannot know and an example of the output you want. That is the cheapest fix and the one to try first.

When the model needs facts it was never trained on, such as your notes or yesterday's news, retrieve the relevant text and add it to the prompt. This pattern is called retrieval-augmented generation, and it has its own lesson later in the course.

Fine-tuning trains an existing model further on your own examples. It suits a stable format, tone or narrow task with plenty of good examples, not knowledge that changes often. Training a model from scratch is rarely sensible outside large research teams.

A useful order of escalation is prompt, then retrieval, then fine-tuning, then a different model. Each step costs more effort than the one before, so move on only when your test set shows the current step has stopped helping.

Compare on your own test set

Public leaderboards measure general skills on public tasks. Your task is narrower and your users phrase things their own way, so ten real examples of your own predict your results better than any ranking.

Build the test set before you look at any output. For each input, write one line describing what a good answer must contain. Run every candidate with the same prompts and settings, record time and tokens, and score each answer as correct, partly correct or wrong.

Score without knowing which model wrote which answer, for example by shuffling the outputs. Then pick the cheapest, fastest model that clears your bar, and keep the test set: you will rerun it whenever a provider updates a model or you change a prompt.

Keep the scoring simple enough that you will actually do it. Three marks and a short note on each failure are plenty for a personal project; you can add automated checks once you know which failures matter most.

Write down the model name and the date of the run next to the scores. Hosted models are updated over time, and without a record you cannot tell whether a later drop in quality came from the model or from your own changes.

Example

compare.py: the same tests across several models

# compare.py - run the same test prompts through several modelsimport osimport time from dotenv import load_dotenvfrom openai import OpenAI load_dotenv()client = OpenAI(base_url=os.environ["LLM_BASE_URL"], api_key=os.environ["LLM_API_KEY"]) # In .env: LLM_MODELS=first-model,second-model (names your endpoint serves)models = [m.strip() for m in os.environ.get("LLM_MODELS", os.environ["LLM_MODEL"]).split(",")]tests = [    "Explain osmosis to a 12-year-old in three sentences.",    "Write one multiple-choice question about the French Revolution and mark the answer.",    "Turn this note into two bullet points: mitochondria make ATP; ATP stores energy for the cell.",] for model in models:    for number, prompt in enumerate(tests, 1):        start = time.perf_counter()        response = client.chat.completions.create(            model=model, messages=[{"role": "user", "content": prompt}]        )        seconds = time.perf_counter() - start        tokens = response.usage.total_tokens if response.usage else "n/a"        print(f"\n[{model}] test {number}: {seconds:.1f}s, {tokens} tokens")        print(response.choices[0].message.content.strip())

All models in LLM_MODELS must be served by the same endpoint, which is easy with a router or with several models pulled into Ollama. To compare providers, run the script once per .env setup.

Practice

Choose the model for Study Buddy

  1. Replace the tests list with ten real questions from a subject you are studying, mixing explanations, quiz requests and note rewrites.
  2. In tests/rubric.md, write one line per question saying what a good answer must include.
  3. Set LLM_MODELS to two or three models your endpoint offers, ideally one large and one small, create a results folder and run python compare.py > results/lesson-03.txt.
  4. Copy the answers into a table with the model names hidden, then score each one against the rubric as correct, partial or wrong.
  5. Put the winner in LLM_MODEL and write a one-sentence reason for the choice at the top of tests/rubric.md.

Done when: You have a results file, a score for every answer, and LLM_MODEL set to a model whose choice you can explain with your own scores, timings or token counts.

Common mistakes

  • Defaulting to the largest model and paying for quality the task does not need.
  • Trusting a public leaderboard more than ten examples of your own.
  • Giving each model a different prompt or setting, so the test measures the prompt instead of the model.
  • Assuming open weights means any commercial use is allowed without reading the licence.

Check yourself

Pick an answer to see whether it is right and why.

Answers on a general task are vague. What should you try first?

Right.Prompt improvements cost almost nothing and fix many problems; heavier options make sense only once the prompt is good.

Not quite.The right answer is “Add clear instructions, context and an example to the prompt”. Prompt improvements cost almost nothing and fix many problems; heavier options make sense only once the prompt is good.

What is the main advantage of an open-weight model?

Right.Downloadable weights let you host the model yourself, which gives control over privacy, versions and offline use.

Not quite.The right answer is “You can run it on hardware you control and keep data there”. Downloadable weights let you host the model yourself, which gives control over privacy, versions and offline use.

Which comparison between two models is fair?

Right.Holding prompts, settings and rubric constant means any difference you see comes from the models themselves.

Not quite.The right answer is “Both get the same prompts, settings and scoring rubric”. Holding prompts, settings and rubric constant means any difference you see comes from the models themselves.

From the founder

Write your ten test questions before you run a single model. If you write them after seeing the answers, you will quietly pick questions that your favourite model already handles well.
Vitalii Tarasov, Founder of VITON13 SCHOOL

Course by Vitalii Tarasov, VITON13 SCHOOL. Draws in part on Microsoft's Generative AI for Beginners, MIT licence, Copyright (c) Microsoft Corporation. microsoft/generative-ai-for-beginners