Skip to main content

Your First AI Model

Let’s train a simple text classification model that can detect positive vs negative sentiment in text. This tutorial takes about 10 minutes and works on any computer.
New to AI Training? Check out the Interactive Wizard Guide for a more detailed walkthrough, including how to choose models, understand dataset sizes, and use wizard commands.

Before You Start

Make sure you’ve installed AI Training. You should be able to run:
aitraining --version
If you haven’t installed it yet, the quickest way is:
# Install uv if you don't have it
curl -LsSf https://astral.sh/uv/install.sh | sh  # Mac/Linux
# or
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"  # Windows

# Then install AI Training
uv pip install aitraining torch torchvision torchaudio

Choose Your Path

We’ll show the same task two ways. Pick the one you’re comfortable with:
  • Interactive Wizard
  • Command Line
  • Python API

Using the Interactive Wizard

AITraining Interactive Wizard

1. Start the Wizard

Open your terminal and run:
aitraining
The interactive wizard guides you through configuration.

2. Select Task Type

Choose Text Classification from the menu.

3. Prepare Your Data

Create a simple CSV file called reviews.csv:
text,label
"This product is amazing! Best purchase ever.",positive
"Terrible quality. Complete waste of money.",negative
"Great service and fast delivery.",positive
"Broken on arrival. Very disappointed.",negative
"Exceeded my expectations!",positive
"Would not recommend to anyone.",negative

4. Follow the Prompts

The wizard will ask for:
  • Data path: Enter ./reviews.csv
  • Model: Choose bert-base-uncased (or pick from trending models)
  • Text column: Enter text
  • Label column: Enter label
  • Output directory: Enter ./my-sentiment-model
Wizard Commands:
  • :help - Get help for current step
  • :back - Go back to previous step
  • :exit - Cancel and exit
  • :search <query> - Search for models/datasets
  • :sort <option> - Sort by trending, downloads, likes

5. Start Training

Confirm your settings and training begins. Watch the progress in the terminal.

6. Test with Chat

After training, test your model:
aitraining chat
Open your browser to localhost:7860 and try your model.

What Just Happened?

You’ve successfully:
  1. Prepared data - Created examples for the AI to learn from
  2. Configured training - Selected a model and settings
  3. Trained a model - The AI learned patterns from your examples
  4. Tested predictions - Verified the model works on new text
  5. Saved the model - Can use it anytime without retraining

Understanding the Results

Your model learned to:
  • Recognize positive words and phrases
  • Identify negative sentiment patterns
  • Make predictions on text it hasn’t seen before
With just 6 examples, you got a working model. With more data (hundreds or thousands of examples), accuracy improves significantly.

Common Next Steps

Add More Data

More examples = better accuracy. Try adding 50-100 examples per category.

Try Different Models

Experiment with different base models like distilbert-base-uncased (faster) or roberta-base (more accurate).

Fine-tune Settings

Adjust epochs, learning rate, and batch size for better results.

Deploy Your Model

Learn how to serve your model as an API or integrate it into applications.

Try Other Tasks

Now that you understand the basics, try these:
  • Language Generation - Train a chatbot with conversation examples
  • Image Classification - Sort images into categories
  • Named Entity Recognition - Extract names, places, dates from text
  • Translation - Convert between languages

Troubleshooting

  • Reduce batch size to 4 or 2
  • Use a smaller model like distilbert
  • Ensure you’re using GPU if available
  • Add more training examples
  • Ensure labels are consistent
  • Try training for more epochs
  • Check if your data is balanced
  • Reduce batch size
  • Use a smaller model
  • Enable gradient checkpointing
  • Use LoRA for efficient training

What’s Next?


Pro Tip: Start with the interactive wizard (aitraining) to understand the concepts, then move to CLI for automation, and test your models with the Chat interface (aitraining chat).