How to train an AI model?
Training means showing a model examples, measuring how wrong it is, and nudging its numbers to be less wrong — repeated millions of times. For your own task, don't train from scratch: fine-tune an existing open-weight model like gpt-oss-20b, which runs in 16GB of memory. From-scratch frontier training costs billions.
Why — the first-principles explanation
Underneath the mystique, training is one loop repeated until your money runs out.
A model is a giant pile of numbers called weights — gpt-oss-20b has 21 billion of them. Those numbers define a function: text in, prediction out. Training is the process of finding good values for them. You start with random noise, feed in an example, and compare the model's output to the right answer. The gap is the loss. Then calculus tells you, for every single weight, which direction to nudge it to make the loss slightly smaller. You nudge. You repeat. That's gradient descent, and it is essentially the entire field.
What makes this expensive isn't cleverness, it's scale. Each nudge is tiny, so you need trillions of examples and enormous parallel hardware to get anywhere. This is why frontier training costs are measured in billions of dollars and why OpenAI, with roughly $2 billion in monthly revenue, still isn't profitable. The compute bill is the business.
Here's the part that saves you: you almost certainly should not train from scratch. Someone else already spent the billions learning grammar, facts and reasoning, and released the weights. Your job is to take that finished brain and specialize it — fine-tuning. You show it a few hundred or few thousand examples of your task, and nudge the weights slightly. Same loop, ten-thousandth of the cost.
And before even that, try the cheapest option: prompting. Just describe your task well, or paste in relevant documents (retrieval). A huge share of "we need to train a model" projects turn out to be prompting problems wearing a costume. Training is what you do after prompting has genuinely failed, not before you've tried it.
An example that makes it click
Think of hiring a chef. Training from scratch is raising a baby for 25 years until they can cook — that's what OpenAI and Google do, and it costs a fortune.
Fine-tuning is hiring a chef who already went to culinary school and spending two weeks teaching them your restaurant's twelve signature dishes. Same result for your menu, a rounding error of the cost.
And prompting? That's just handing the chef your recipe card. Try that first. You'd be amazed how often the chef already knew.
How to do it
- Try prompting first. Write a clear instruction to an existing model like Gemini, Claude or GPT. Add examples in the prompt. If this works, stop — you've saved weeks and thousands of dollars.
- Try retrieval next. If the model just lacks your specific facts, feed it your documents at question time (RAG) instead of baking them into the weights. Facts change; weights don't update themselves.
- Define success numerically before you train anything. Build a test set of 100–500 real examples with correct answers. If you can't measure it, you can't tell if training helped.
- Collect and clean your data. For fine-tuning, aim for hundreds to a few thousand high-quality input/output pairs. Quality beats quantity — 500 clean examples beat 50,000 messy ones.
- Pick a base model that fits your hardware. gpt-oss-20b (21B parameters, 3.6B active) runs within 16GB of memory; gpt-oss-120b needs a single 80GB GPU like an H100. Both are Apache 2.0 licensed.
- Fine-tune with a parameter-efficient method (LoRA/QLoRA), which trains a small adapter instead of all the weights. This is what makes fine-tuning possible on one consumer GPU or a cheap cloud rental.
- Evaluate against the test set from step 3, and compare to the un-tuned baseline. If fine-tuning doesn't beat plain prompting, throw the fine-tune away.
- Deploy with a real inference server — Ollama, LM Studio, vLLM or llama.cpp — not your training script.
Key facts
- gpt-oss-20b has 21 billion total parameters with 3.6 billion active per token and runs within 16GB of memory; gpt-oss-120b has 117 billion total with 5.1 billion active and runs on a single 80GB GPU.
- Both gpt-oss models are released under the Apache 2.0 license, permitting commercial use and fine-tuning without copyleft restrictions.
- Frontier training economics: OpenAI reported roughly $2 billion in monthly revenue as of March 2026 and remains unprofitable, because compute spending exceeds it.
- Local runtimes that serve open-weight models include Ollama, LM Studio, llama.cpp, vLLM and Hugging Face Transformers.
- Fine-tuning a Mixture-of-Experts model like gpt-oss activates only a fraction of parameters per token (3.6B of 21B), which is why it fits on consumer hardware.
▶ The 60-second explainer (script)
How do you train an AI model? Underneath the mystique, it's one loop. A model is a giant pile of numbers called weights — gpt-oss-20b has twenty-one billion of them. Training means finding good values. You start random, feed in an example, compare the output to the right answer. The gap is the loss. Then calculus tells you which direction to nudge every single weight to make that gap smaller. You nudge. You repeat. That's it. That's gradient descent, and it's basically the whole field. What makes it expensive isn't cleverness, it's scale. Each nudge is tiny, so you need trillions of examples. That's why frontier training costs billions and why OpenAI still loses money at two billion a month in revenue. Now the part that saves you: don't train from scratch. Someone already spent the billions teaching a model grammar and facts, then published the weights. Take that finished brain and specialize it — that's fine-tuning. A few hundred examples of your task, a ten-thousandth of the cost. gpt-oss-20b runs in sixteen gigs. But try prompting first. Honestly. Most 'we need to train a model' projects are prompting problems in a costume.
What authoritative sources say
People also ask
How much does it cost to train an AI model?
Fine-tuning an open-weight model can cost from nothing (your own GPU) to a few hundred dollars of cloud rental. Training a frontier model from scratch costs billions — that market is closed to almost everyone.
How much data do I need?
For fine-tuning, hundreds to a few thousand clean input/output pairs is a normal starting point. Quality dominates: 500 accurate examples beat 50,000 noisy ones.
Can I train an AI model on my laptop?
You can fine-tune a small open-weight model with LoRA on a decent GPU, and gpt-oss-20b will run for inference in 16GB. You cannot train a frontier model — that needs thousands of GPUs.
What's the difference between training and fine-tuning?
Training from scratch starts from random weights and learns everything. Fine-tuning starts from a model that already knows language and nudges it toward your specific task.
Do I need to know math?
To use fine-tuning libraries, no — the calculus is handled for you. To debug why training failed, understanding loss, learning rate and overfitting will save you enormous time.
The same question, asked other ways
- How to train AI?720/mo
- How to train an AI?590/mo