How to train an AI model in 2026: 6 steps, with a worked example
How to train an AI model in six plain steps: define the task, gather data, pick no-code, fine-tuning or scratch, train, test and deploy.

To train an AI model, you pick one narrow task, collect labelled examples of it, choose an approach (a no-code AutoML tool, fine-tuning an existing model, or training from scratch), run the training, check the results on examples the model has never seen, then deploy it. That's the whole loop. For most people, fine-tuning or a no-code tool is the right call; training from scratch is rarely worth it.
By the end of this guide you'll know how to train an AI model of your own, and you'll have walked through a full example: a photo classifier built in a browser in under an hour. I put this together from official docs and pricing pages (Google, Hugging Face, OpenAI, Together AI and others) as of early November 2026. Nobody at the site ran these tools hands-on for this piece, so the screen labels and prices come from the vendors' own pages. If the word "model" still feels fuzzy, read our explainer on what an AI model is first.
Before you start: the kit you need
- One task you can describe in a sentence, such as "sort these photos into three bins".
- Examples of that task with the right answer attached. Fifty is a sensible floor for text; images need a few dozen per category.
- A laptop with a modern browser. A GPU is only needed if you train locally, and free cloud notebooks cover most beginners.
- A small budget, possibly zero. Most of the beginner routes below cost nothing or a few dollars.
Tip: Spend more time on your examples than on picking tools. I'd guess bad data sinks more first projects than any other single cause.
Step 1: Define one narrow task
Write your task as an input and an output. "Input: a customer email. Output: one of billing, bug or feature request." That's a task a model can learn. "Make our support better" isn't.
Decide how you'll judge success before you collect a single example. A number works best, like "correct label on 9 out of 10 new emails". OpenAI's own fine-tuning guide puts it bluntly: "Only invest in fine-tuning after setting up evals." I think that advice holds for every route in this guide, not just theirs.
You should now have one sentence describing the input, one describing the output, and a target score.
Step 2: Collect and label your data
Gather real examples, ideally from the place the model will work. Old emails, photos from the actual camera, rows from your own spreadsheet. Then label each one.
Split the pile three ways: roughly 80% for training, 10% for checking progress during training, and 10% locked away for the final test. Never let the test set leak into training. It's the only honest exam you've got.
For text models, the common format is JSONL: one JSON object per line. Going by Hugging Face's TRL docs, a conversational example looks like this:
{"messages": [{"role": "user", "content": "My card was charged twice this month."}, {"role": "assistant", "content": "billing"}]}
How many lines? OpenAI's guide sets a minimum of 10 and says it sees gains "from fine-tuning on 50–100 examples", recommending you start with 50 good ones. It's a handy rule of thumb anywhere.
Watch out: models read text as tokens, not words, and many training services bill per token. Our guide to what a token is in AI explains why a 500-word email might count as 600 or more.
Step 3: Choose your approach
This is the biggest decision in the guide. Pick the row that sounds like you.
| Approach | Good for | Example tools | Typical cost (checked November 2026) |
|---|---|---|---|
| No-code AutoML | Image, sound or table classifiers; non-coders | Teachable Machine; Google Cloud AutoML | Free in the browser; Google charges $3.465 per training hour for image classification |
| Fine-tune an existing model | Custom chatbots, text sorting, a house writing style | Hugging Face TRL, Unsloth, Together AI | Free on Colab's free tier, or from $0.34 per million training tokens on Together AI |
| Train from scratch | Research, or very unusual data with no suitable base model | PyTorch, Keras | Anywhere from a few dollars for a tiny model to hundreds of millions for a frontier one |
A few details behind those numbers. On Google Cloud's price list, AutoML image training costs $3.465 an hour and keeping the model deployed costs $1.375 an hour, and you pay for a deployed model "even if no prediction is made". Tabular AutoML jumps to $21.252 per node hour. Google now sells all this under the name Gemini platform (it was Vertex AI, and the web address still says so).
For fine-tuning, Together AI's rates start at $0.34 per million tokens for small models such as Llama 3.1 8B, with a $4 minimum per job; you're billed on dataset size times the number of passes (epochs). One big change this year: OpenAI is winding down its fine-tuning platform, which is "no longer accessible to new users", and existing customers can only create jobs until January 6, 2027. If an older tutorial sends you there, you'll hit a wall.
Training from scratch is a different sport. Epoch AI estimates frontier training costs have grown about 2.4x a year since 2016 and that the largest runs will pass a billion dollars by 2027. Honestly, unless you're doing research or have truly unusual data, I'd skip it.
Step 4: Run the training
For no-code tools, this is a button. In Teachable Machine you click Train; in Google's AutoML you set a budget in hours and start the job.
If you're fine-tuning in code, probably the shortest path is TRL's SFTTrainer. The quick-start in the TRL docs trains a Qwen3 0.6B model in a few lines. Adapted for your own file, it's roughly:
# Run this in a Colab notebook cell after switching the runtime type to a GPU
!pip install trl datasets
from trl import SFTTrainer
from datasets import load_dataset
# Load your JSONL file of labelled examples, one conversation per line
dataset = load_dataset("json", data_files="train.jsonl", split="train")
trainer = SFTTrainer(model="Qwen/Qwen3-0.6B", train_dataset=dataset)
trainer.train()
Run it in a free Google Colab notebook if you haven't got a GPU. Colab's free tier includes GPUs and TPUs, though its FAQ warns resources "are not guaranteed and not unlimited". Short sessions are safer than overnight ones.
Low on memory? Unsloth is an open-source framework that claims training "2× faster with 70% less VRAM" and supports LoRA and QLoRA, which update only a small slice of the model's weights. Treat the speed claim as the vendor's, not an independent benchmark.
You should now see a loss number printed every few steps. It should drift down. If it flatlines at the start, check your data format before anything else.
Step 5: Evaluate on data the model hasn't seen
Open your locked test set from Step 2 and run every example through the new model. Count how many it gets right. Compare that against your target from Step 1, and against the base model with a good prompt and no training at all.
That second comparison matters a lot. If a plain prompt scores 85% and your fine-tuned model scores 86%, the training probably wasn't worth the upkeep. Read the wrong answers one by one, too; patterns usually point at missing or mislabelled examples.
Step 6: Deploy it
Training builds the model; running it to answer real requests is inference, and it's billed differently. Our comparison of AI inference vs training covers why the running costs often outlast the training bill.
Your options depend on the route. Teachable Machine exports "real TensorFlow.js models" that run anywhere JavaScript does, so a web page can host it for free. Open models can go on Hugging Face, where a Space on the free ZeroGPU tier costs nothing, a T4 GPU Space is $0.40 an hour, and dedicated Inference Endpoints start at $0.033 an hour. Remember to switch off anything you aren't using: idle endpoints still bill.
Example: a complete worked example
Here's the whole loop on a small, real-world task: a model that tells apart three kinds of recycling (cans, plastic bottles and paper) from a webcam photo. It's free and needs no code.
- Define the task: input is a webcam photo, output is one of Can, Bottle or Paper. Target: 9 out of 10 test items right.
- Go to Teachable Machine, click Get Started and pick the image option.
- Set up three classes and name them Can, Bottle and Paper.
- For each class, hold up a range of items to the webcam and capture 50 to 100 images. Vary the angle, lighting and background.
- Keep 10 physical items aside that you never show during capture. That's your test set.
- Start training and wait for it to finish (the site says you can keep everything on your device if you prefer).
- Hold up each of the 10 held-back items and note whether the preview picks the right class.
- If you hit 9 out of 10, use the export option and pick TensorFlow.js to use it on a web page.
You should now have a working classifier and a score. Scored 6 out of 10? Look at which class it confuses (crushed cans and foil-lined paper are classic culprits), capture more examples of exactly those, and retrain. That fix-and-retrain loop is what training actually looks like in practice.
Common mistakes and how to fix them
Testing on the training data
A model that's seen the answers will ace the test and then stumble in real use. Lock a test set away on day one.
Unbalanced classes
If 90% of your emails are "billing", a model can score 90% by always saying billing, which looks great on paper and is useless in practice. Count examples per class. Then top up the small ones.
Training when a prompt would do
Plenty of tasks don't need training at all. Try a well-written prompt on a large model first; if you're building something that takes actions, our guide on how to build AI agents may be a better fit than a custom model.
Forgetting the running bill
Google charges for a deployed AutoML model per hour, whether or not anyone uses it. Undeploy test models the same day.
Tips to get better results
- Fix labels before adding volume. Fifty clean examples tend to beat 500 messy ones.
- Collect examples from the exact setting the model will work in, with the same camera, the same email inbox and the same lighting.
- Change one thing per training run, so you know what made the difference.
- Avoid Hugging Face AutoTrain for new projects. Its docs now say it's "no longer maintained" and point you to Axolotl, TRL or transformers.Trainer instead.
Next steps
Once your first model works, try a second task with text instead of images, using the TRL snippet and a free Colab notebook. If you want the theory behind what just happened, our explainer on how LLMs work fills in the gaps. My advice? Keep the first three projects small and boring. It's the fastest way I know to build intuition.
FAQ
How to train AI model?
Define one narrow task, collect labelled examples, then pick a route: a no-code tool like Teachable Machine, fine-tuning an open model with TRL or Unsloth, or (rarely) training from scratch. Train it, test it on examples it hasn't seen, and deploy only if it beats a plain prompt on a large model.
How to train an AI?
For beginners, the easiest way is a browser tool. Teachable Machine lets you train an image, sound or pose classifier from webcam captures or uploaded files, with no coding, and export it as a TensorFlow.js model.
How do you train an AI model?
The model sees many input and answer pairs and adjusts its internal weights each time it guesses wrong, measured by a "loss" score that should fall over time. In practice, you supply the examples and a library such as TRL or a service like Google Cloud AutoML handles the maths. Your real job is good data and an honest test.
How to train my own AI?
Start with an existing open model and fine-tune it on your own data; it's far cheaper than building one. Together AI charges from $0.34 per million training tokens with a $4 minimum, or you can try a free Colab notebook. I'd begin with 50 good examples and grow from there.



